2

I want to monitor my DNS server with Nagios. I understand there's a check_dns plugin but I'm a total Nagios noob and I have no idea how I would go about using the plugin. All I want to do is the equivalent of making sure an nslookup command succeeds. Can someone point me in the right direction?

4 Answers 4

9

login the nagios server with putty (windows) or slogin in a unix shell. If you login as root, become the nagios user:

# su - nagios [enter]

Go to the /usr/local/nagios/libexec dir (assuming you have installed nagios from source, if you have used a package from your distribution, check the docs of your package):

$ cd /usr/local/nagios/libexec

execute the check_dns plugin with the --help switch. It will give you all the available options:

$./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]

So, if you want to check that serverfault.com resolves to 69.59.196.211, yo do this:

./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

As you can see you can also especify which DNS server to query with the -s switch, warning and critical thresholds, etc. Once you're satisfied with the check you run from the cli, you edit the nagios config file where you define the services (probably services.cfg) and apply the check to a given host(group). But that is much better documented in the fine manual you can even read from the web interface that got installed when you installed nagios.

2

You probably already have the command defined in your stock nagios config like so:

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

Mine is in /etc/nagios/objects/commands.cfg

The most simple case is to define a service that checks the DNS server on the host:

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

Note that this assumes:

  • that you have ns1 set up as a host already
  • that you have a template generic service already set up with useful defaults
  • that any other objects that either the host or the template depend on, like time periods and contacts, are already defined

Nagios is a pretty complicated tool, there's no really easy 'quick start'.

1

In order that the command looks for binary check_dns in the right place better to define it using nagios variables (default installation):

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

The above command checks that the server being tested returns the address 93.184.216.119 for hostname www.example.com

0

Run the plugin with -h and it should give you documentation on how to use it. Normal paramters include the host to test, limits for critical and warning limits. DNS test will likely include what you want to look up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .