Nagmap: An awesome addon for Nagios and Icinga

Overview

Nagios is one of the best open source IT infrastructure monitoring system available in market. The thing that makes it so powerful are the addons that can enhance its capabilities and give it some teeth. One such addon which is awesome in my view and one of the best I have seen recently is the Nagmap addon. It uses map from google map api version 3, and you don’t need a key for it. The installation is easy and you only need to know about latitude and longitude of the places you show up on the map (you can use Google to get those).

Nagmap: An awesome addon for Nagios and Icinga

1

2

3

4

wget http://labs.shmu.org.uk/nagmap/nagmap-1.0.tar.gz

tar zxvf nagmap-1.0.tar.gz

mv nagmap /var/www/html/

cd /var/www/html/nagmap/

Next edit config.php file under the nagmap directory and set the following parameters according to your environment. Set nagmap_map_center parameter according your central area, I am setting this to India where most of my servers currently reside. If you do not know the path of status file, open the nagios configuration file, it is defined somewhere in this file.

$nagmap_map_centre = '21.7679,78.871'; //set to the centre of your map

$nagmap_map_zoom = 4; //default zoom level of the map

//which google maps type to use?

$nagmap_map_type = 'ROADMAP'; //you can use any of these: ROADMAP or SATELLITE or HYBRID or TERRAIN

Open the status.php file in an editor of choice.

1

vi status.php

Set $fp parameter to the status.dat file

1

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

Next you just need to add a field to the host definition. Open the configuration file containing the host definition

1

vi hosts.cfg

Add notes latlag with the longitude and latitude of your host.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

define host {

use linux-server

host_name ossim

alias ossim

address 127.0.0.1

check_command check_ping!100.0,20%!500.0,60%

notes latlng: -6.914125,107.609393

}

define host {

use linux-server

host_name repo

alias repo

address 192.168.10.10

check_command check_ping!100.0,20%!500.0,60%

notes latlng: 22.5697, 88.369

parents ossim

}

Restart nagios and point your browser to

http://ip-address/nagmap/index.php

If you have parent child relation between the hosts as shown above, you will see lines connecting your servers. You can remove the line by removing parents in the host definition. The line only indicate your network topology.