addons:xymonmap

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
addons:xymonmap [2012/01/25 19:29] – external edit 127.0.0.1addons:xymonmap [2016/09/20 12:01] (current) – [xymonmap.pl] b-art
Line 93: Line 93:
 use strict; use strict;
 use XML::Simple; use XML::Simple;
 +$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
  
 my $XYMONHOME = "/opt/mms/server"; my $XYMONHOME = "/opt/mms/server";
 my $XYMON = "$XYMONHOME/bin/xymon"; my $XYMON = "$XYMONHOME/bin/xymon";
-my $localhost = "mms-test";+my $localhost = "localhost.localdomain";
 my $cgiloc = "mms-cgi"; my $cgiloc = "mms-cgi";
 #PO - More information for the status message #PO - More information for the status message
 my $theEpoch = time(); my $theEpoch = time();
 my $kaoDate = localtime($theEpoch); my $kaoDate = localtime($theEpoch);
- 
 #PO - Declare $machineName and $testName and concatenate them for the links on the pop-ups. #PO - Declare $machineName and $testName and concatenate them for the links on the pop-ups.
 # $XYMESSAGE is for UNIX/Linux # $XYMESSAGE is for UNIX/Linux
-my ($machineName, $testName, $YXMESSAGE);+my ($machineName, $testName, $XYMESSAGE);
  
 ######################## START CONFIG ######################## START CONFIG
-# Might need some degug+# Might need some debug
 my $DEBUG = 'N'; my $DEBUG = 'N';
  
 # You should use an FQDN or IP address of the XYMONServer # You should use an FQDN or IP address of the XYMONServer
-my $xymon_web_server = '172.29.153.62';+my $xymon_web_server =  "192.168.56.102"; 
 # The top URL directory name for the Xymon webpages # The top URL directory name for the Xymon webpages
 my $xymon_web_folder = 'mms'; my $xymon_web_folder = 'mms';
Line 125: Line 126:
  
 #-------- Define the initial lat/long to display in the report #-------- Define the initial lat/long to display in the report
-my $init_lat = '4.726811'; # +my $init_lat = '17.10430'; # 
-my $init_long = '50.848775'; # This configuration is for the Leuven view +my $init_long = '45.34530'; # This configuration is for the Servië view 
-my $init_zoom_level = '9'; #+my $init_zoom_level = '4'; #
  
 ######################## END CONFIG ######################## END CONFIG
Line 135: Line 136:
 my $testFailed; my $testFailed;
 my $COLOR = ''; my $COLOR = '';
 +my $device = ' ';
 +my $sitecolor = "green";
 my $pin_message; my $pin_message;
 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
 $year = $year + 1900; $year = $year + 1900;
 +
 # Start a log file, if it's empty when the script ends we'll delete it - so if it's there you know something went wrong. # Start a log file, if it's empty when the script ends we'll delete it - so if it's there you know something went wrong.
 my $ERRORFILE = "/var/log/mms/xymon_geo_map.log"; my $ERRORFILE = "/var/log/mms/xymon_geo_map.log";
 open (STDERR, ">${ERRORFILE}"); open (STDERR, ">${ERRORFILE}");
- 
 open(OUT, "> $xymon_hist") or die "Can't open $xymon_hist\n"; open(OUT, "> $xymon_hist") or die "Can't open $xymon_hist\n";
  
Line 147: Line 150:
 #     report or things won't work right. So, I call html_start() in the process_data subroutine. #     report or things won't work right. So, I call html_start() in the process_data subroutine.
 #html_start(); #html_start();
- 
 process_data(); process_data();
- 
 html_end(); html_end();
 close(OUT); close(OUT);
Line 171: Line 172:
     #PO - substitute the commas for dots, but, this has to be converted back for the links to each status message on the pop-ups, PAINFUL!!!     #PO - substitute the commas for dots, but, this has to be converted back for the links to each status message on the pop-ups, PAINFUL!!!
     $target_node =~ s/,/./g;     $target_node =~ s/,/./g;
-    print "TARGET_NODE: $target_node\n" if ($DEBUG eq 'Y'); +print "TARGET_NODE: $target_node\n" if ($DEBUG eq 'Y'); 
 +print "sitecolor:  $sitecolor\n" if ($DEBUG eq 'Y');
     open (IN, "< " . $xymon_hist_path . $lf);     open (IN, "< " . $xymon_hist_path . $lf);
     while (<IN>){     while (<IN>){
Line 182: Line 183:
         $color = $l1x[1];         $color = $l1x[1];
  $testFailed = 0;  $testFailed = 0;
- $testFailed = 1 if ($color eq 'red' || $color eq 'purple'); + $testFailed = 1 if ($color eq 'red' || $color eq 'purple'|| $color eq 'yellow'); 
 +# $testFailed = 1 if ($color eq 'red' || $color eq 'purple');
  #PO - change commas to dots in the log file name  #PO - change commas to dots in the log file name
  ($machineName, $testName) = split(/\./, $lf, 2);  ($machineName, $testName) = split(/\./, $lf, 2);
  $lf =~ s/,/./g;  $lf =~ s/,/./g;
  #PO - DEBUG output  #PO - DEBUG output
- #print "Test Failed [$testFailed]: $lf - $mpart1 - $color\n\n" if ($color ne 'green' && $color ne 'clear');+ print "Test Failed [$testFailed]: $lf - $mpart1 - $color\n\n" if ($color ne 'green' && $color ne 'clear' && $DEBUG eq 'Y');
       }       }
     }     }
Line 194: Line 195:
  
     if ($testFailed == 1) {     if ($testFailed == 1) {
- $COLOR = 'yellow';+ 
 +# $COLOR = 'yellow'; 
 + $COLOR = 'green';
  
 $machineName =~ s/\.[A-z]+$//g; $machineName =~ s/\.[A-z]+$//g;
 $machineName =~ s/\.//g; $machineName =~ s/\.//g;
 + if ($device eq $machineName){ 
 + if ($color eq 'red' || $sitecolor eq 'red') { 
 + $sitecolor = "red"; 
 + }elsif ($color eq 'purple' && $sitecolor ne 'red'){ 
 + $sitecolor = "purple"; 
 + }elsif ($color eq 'yellow' && ($sitecolor ne 'red' || $sitecolor ne 'purple')){ 
 + $sitecolor = "yellow"; 
 + }else {$sitecolor = "green"; 
 +
 + } else {$sitecolor = "green"; 
 +
 +$device = $machineName;
 next if ($color eq 'green' || $color eq 'clear'); next if ($color eq 'green' || $color eq 'clear');
- #print "machineName: ${machineName} - Test: $testName - Color: $color\n"; + PO DEBUG output 
- + print "machineName: ${machineName} - Test: $testName - Color: $color\n" if ($DEBUG eq 'Y')
- #PO - For Windows: + $pin_message .= '<html><br><font color=' . $color . '><A HREF=\\"http://' . $xymon_web_server . '/' . $cgiloc . '/svcstatus.sh?HOST=' . ${machineName} . '&SERVICE=' . ${testName} . '\\">' . $lf . '<img src=\"/mms/gifs/' . $color . '.gif\">' . ' [ '. $color . ' ]' . '</A></font></html>'; 
- $pin_message .= '<html><br><font color=' . $color . '><A HREF=\\"http://' . $xymon_web_server . '/' . $cgiloc . '/svcstatus.sh?HOST=' . ${machineName} . '&SERVICE=' . ${testName} . '\\">' . $lf . ' [ '. $color . ' ]' . '</A></font></html>';+ #PO DEBUG output
  print "<html><br><font color=' . $color . '><A HREF=\"http://' . $xymon_web_server . '/' . '$cgiloc/svcstatus.sh?HOST=' . $lf . '\">' . $lf . ' [ '. $color . ' ]' . '</A></font></html>" if ($DEBUG eq 'Y');  print "<html><br><font color=' . $color . '><A HREF=\"http://' . $xymon_web_server . '/' . '$cgiloc/svcstatus.sh?HOST=' . $lf . '\">' . $lf . ' [ '. $color . ' ]' . '</A></font></html>" if ($DEBUG eq 'Y');
- 
- 
         $alert_locales->{$lat_long_ref->{locale}->{$target_node}->{lat}}->{$lat_long_ref->{locale}->{$target_node}->{long}}->{message} .= $pin_message;         $alert_locales->{$lat_long_ref->{locale}->{$target_node}->{lat}}->{$lat_long_ref->{locale}->{$target_node}->{long}}->{message} .= $pin_message;
         my $tmp_locale = $lat_long_ref->{locale}->{$target_node}->{lat} . ',' . $lat_long_ref->{locale}->{$target_node}->{long};         my $tmp_locale = $lat_long_ref->{locale}->{$target_node}->{lat} . ',' . $lat_long_ref->{locale}->{$target_node}->{long};
Line 212: Line 224:
    push(@ary_alert_locales, $tmp_locale);     push(@ary_alert_locales, $tmp_locale); 
         }         }
-    }  +    } 
 +print "sitecolor-last:  $sitecolor\n" if ($DEBUG eq 'Y');
   }   }
  
