v-list-sys-dns-status 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # info: list dns status
  3. # options: [FORMAT]
  4. #
  5. # The function lists dns server status
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. #format=${1-shell}
  11. # Includes
  12. #source $VESTA/func/main.sh
  13. source $VESTA/conf/vesta.conf
  14. #----------------------------------------------------------#
  15. # Action #
  16. #----------------------------------------------------------#
  17. # Checking dns system
  18. if [ -z "$DNS_SYSTEM" ]; then
  19. exit
  20. fi
  21. # Checking statistics-file on RHEL/CentOS
  22. if [ -e "/etc/named/named.conf" ]; then
  23. conf="/etc/named/named.conf"
  24. dump_file='/var/named/data/named_stats.txt'
  25. dump_option=" dump-file \"$dump_file\";"
  26. opt_check=$(grep $dump_file $conf |grep -v //)
  27. if [ -z "$opt_check" ]; then
  28. sed -i "s|options {|options {\n$dump_option|" $conf
  29. service named restart >/dev/null 2>&1
  30. fi
  31. fi
  32. if [ -e "/etc/named.conf" ]; then
  33. conf="/etc/named.conf"
  34. dump_file='/var/named/data/named_stats.txt'
  35. dump_option=" dump-file \"$dump_file\";"
  36. opt_check=$(grep $dump_file $conf |grep -v //)
  37. if [ -z "$opt_check" ]; then
  38. sed -i "s|options {|options {\n$dump_option|" $conf
  39. service named restart >/dev/null 2>&1
  40. fi
  41. fi
  42. # Checking statistics-file on Debian/Ubuntu
  43. if [ -e "/etc/bind/named.conf" ]; then
  44. conf="/etc/bind/named.conf.options"
  45. dump_file='/var/cache/bind/named.stats'
  46. #dump_option=" dump-file \"$dump_file\";"
  47. #opt_check=$(grep $dump_file $conf |grep -v //)
  48. #if [ -z "$opt_check" ]; then
  49. # sed -i "s|options {|options {\n$dump_option|" $conf
  50. # service named restart >/dev/null 2>&1
  51. #fi
  52. fi
  53. # Generating dns stats
  54. rm -f $dump_file 2>/dev/null
  55. /usr/sbin/rndc stats 2>/dev/null
  56. # Displaying dns status
  57. if [ -e "$dump_file" ]; then
  58. cat $dump_file
  59. fi
  60. #----------------------------------------------------------#
  61. # Vesta #
  62. #----------------------------------------------------------#
  63. exit