check_dns
Posted by tonvoon on 3 July 2008 - 12:46am
check_dns v1992 (nagios-plugins 1.4.12)
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
- Printer-friendly version
- Login or register to post comments
To check that a host has a DNS entry containing both the name and ip address used by Nagios, use the following command string:
check_dns -t 30 -s dns.ip.add.ress -H "$HOSTNAME$" -a $HOSTADDRESS$
Would be nice if the check allowed for multiple IP addresses in the result from DNS - then you could use -a $HOSTADDRESS$ in the Nagios Service Check and it wouldn't return a critical status. Otherwise it is necessary to create a separate Service Check for servers with multiple addreses, and since you don't know what order the DNS server may return the addresses, this may also throw a critical error at times.
This command checks for the address entry (A record) but do not check if there is a reverse pointer for it. Also note that in the latest version of check_dns allow checking for multiple addresses. You can either separate the addresses with commas (all addresses must be returned) or repeat the -a argument (any address or address list can match). See help output for more details (check_dns --help).
If you want to check the reverse lookup, you need to check for a PTR record as well (an A record do not guarantee any reverse lookup). I wrote a check for this (sort of) but it do not necessary use DNS (it use the host's standard resolve functions so that may use any other configured method like hosts file or zeroconf). My script do not support multiple addresses either.
See check_lookup here:
http://solaris.beaubien.net/cgi-bin/gitweb.cgi?p=code.git;a=blob_plain;f...