Line 231: Line 244:
 sub html_start() { sub html_start() {
   $COLOR = 'yellow' if ($testFailed == 1);   $COLOR = 'yellow' if ($testFailed == 1);
- +  print (OUT '<img src=/mms/gifs/'$sitecolor . '.gif> ' . "${kaoDate}\n<strong>We have 1 datacenters in Hasselt and 1 in Leuven</strong>.\n");        
-  print (OUT "${COLOR} ${kaoDate}\n<strong>We have 1 datacenters in Hasselt and 1 in Leuven</strong>.\n");      +
   print (OUT '     <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>' . "\n");   print (OUT '     <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>' . "\n");
              
Line 261: Line 273:
   print (OUT '      pinID, ' . "\n");   print (OUT '      pinID, ' . "\n");
   print (OUT '      new VELatLong(long_in, lat_in), ' . "\n");   print (OUT '      new VELatLong(long_in, lat_in), ' . "\n");
-  print (OUT '      "/mms/gifs/red.gif", ' . "\n"); 
-  print (OUT '      \'<img src="/mms/gifs/red.gif"> \' + device_in,' . "\n"); 
  
 +#  print (OUT '      "/mms/gifs/red.gif", ' . "\n");
 +  print (OUT '      "/mms/gifs/' . $sitecolor . '-recent.gif", ' . "\n");
 +#  print (OUT '      \'<img src="/mms/gifs/yellow.gif"> \' + device_in,' . "\n");
 +  print (OUT '      \'<img src="/mms/gifs/' . $sitecolor . '.gif"> \' + device_in,' . "\n");
   print (OUT '      alert_in,' . "\n");   print (OUT '      alert_in,' . "\n");
   print (OUT '      "iconStyle",' . "\n");   print (OUT '      "iconStyle",' . "\n");
Line 295: Line 309:
 if(-z $ERRORFILE) { unlink $ERRORFILE; } if(-z $ERRORFILE) { unlink $ERRORFILE; }
  
-my $cmd = "$XYMON localhost \"status $localhost.xymonmap $COLOR `date`: XYMON map\n<iframe src=\"http://$xymon_web_server/$xymon_web_folder/html/xymonmap.html\" width=\"930\" height=\"522\" align=\"center\"></iframe>\"";+#my $cmd = "$XYMON localhost \"status $localhost.xymonmap $COLOR `date`: XYMON map\n<iframe src=\"http://$xymon_web_server/$xymon_web_folder/html/xymonmap.html\" width=\"930\" height=\"522\" align=\"center\"></iframe>\""; 
 +my $cmd = "$XYMON localhost \"status $localhost.xymonmap $COLOR `date`: XYMON map\n<object data=\"http://$xymon_web_server/$xymon_web_folder/html/xymonmap.html\" width=\"930\" height=\"522\"> <embed src=http://$xymon_web_server/$xymon_web_folder/html/xymonmap.html width=\"900\" height=\"522\"> </embed> Error: Embedded data could not be displayed. </object>\"";
  
-print "$cmd\n";+#print "$cmd\n";
 system ($cmd); system ($cmd);
  
Line 375: Line 390:
   * **2012-01-20**   * **2012-01-20**
     * Initial release     * Initial release
 +  * **2016-09-20** 
 +    * Added alert color code onto the failing site. 
 +    * Changed webpage embedding in the Xymon page from iFrame to HTML5 embed TAG.
  • addons/xymonmap.1327519751.txt.gz
  • Last modified: 2016/09/20 09:42
  • (external edit)