Showing posts with label Nagios. Show all posts
Showing posts with label Nagios. Show all posts

Wednesday, September 22, 2010

Convert .png to .gd2 for Nagios status map

nagios-150x150

If you ever tried to make Nagios web interface look a little nicer by adding some custom host or service icons, you have probably came across collections of icon packs at Nagios Exchange. You have also noticed an unusual .gd2 extension on some of the images and realized that without this format icons don't display properly on Status Map. I was doing exactly that the other day and couldn't find the icons I needed, so I ended up creating some myself. Here's how to convert a PNG image into .gd2 (GD Graphics Library format).

On Ubuntu install libgd-tools package, it will contain a pngtogd2 app. To convert file.png to file.gd2 use:

$ pngtogd2 file.png file.gd2 0 1

Once you have your .png or .gif and .gd2 images, I tend to use 40x40x8bit images with transparent background, place them in your /usr/local/nagios/share/images/logos/ directory (if you installed Nagios from source) and add these properties to your host or service definition:

define host{
        ...
        icon_image              ubuntu.png
        statusmap_image         ubuntu.gd2
        ...
        }

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
        }