Category Archives: Monitoring

Monitoring

D-Link DNS-320 Nagios Monitoring

A quickie post for setting up “nrpe” on a D-Link DNS-320 to allow monitoring from Nagios!

Assumes a working install of funplug and optware already exists 🙂

root@DNS320:# slacker -a nano

root@DNS320:# ipkg install nrpe

root@DNS320:# ipkg install nagios-plugins

root@DNS320:# killall syslogd

root@DNS320:# nano -w /etc/syslogd.conf

(uncomment daemon line, this allows nrpe to log via syslogd)

root@DNS320:# /usr/sbin/syslogd -r -m 0 –rt_line 800

root@DNS320:# touch /var/log/daemon.log

root@DNS320:# useradd –system –shell /bin/false –no-create-home nagios

root@DNS320:# nano -w /opt/etc/nrpe.cfg

(change nrpe_user and nrpe_group to nagios, update allowed_hosts appropriately)

root@DNS320:# cp /opt/etc/init.d/S99nrpe /root

(creates backup of init script)

root@DNS320:# nano -w /opt/etc/init.d/S99nrpe

…..edit S99nrpe to:

#!/bin/shif [ -n "`pidof nrpe`" ] ; then
killall nrpe 2>/dev/null
fi
sleep 2
/opt/sbin/nrpe -c /opt/etc/nrpe.cfg -d

root@DNS320:# /opt/etc/init.d/S99nrpe

root@DNS320:# ps aux |grep nrpe

(nrpe should now be running)

root@DNS320:# tail /var/log/daemon.log

(check log for any error messages)

Unfortunately nagios-plugins in ipkg doesn’t contain check_procs, so:

root@DNS320:# nano -w /opt/libexec/check_procs

…..edit check_procs to:

#!/usr/bin/perl -w
use strict;
my $process = $ARGV[0];
my $processcount = 0;
open STDERR, '>/dev/null';
open(PS, "/bin/ps aux |") or die "Can't run ps: __FILE__ $!";
while (my $line = <PS>) {
    if($line =~ /$process/ and $line !~ /check_proc/) {
        $processcount++;
    }
}
close(PS);
close STDERR;
my $return = 0;
if ($processcount == 0) {
    print "Process $process is NOT running!\n";
    $return = 2;
}
else
{
    print "Process $process occurred $processcount times!\n";
}
exit $return;

D-Link DNS-320 can now be monitored from Nagios!

Thanks for reading,

Martyn Wendon