Dynamic Nagvis maps with GPS

gps2map.pl calculates pixel coordinates of objects with GPS coordinates and produces a Nagvis (a visualization addon for Nagios) configuration file. This allows us to create Nagvis maps with moving objects. First of all, you need to create a map image representing the area in where your mobile objects will be positioned. You can use the parameters below for map image customization:

 

 

     # Ellipsoid type, no need to change normally
     my $ELLIPSOID = 'WGS-84';
     # Map image file
     my $MAP_IMAGE = "$Bin/mymap.png";
     # GPS coordinates for the map origin
     my $GPS_ORIGO_X = 4.023896;
     my $GPS_ORIGO_Y = 60.210969;
     # GPS coordinates for the reference point on the map (Oslo by example)
     my $GPS_REF_X = 10.738741;
     my $GPS_REF_Y = 59.913820;
     # Pixel coordinates of the reference point on the map 
     my $MAP_REF_X = 50;
     my $MAP_REF_Y = 426;

gps2map.pl uses a web service delivering GPS coordinates in XML format. In the example below, we have two ships called ship1 and ship2:

     <?xml version="1.0" encoding="iso-8859-1" ?>
     <ships count="2">
     <ship device_id="6" device_name="ship1" time="xx" latitude="xx" longitude="xx">
     </ship>
     <ship device_id="7" device_name="ship2" time="xx" latitude="xx" longitude="xx">
     </ship>
     </ships>

gps2map.pl calculates pixel coordinates and processes the template file below by replacing tags #map_image#, #ship1_x#, #ship1_y#, #ship2_x# and #ship2_y# with the corresponding values.

     define global {
     allowed_user=EVERYONE
     allowed_for_config=nagiosadmin
     iconset=std_big
     map_image=#map_image#
     show_in_lists=1
     label_show=1
     label_x=+15
     label_y=+0
     only_hard_states=1
     }
 
     define host {
     host_name=gps-ship1
     x=#ship1_x#
     y=#ship1_y#
     iconset=std_small
     label_text=Ship 1
     }
 
     define host {
     host_name=gps-ship2
     x=#ship2_x#
     y=#ship2_y#
     iconset=std_small
     label_text=Ship 2
     }

Output from gps2map.pl is a Nagvis configuration file:

     define global {
     allowed_user=EVERYONE
     allowed_for_config=nagiosadmin
     iconset=std_big
     map_image=mymap.png
     show_in_lists=1
     label_show=1
     label_x=+15
     label_y=+0
     only_hard_states=1
     }
 
     define host {
     host_name=gps-ship1
     x=440
     y=745
     iconset=std_small
     label_text=Ship 1
     }
 
     define host {
     host_name=gps-ship2
     x=415
     y=107
     iconset=std_small
     label_text=Ship 2
     }

Links

Nagvis visualization addon for Nagios
Geo::Coordinates::UTM - Perl extension for Latitiude Longitude conversions
World Geodetic System
Figure of the Earth

AttachmentSize
Plain text icon gps2map.pl.txt5.32 KB

Release announcements