Some time ago I came across NagMap addon for Nagios and found it pretty helpful for monitoring multiple hosts around the world.

For example, there are some production servers in Europe, US and others in India and New Zealand and it’s much better see their states on the map rather than using boring Nagios host status list. Every host can have one of the following states based on ping statistics: green, yellow and red. Green/white (ok) status corresponds to 0-10% packet loss, yellow (warning) is 10-20% packet loss and red (critical) means the host is down or packet loss to it is more than 20%. All three states are shown on the map using different markers.

Using NagMap addon for Nagios it’s possible to create a map of the hosts and their states based on Google Maps, here is some part of my map:

Above screenshot shows all hosts in OK state (desired picture) so in case when some host goes down or becomes sluggish then you’ll see some red markers like this or (depending on type of the host).

Setup and configure NagMap

So first of all you need to download nagmap tarball from project’s download section and unpack it somewhere on the server that hosts Nagios monitoring system. Downloaded tarball contains PHP scripts which will access Nagios’s status file and show corresponding markers on the map using Google Maps. I suggest to create new subdir in directory where Nagios files are located:

cd /usr/share/nagios/
wget http://labs.shmu.org.uk/nagmap/nagmap-0.11.tar.gz
tar -xvzf nagmap-0.11.tar.gz
rm nagmap-0.11.tar.gz

Once unpacked the archive it’s necessary to set path to Nagios status file in Nagmap’s file status.php. In my case Nagios’s status.dat file is located at /var/nagios/status.dat so I have the following line in nagmap’s status.php:

$fp = fopen("/var/nagios/status.dat","r");

It’s natural that web server must have enough rights to read /var/nagios/status.dat file.

The next step is to set up geographical location for the hosts which should be shown at Nagmap. It should be specified in the following way:

define host {
        use generic-host
        host_name HostName1
        address 11.22.33.44
        notes latlng: 40.664167, -73.938611
        check_command check-host-alive
        register 1
}

Where “40.664167, -73.938611″ is longitude and latitude of the host (New York city in this example). So you should add ‘notes latlng:’ lines to all host in Nagios to see them on the map.

From this point you should be able to open the map, e.g. https://your.server.com/nagios/nagmap/ URL. If opened page is empty then there is some problem in reading or parsing status.dat file. Unfortunately nagmap doesn’t provide debug feature so you should open marker.php (e.g. https://your.server.com/nagios/nagmap/marker.php) and look into its output to see where’s the problem. Most probably you’ll need some basic PHP knowledge. Btw, file marker.php contains paths to marker images so you can easily change them from default there.

 

5 Comments

 

  1. Pingback : Links 4/7/2012: Blizzard’s Linux PR Crisis, Fuduntu 2012.3 Released | Techrights

  2. Pingback : Geolocation for Nagios - LinuxOS Pro

  3. March 22, 2013  9:16 pm by flight deals india Reply

    I am extremely impressed with your writing skills as neatly as with the layout in your weblog. Is that this a paid topic or did you customize it yourself? Anyway stay up the excellent quality writing, it is rare to look a great weblog like this one nowadays..| flight deals india http://www.funtraveldeals.com/book-flights/

  4. March 22, 2013  9:46 pm by agate cameo Reply

    Hiya very nice blog!! Guy .. Beautiful .. Superb .. I'll bookmark your blog and take the feeds also? I'm happy to seek out numerous useful information here within the post, we'd like work out more techniques on this regard, thank you for sharing. . . . . .| agate cameo http://www.goldmemoriesforever.com

  5. May 7, 2013  7:11 pm by DebraHughes Reply

    Excuse for that I interfere ? At me a similar situation. Is ready to help.

Leave a reply

 

Your email address will not be published.