Jas*_*ett 2 domain-name-system nagios
我想用 Nagios 监控我的 DNS 服务器。我知道有一个 check_dns 插件,但我完全是 Nagios 菜鸟,我不知道我将如何使用该插件。我想要做的就是确保 nslookup 命令成功。有人可以指出我正确的方向吗?
使用 putty (windows) 或 slogin 在 unix shell 中登录 nagios 服务器。如果您以 root 身份登录,请成为 nagios 用户:
# su - nagios [enter]
Run Code Online (Sandbox Code Playgroud)
转到 /usr/local/nagios/libexec 目录(假设您已经从源代码安装了 nagios,如果您使用了发行版中的软件包,请检查您的软件包的文档):
$ cd /usr/local/nagios/libexec
Run Code Online (Sandbox Code Playgroud)
使用 --help 开关执行 check_dns 插件。它将为您提供所有可用选项:
$./check_dns --help
check_dns v1.4.15 (nagios-plugins 1.4.15)
Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>
Copyright (c) 2000-2008 Nagios Plugin Development Team
<nagiosplug-devel@lists.sourceforge.net>
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 nagios-users@lists.sourceforge.net if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to nagiosplug-devel@lists.sourceforge.net
Run Code Online (Sandbox Code Playgroud)
因此,如果您想检查 serverfault.com 是否解析为 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
Run Code Online (Sandbox Code Playgroud)
如您所见,您还可以使用 -s 开关、警告和临界阈值等来指定要查询的 DNS 服务器。一旦您对从 cli 运行的检查感到满意,您就可以编辑 nagios 配置文件,在其中定义服务(可能是 services.cfg)并将检查应用于给定的主机(组)。但这在您甚至可以从安装 nagios 时安装的 Web 界面中阅读的精美手册中记录得更好。