使用Nagios监控DNS服务器

我想用Nagios监视我的DNS服务器。 我知道有一个check_dns插件,但我是一个总的Nagios noob,我不知道如何去使用插件。 我想要做的就是确保nslookup命令成功。 有人能指出我正确的方向吗?

用putty(windows)或sloginlogin到unix shell。 如果以root身份login,则成为nagios用户:

# su - nagios [enter] 

进入/ usr / local / nagios / libexec目录(假设你已经从源代码安装了nagios,如果你已经使用了发行版的软件包,请检查你的软件包的文档):

 $ cd /usr/local/nagios/libexec 

用–help开关执行check_dns插件。 它会给你所有可用的选项:

 $./check_dns --help check_dns v1.4.15 (nagios-plugins 1.4.15) Copyright (c) 1999 Ethan Galstad <[email protected]> Copyright (c) 2000-2008 Nagios Plugin Development Team <[email protected]> This plugin uses the nslookup program to obtain the IP address for the given host/domain query. An optional DNS server to use may be specified. If no DNS server is specified, the default server(s) specified in /etc/resolv.conf will be used. Usage: check_dns -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit] Options: -h, --help Print detailed help screen -V, --version Print version information -H, --hostname=HOST The name or address you want to query -s, --server=HOST Optional DNS server you want to use for the lookup -a, --expected-address=IP-ADDRESS|HOST Optional IP-ADDRESS you expect the DNS server to return. HOST must end with a dot (.). This option can be repeated multiple times (Returns OK if any value match). If multiple addresses are returned at once, you have to match the whole string of addresses separated with commas (sorted alphabetically). -A, --expect-authority Optionally expect the DNS server to be authoritative for the lookup -w, --warning=seconds Return warning if elapsed time exceeds value. Default off -c, --critical=seconds Return critical if elapsed time exceeds value. Default off -t, --timeout=INTEGER Seconds before connection times out (default: 10) Send email to [email protected] if you have questions regarding use of this software. To submit patches or suggest improvements, send email to [email protected] 

所以,如果你想检查serverfault.comparsing为69.59.196.211,哟做到这一点:

 ./check_dns -H serverfault.com -a 69.59.196.211 DNS OK: 0.013 seconds response time. serverfault.com returns 69.59.196.211|time=0.012614s;;;0.000000 

正如你所看到的,你也可以指定使用-s开关查询哪个DNS服务器,警告和临界阈值等等。一旦你对从cli运行的检查感到满意,你可以编辑你定义的nagiosconfiguration文件服务(可能是services.cfg),并将检查应用到给定的主机(组)。 但是,在精细的手册中,您甚至可以从安装nagios时安装的Web界面中读取这些信息。

你可能已经有了在你的股票nagiosconfiguration中定义的命令,如下所示:

 define command{ command_name check_dns command_line /usr/lib/nagios/plugins/check_dns -H google.ca -s $HOSTADDRESS$ } 

我在/etc/nagios/objects/commands.cfg

最简单的情况是定义一个服务来检查主机上的DNS服务器:

 define service{ use generic-service host_name ns1 service_description DNS check_command check_dns } 

请注意,这假定:

  • 您已经将ns1设置为主机
  • 你有一个模板generic service已经设置了有用的默认值
  • 已经定义了主机或模板依赖的任何其他对象,如时间段和联系人

Nagios是一个非常复杂的工具,没有真正简单的“快速入门”。

为了使命令在正确的位置查找二进制check_dns,最好使用nagiosvariables(默认安装)来定义它:

 define command{ command_name check_dns command_line $USER1$/check_dns -H www.example.com -a 93.184.216.119 -s $HOSTADDRESS$ } 

以上命令检查被testing的服务器是否返回主机名www.example.com的地址93.184.216.119

运行插件与-h,它应该给你如何使用它的文件。 正常参数包括要testing的主机,限制关键和警告限制。 DNStesting可能会包括你想要查找的内容。