Nagios plugin: check_rdns

check_rdns is a plugin for the system monitoring software Nagios, which allows to check reverse DNS entries using the tool dig.

The current version is available on git.sthu.org.

The plugin can be invoked with -h to get a list of options.

% ./check_rdns -h
check_rdns v0.1
Copyright (c) 2013 Stefan Huber <shuber@sthu.org>
    
Usage: check_rdns -H ip-address [OPTIONS]

Arguments:
    -H, --address IP-address    The ip-addres on which reverse-DNS is performed.

Options:
    -h, --help                  Print this text.
    -a, --expect=HOST           The expected result.
    -s, --server=HOST           The DNS server to contact.
    -t, --timeout=SEC           Seconds before lookup times out. (Default: 10)
    -w, --warning=MSEC          Return warning if lookup time exceeds value.
    -c, --critical=MSEC         Return critical if lookup time exceeds value.
    -V, --version               Print version info.

In my case, I actually use Icinga instead of Nagios. Anyway, I added the following lines to ‘/etc/nagios-plugins/config/dns.cfg’ to make check_rdns available for service definitions:

# 'check_rdns' command definition
define command{
        command_name    check_rdns
        command_line    /usr/lib/nagios/plugins/check_rdns -H '$HOSTADDRESS$' \
-w 100 -c 1000 -a '$ARG1$'
}

In the above code, the backslash indicates that the line should be continued without a line break.