nagios check_dns / check_ip example

Need to monitor an IP address / DNS entry with Nagios? Nagios has a plugin called check_dns just for that.

The check commands are defined in this file: /etc/nagios-plugins/config/dns.cfg

# 'check_dns' command definition
define command{
        command_name    check_dns
        command_line    /usr/lib/nagios/plugins/check_dns -H www.google.com -s '$HOSTADDRESS$'
}

# 'check_dig' command definition
define command{
        command_name    check_dig
        command_line    /usr/lib/nagios/plugins/check_dig -H '$HOSTADDRESS$' -l '$ARG1$'
}

here is an alternate version I wrote to check the IP of a host, I could have used check_ip because I don’t think that command is taken, but instead I used my_check_dns:

#my_check_dns command, checks to make sure a hostname resolved to a specified IP address:

define command {
        command_name my_check_dns
        command_line    /usr/lib/nagios/plugins/check_dns -H $ARG1$ -a $ARG2$
}

this is how it would be implemented in a service:

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       mysite.com
        service_description             check dns
        check_command                   my_check_dns!www.mysite.com!123.456.78.90
        }

Man Page:

check_dns v1.4.14 (nagios-plugins 1.4.14)
Copyright (c) 1999 Ethan Galstad <nagios @nagios.org>
Copyright (c) 2000-2008 Nagios Plugin Development Team
    <nagiosplug [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]</nagiosplug></nagios>

Related Posts:

  • No Related Posts
This entry was posted in Security, Server Admin and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *