Tuesday, September 21, 2010

Check NFS & memcached with Nagios

Recently I had to add a lot of new checks to my Nagios monitoring at work, here's a coupe that you can do without having to find dedicated plugins.

NFS

You can quickly check whether NFS server is up by using check_rpc plugin like so:
./check_rpc –H host –C nfs
Here's my command definition:
define command{
        command_name    check_nfs
        command_line    $USER1$/check_rpc -H $HOSTADDRESS$ -C nfs
        }

memcached

There are some dedicated plugins in the web for this one, but for my purposes this blog post was just the perfect solution. Memcached has a simple text based protocol and by default listens for connection on port 11211. So for a simple check I'm asking memcached for its version via TCP connection and expecting a response with word "VERSION" in it within 5 seconds:
./check_tcp -H host -p11211 -E -s 'version\n' -e 'VERSION' -w2 -c5 –t5
Here's my command definition:
define command{
        command_name    check_memcache
        command_line    $USER1$/check_tcp --hostname=$HOSTADDRESS$ --port=11211 --escape -s 'version\r\n' --expect='VERSION' --warning=2 --critical=5 --timeout=5
        }