Pages

Wednesday, October 15, 2014

Configure Nagios statusmap with User-supplied coords

The statusmap is most useful if you use the User-supplied coords function (imho). This article covers the following topics:

Add coords to the host definition
Set the User-supplied coords statusmap as default
Change the image from ? to a valid gd2

Add coords to the host definition:

First open a host definition and add the 2d_coords parameter, eg.:

$ cd /opt/nagios/latest/etc/hosts
$ vi wlan01.cfg
define host{
...
        host_name                  wlan01
...
        2d_coords                  200,100
...

The above 2d_coords parameter user x (200) and y (100) values.
When you have done all your changes restart Nagios, click on Map and choose User-supplied coords. Now the hosts will appear in the order you have defined them.

Set the User-supplied coords statusmap as default:

If you want to show the User-supplied coords statusmap directly when clicking on Map then you need to configure the cgi.cfg configuration file and change the value for the default_statusmap_layout parameter to 0:

$ cd /opt/nagios/latest/etc
$ vi cgi.cfg
...
default_statusmap_layout=0
...


Nagios must be restarted to take effect of the changes.

Change the image from ? to a valid gd2:

First check the png file you want to use (the image should not be bigger than 40x40):

$ cd /opt/nagios/latest/share/images/logos
$ file wifi.png
wifi.png: PNG image data, 64 x 64, 8-bit/color RGBA, non-interlaced


The above output indicates that the image needs to be resized:

$ cd /opt/nagios/latest/share/images/logos
$ convert -strip -resize 40x40! wifi.png wifi_40x40.png
$ file wifi_40x40.png
wifi_40x40.png: PNG image data, 40 x 40, 8-bit/color RGBA, non-interlaced


Then create a valid gd2 image from your png, eg:

$ cd /opt/nagios/latest/share/images/logos
$ pngtogd2 wifi_40x40.png wifi.gd2 0 1


Configure the host definition one more time and add the statusmap_image parameter with the new gd2 image:

$ cd /opt/nagios/latest/etc/hosts
$ vi wlan01.cfg
define host{
...
        host_name                  wlan01
...
        2d_coords                  200,100
        statusmap_image            wifi.gd2
...


Restart Nagios and click on Map again. The map will show your prior created gd2 images now.

No comments:

Post a Comment