StatusMaps Nagios With Google Maps

Traiano Welcome twelcome at tenet.ac.za
Mon Jun 22 15:57:46 CEST 2009


Hi Deocir

I have a (not very elegant) but working implementation of this, below is 
a description that you may be able to use as a rough example to 
construct your own, and attached is the scripts I use:


The system is composed of a number of components

1. Google API Frontend (NAGIOS-monitored sites over a map display):
----------------------------------------------------------------------------------------------

The GoogleMaps frontend scripts are based on examples provided in the 
API tutorial, and modified to display sites stored in a mysql database 
table. The scripts draw individual sites with markers coloured blue or 
red depending on whether the site is up or down, and also links 
(representing WAN links) between sites defined by two GPS end-points.


2. Node and Link Editing Interface (so users can edit WAN links and site 
markers)
-----------------------------------------------------------------------------------------------------------

PHP scripts provide an interface to define single nodes on a map, which 
represent sites monitored by NAGIOS, and also WAN links between two
sites that have been defined. Basically, the scripts allow you to enter 
site details and GPS coordinates into a database table, which the Google API
code will read and represent on the GoogleMap.

3. Database Backend (to hold site GPS coordinates and site status info):
---------------------------------------------------------------------------------------------

Mysql database tables hold information defining a "site" on the map, i.e 
GPS coordinates, colour of the marker, name of the site and
a short textual description of the site which will pop up on the map "on 
mouse-over ".

The GoogleMap frontend code reads these tables in order to draw links 
and individual sites. The tables are edited through a simple HTML/PHP 
frontend in order to define sites and links.

4. Site Marker update script (to update the status of site markers on 
the map according to NAGIOS alerts)
------------------------------------------------------------------------------------------------------------------------------------------

NAGIOS sends alerts via email to an email alias on the web server, the 
alias is to a perl script which parses the email and updates the status 
of the site in the database table. Depending on the status of a site 
(UP/DOWN) the colour of the marker for a given site is changed between 
Blue and Red, and this will show up on the GoogleMap frontend.


Attached are the scripts that comprise the system, below is a 
description of how they're arranged in the file hierarchy on my web server:

Web front-end scripts:

-----
traiano at sparklight:/var/www/maps/# ls -l

-rw-r--r-- 1 root root 3921 2009-06-19 13:40 index.html
-rw-r--r-- 1 root root 4950 2009-06-19 13:40 mapedit.php

-rwxr-xr-x 1 root root 90 2009-06-19 13:40 phpsqlajax_dbinfo.php
-rwxr-xr-x 1 root root 1277 2009-06-19 13:40 phpsqlajax_genxml_lines.php
-rwxr-xr-x 1 root root 1238 2009-06-19 13:40 phpsqlajax_genxml.php

-rwxr-xr-x 1 root root 1965 2009-06-19 13:40 store_link.php
----


Perl code and files to update the status of sites in the database

----
traiano at sparklight:/var/local/google_mapping# ls -la *

-rw-rw-rw- 1 root staff 98222 2009-06-03 19:36 msg.log
-rw-r--r-- 1 root staff 230 2009-02-09 15:33 sample.dat
-rw-rw-rw- 1 root staff 773 2009-06-03 19:36 site_status.dat

bin:
total 12
drwxr-sr-x 2 root staff 4096 2009-02-09 15:38 .
drwxrwsrwx 3 root staff 4096 2009-06-19 13:45 ..
-rwxr-xr-x 1 root staff 2279 2009-02-09 15:38 update_marker_status.pl
----

Database schema and sample data:


--- tables in the google mapping database ----

mysql> show tables;

+--------------------------+
| Tables_in_google_mapping |
+--------------------------+
| map_items |
| map_links |
| map_node_relations |
| map_nodes |
| markers |
+--------------------------+
5 rows in set (0.00 sec)


--- map_items ----

The map_items table holds items for a drop down list so the user can 
select the colour of a link when defining it through the interface:


mysql> describe map_items;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| link_colour | varchar(255) | NO | | #FF0000 | |
| link_width | int(16) | NO | | 3 | |
+-------------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)


mysql> select * from map_items;
+----+-------------+------------+
| id | link_colour | link_width |
+----+-------------+------------+
| 1 | #FFFFFF | 1 |
| 2 | #FFF200 | 2 |
| 3 | #00FF00 | 3 |
| 4 | #FF5F00 | 4 |
+----+-------------+------------+
4 rows in set (0.00 sec)



--- map_links ----

The map_links table holds the coordinate information required for the 
GoogleMap API to draw a link. The coords are taken from sites that have 
already been defined in the "markers" table.

mysql> describe map_links;

+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| link_id | varchar(255) | NO | | UNKNOWN | |
| link_parent | int(16) | NO | | 0 | |
| parent_coord | varchar(255) | NO | | UNKNOWN | |
| link_child | int(16) | NO | | 0 | |
| child_coord | varchar(255) | NO | | UNKNOWN | |
| link_state | varchar(255) | NO | | UP | |
| link_desc | varchar(255) | NO | | UNKNOWN | |
| link_colour | varchar(255) | NO | | #002A97 | |
| link_width | int(16) | NO | | 3 | |
+--------------+--------------+------+-----+---------+----------------+
10 rows in set (0.00 sec)

mysql> select * from map_links limit 1;
+----+---------+-------------+----------------------+------------+----------------------+------------+------------------+-------------+------------+
| id | link_id | link_parent | parent_coord | link_child | child_coord | 
link_state | link_desc | link_colour | link_width |
+----+---------+-------------+----------------------+------------+----------------------+------------+------------------+-------------+------------+
| 7 | 85-44 | 85 | -29.134351,23.044633 | 44 | -24.193867,24.055133 | UP 
| SITE85-SITE44 Link | #002A97 | 3 |
+----+---------+-------------+----------------------+------------+----------------------+------------+------------------+-------------+------------+
1 row in set (0.00 sec)



--- markers ---


The markers table holds details of each monitored site that will be 
required for the Googlemap API scripts to place site markers on the map. 
The details
are added via a simple PHP web form the users fill in:


mysql> describe markers;
+---------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(60) | NO | | | |
| address | varchar(80) | NO | | | |
| lat | float(10,6) | NO | | | |
| lng | float(10,6) | NO | | | |
| type | varchar(30) | NO | | | |
+---------+-------------+------+-----+---------+----------------+
6 rows in set (0.01 sec)


An example of a defined site (marker) in the table:


mysql> select * from markers limit 1;
+----+-------+----------------------------------------------------------------------------------+------------+-----------+------+
| id | name | address | lat | lng | type |
+----+-------+----------------------------------------------------------------------------------+------------+-----------+------+
| 1 | NUMC | University of Lalaland, Primary PABX Room | -24.887315 | 
45.985916| UP |
+----+-------+----------------------------------------------------------------------------------+------------+-----------+------+
1 row in set (0.00 sec)



Deocir Ribeiro Luz wrote:
> Hi all,
>
> I'm new in this list, so I don't know if this was discussed here. I'm
> studing the API Google Maps with the objective of the integrate of the
> statusmaps of nagios with the Google Maps. I need do this, are there
> some person that did this here that can help me?
>
> Thanks
> Deocir Ribeiro Luz
>
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing 
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: google-mapping-documentation.tar.gz
Type: application/gzip
Size: 15517 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20090622/f9db15ca/attachment.bin>
-------------- next part --------------
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list