]> git.pld-linux.org Git - packages/nagios.git/commitdiff
- google map in statusmap support; rel 7
authorElan Ruusamäe <glen@pld-linux.org>
Thu, 22 Oct 2009 16:05:45 +0000 (16:05 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    googlemap.js -> 1.1
    nagios-googlemap.patch -> 1.4
    nagios.spec -> 1.148

googlemap.js [new file with mode: 0644]
nagios-googlemap.patch
nagios.spec

diff --git a/googlemap.js b/googlemap.js
new file mode 100644 (file)
index 0000000..918bf78
--- /dev/null
@@ -0,0 +1,87 @@
+function setMapCookie(map) {
+       document.cookie = 'googlemaplng=' + map.getCenter().lng();
+       document.cookie = 'googlemaplat=' + map.getCenter().lat();
+       var zoom = map.getZoom();
+       document.cookie = 'googlemapzoom=' + zoom;
+       document.layoutform.scaling_factor.value =+ zoom;
+}
+
+function readCookie(name) {
+       var nameEQ = name + "=";
+       var ca = document.cookie.split(';');
+       for(var i=0;i < ca.length;i++) {
+               var c = ca[i];
+               while (c.charAt(0)==' ') c = c.substring(1,c.length);
+               if (c.indexOf(nameEQ) == 0) {
+                       c=c.substring(nameEQ.length,c.length);
+                       while (c.substring(c.length-1, c.length) == ' ')
+                               c = c.substring(0,c.length-1);
+                       return c;
+               }
+       }
+       return null;
+}
+
+function createMarker(hostname, comment, lat, long, state) {
+       var point = new GLatLng(lat,long);
+       var marker;
+       if (state == "Up") {
+               var baseIcon = new GIcon();
+               baseIcon.shadow = gstatusmap.images_url + "shadow50.png";
+               baseIcon.iconSize = new GSize(20, 34);
+               baseIcon.shadowSize = new GSize(37, 34);
+               baseIcon.iconAnchor = new GPoint(9, 34);
+               baseIcon.infoWindowAnchor = new GPoint(9, 2);
+               baseIcon.infoShadowAnchor = new GPoint(18, 25);
+               var okicon = new GIcon(baseIcon);
+               okicon.image = gstatusmap.images_url + "marker.png";
+               marker = new GMarker(point, okicon);
+       } else {
+               marker = new GMarker(point);
+       }
+       GEvent.addListener(marker, "click", function() { 
+               marker.openInfoWindowHtml("<b>" + hostname + "</b><br/>" + comment + "<br/>State: " + state + "");
+       });
+       return marker;
+}
+
+function load() {
+       if (!GBrowserIsCompatible()) {
+               return
+       }
+
+       var map = new GMap2(document.getElementById("map"));
+       map.addControl(new GLargeMapControl3D());
+       map.addControl(new GOverviewMapControl());
+       map.addControl(new GMenuMapTypeControl());
+
+       GEvent.addListener(map, "click", function () {
+               setMapCookie(map);
+       });
+       GEvent.addListener(map, "move", function () {
+               setMapCookie(map);
+       });
+       GEvent.addListener(map, "zoom", function () {
+               setMapCookie(map);
+       });
+       var googlemaplat = readCookie('googlemaplat');
+       var googlemaplng = readCookie('googlemaplng');
+       var centerPoint;
+       if (googlemaplng != null && googlemaplat != null) {
+               centerPoint = new GLatLng(googlemaplat, googlemaplng);
+       } else {
+               centerPoint = new GLatLng(gstatusmap.lat, gstatusmap.lng);
+       }
+
+       var scale = readCookie('googlemapzoom') || gstatusmap.scale || 100;
+       map.setCenter(centerPoint, parseInt(scale));
+       document.layoutform.scaling_factor.value = scale;
+
+       // insert markers
+       for (var i in gstatusmap.markers) {
+               var marker = gstatusmap.markers[i];
+               if (marker) {
+                       map.addOverlay(createMarker(marker[0], marker[1], marker[2], marker[3], marker[4]));
+               }
+       }
+}
index 3b51703f99656ed0a0a5bd10b1d0f81cf248c528..12cdd1e321f9920183f7e8a65f20162cdedcf65e 100644 (file)
@@ -1,5 +1,5 @@
---- nagios-3.2.0.googlemap/cgi/statusmap.c     2009-10-22 17:05:32.644615709 +0300
-+++ nagios-3.2.0/cgi/statusmap.c       2009-10-22 18:02:00.526776437 +0300
+--- nagios-3.2.0/cgi/statusmap.c       2009-10-22 18:19:21.913340828 +0300
++++ nagios-3.2.0.googlemap/cgi/statusmap.c     2009-10-22 18:19:06.830007817 +0300
 @@ -27,6 +27,10 @@
   *
   *****************************************************************************/
        initialize_graphics();
        draw_background_image();
        draw_background_extras();
-@@ -876,6 +908,13 @@
-   
-       /******************************/
-+      /***** GOOGLEMAP LAYOUT MODE *****/
-+      /******************************/
-+      if(layout_method==LAYOUT_GOOGLEMAP){
-+                      
-+      }
-+
-+      /******************************/
-       /***** MANUAL LAYOUT MODE *****/
-       /******************************/
 @@ -1563,10 +1602,19 @@
        return;
          }
        int translated_x;
        int translated_y;
  
-+      if (layout_method==LAYOUT_GOOGLEMAP)
++      if (layout_method == LAYOUT_GOOGLEMAP)
 +              return;
        
        /* user didn't supply any coordinates for hosts, so display a warning */
        if(coordinates_were_specified==FALSE){
-@@ -2241,6 +2291,287 @@
+@@ -2241,6 +2291,197 @@
  /************************* MISC FUNCTIONS *************************/
  /******************************************************************/
  
 +      }
 +      fclose(fp);
 +
-+      printf("<script src='http://maps.google.com/maps?file=api&amp;v=2&key=%s&amp;sensor=false' type='text/javascript'></script>\n",gen_loc.key);
-+
-+      printf("<script type='text/javascript'>\n"
-+      "//<![CDATA[ \n");
-+
-+      // printf("<script type=javascript src="webbserverfil" />);
-+
-+      printf("function setMapCookie(map) {"
-+              "document.cookie = 'googlemaplng='+map.getCenter().lng();\n"
-+              "document.cookie = 'googlemaplat='+map.getCenter().lat();\n"
-+              "var zoom = map.getZoom();\n"
-+              "document.cookie = 'googlemapzoom='+zoom;\n"
-+              "document.layoutform.scaling_factor.value=+zoom;\n"
-+      "}\n"
-+      
-+      "function readCookie(name) {\n"
-+              "var nameEQ = name + \"=\";\n"
-+              "var ca = document.cookie.split(';');\n"
-+              "for(var i=0;i < ca.length;i++)\n"
-+              "{\n"
-+                      "var c = ca[i];\n"
-+                      "while (c.charAt(0)==' ') c = c.substring(1,c.length);\n"
-+                      "if (c.indexOf(nameEQ) == 0)\n"
-+                      "{\n"
-+                              "c=c.substring(nameEQ.length,c.length);\n"
-+                              "while (c.substring(c.length-1, c.length) == ' ')\n"
-+                                      "c = c.substring(0,c.length-1);\n"
-+                              "return c;\n"
-+                      "}\n"
-+              "}\n"
-+              "return null;\n"
-+      "}\n"
-+
-+      "function createMarker(hostname, comment, lat, long, state) {\n"
-+      " var point = new GLatLng(lat,long);\n"
-+      "var marker;\n"
-+      "if ( state==\"Up\" ) {\n"
-+              "var baseIcon = new GIcon();\n"
-+              "baseIcon.shadow = \"../images/shadow.png\";\n"
-+              "baseIcon.iconSize = new GSize(20, 34);\n"
-+              "baseIcon.shadowSize = new GSize(37, 34);\n"
-+              "baseIcon.iconAnchor = new GPoint(9, 34);\n"
-+              "baseIcon.infoWindowAnchor = new GPoint(9, 2);\n"
-+              "baseIcon.infoShadowAnchor = new GPoint(18, 25);\n"
-+              "var okicon = new GIcon(baseIcon);\n"
-+              "okicon.image = \"../images/green.png\";\n"
-+              "marker = new GMarker(point,okicon);\n"
-+      "} else {\n"
-+              "marker = new GMarker(point);\n"
-+      "}\n"
-+              
-+      "GEvent.addListener(marker, \"click\", function() { \n"
-+                                               "marker.openInfoWindowHtml(\"<b>\"+hostname+\"</b><br>\"+comment+\"<br>State: \"+state+\"\");\n"
-+      "});\n"
-+      "return marker;\n"
-+      "}\n"
-+
-+      "function load() {\n"
-+      "if (GBrowserIsCompatible()) {\n"
-+              "var map = new GMap2(document.getElementById(\"map\"));\n"
-+              "map.addControl(new GSmallMapControl());\n"
-+              "map.addControl(new GMapTypeControl());\n"
-+              
-+              "GEvent.addListener(map, \"click\", function () {\n"
-+                      "setMapCookie(map);\n"
-+              "});\n"
 +
-+              "GEvent.addListener(map, \"move\", function () {\n"
-+                      "setMapCookie(map);\n"
-+              "});\n"
-+
-+              "GEvent.addListener(map, \"zoom\", function () {\n"
-+                      "setMapCookie(map);\n"
-+              "});\n"
-+
-+              "var googlemaplat = readCookie('googlemaplat');\n"
-+        "var googlemaplng = readCookie('googlemaplng');\n"
-+
-+              "var centerPoint;\n"
-+              "if(  googlemaplng!=null && googlemaplat!=null ) \n"
-+                      "centerPoint = new GLatLng(googlemaplat,googlemaplng);\n"
-+              "else\n");
-+                      printf("centerPoint = new GLatLng(%s,%s);\n",gen_loc.latitude,gen_loc.longitude);
-+
-+              printf("var zoom = map.getZoom();\n"
-+              "document.layoutform.scaling_factor.value=+zoom;\n");
-+
-+
-+      if (user_supplied_scaling==TRUE)
-+      {
-+              printf("map.setCenter(centerPoint, %2.1f);\n",user_scaling_factor);
-+              printf("document.layoutform.scaling_factor.value=%2.1f;\n",user_scaling_factor);
++      printf("<script type='text/javascript'>\n");
++      printf("gstatusmap = {\n");
++      printf("lat:%s,\n", gen_loc.latitude);
++      printf("lng:%s,\n", gen_loc.longitude);
++      if (user_supplied_scaling==TRUE) {
++              printf("scale: '%2.1f',\n", user_scaling_factor);
 +      } else {
-+              printf("var googlemapzoom = readCookie('googlemapzoom');\n"
-+              "if ( googlemapzoom != null ) \n"
-+              "{\n"
-+                      "map.setCenter(centerPoint,parseInt(googlemapzoom));\n"
-+                      "document.layoutform.scaling_factor.value=googlemapzoom;\n"
-+              "} else\n"
-+              "{\n");
-+              printf("map.setCenter(centerPoint, %s);\n",gen_loc.zoom);
-+                      printf("document.layoutform.scaling_factor.value=%s;\n",gen_loc.zoom);
-+              printf("}\n");
++              printf("scale: '%2.1f',\n", gen_loc.zoom);
 +              user_scaling_factor = atof(gen_loc.zoom);
 +      }
-+                      
++      printf("markers: [\n");
++
 +      loc = loc_list;
 +      while (loc) {
 +              // check if allowed to show hostname first
 +                      free(ptr);
 +
 +      
-+                      printf("map.addOverlay(createMarker('%s','",loc->name);
++                      printf("['%s','",loc->name);
 +                      ptr = loc->note;
 +                      while ((ch = *ptr++)) {
 +                              if (ch == '\'') printf("\\'");
 +                              else printf("%c", ch);
 +                      }
-+                      printf("',%s,%s,'%s'))\n",loc->latitude,loc->longitude,stateinfo);
++                      printf("',%s,%s,'%s'],\n",loc->latitude,loc->longitude,stateinfo);
 +
 +                      loc = loc->next;
 +              }
 +      }
-+                      
-+      printf("}\n"
-+      "}\n"
-+      "//]]>\n"
-+      "</script>\n");
++
++      printf("0], \n");
++      printf("images_url: '%s'\n", url_images_path);
++      printf("};\n");
++      printf("</script>\n");
++
++      printf("<script src='http://maps.google.com/maps?file=api&amp;v=2&key=%s&amp;sensor=false' type='text/javascript'></script>\n",gen_loc.key);
++      printf("<script src='%sgooglemap.js' type='text/javascript'></script>\n", url_images_path);
 +}
  
  /* write JavaScript code an layer for popup window */
index 557a05659fd83d73fabf27bf50b8da4427947921..37c66567375dd907d0d563d3d4eb8c3be5483abe 100644 (file)
@@ -9,7 +9,7 @@ Summary(pl.UTF-8):      Program do monitorowania serwerów/usług/sieci
 Summary(pt_BR.UTF-8):  Programa para monitoração de máquinas e serviços
 Name:          nagios
 Version:       3.2.0
-Release:       6
+Release:       7
 License:       GPL v2
 Group:         Networking
 Source0:       http://dl.sourceforge.net/nagios/%{name}-%{version}.tar.gz
@@ -20,12 +20,18 @@ Source3:    %{name}.sysconfig
 Source4:       %{name}-config-20090914.tar.bz2
 # Source4-md5: 605f1cd28c00db961dad6f529d849f16
 Source5:       %{name}-lighttpd.conf
+Source6:       http://www.google.com/mapfiles/shadow50.png
+# Source6-md5: eff99f302f21b95a900d321743fce72b
+Source7:       http://www.google.com/mapfiles/marker.png
+# Source7-md5: edefef4bdfc29e1c953694651f05b466
+Source8:       googlemap.js
 Patch0:                %{name}-resources.patch
 Patch1:                %{name}-iconv-in-libc.patch
 Patch2:                %{name}-webapps.patch
 Patch3:                %{name}-cgi-http_charset.patch
 Patch4:                %{name}-cmd-typo.patch
 Patch5:                config.patch
+Patch6:                nagios-googlemap.patch
 URL:           http://www.nagios.org/
 BuildRequires: autoconf
 BuildRequires: automake
@@ -177,6 +183,7 @@ aplicativos para o Nagios.
 %patch3 -p1
 %patch4 -p1
 %patch5 -p1
+%patch6 -p1
 
 find -name .cvsignore -o -name .gitignore | xargs rm
 
@@ -257,6 +264,9 @@ cp -a apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/apache.conf
 cp -a apache.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/httpd.conf
 cp -a lighttpd.conf $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/lighttpd.conf
 cp -a sample-config/cgi.cfg $RPM_BUILD_ROOT%{_webapps}/%{_webapp}
+cp -a %{SOURCE6} $RPM_BUILD_ROOT%{_datadir}/images
+cp -a %{SOURCE7} $RPM_BUILD_ROOT%{_datadir}/images
+cp -a %{SOURCE8} $RPM_BUILD_ROOT%{_datadir}/images
 > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/passwd
 echo 'nagios:' > $RPM_BUILD_ROOT%{_webapps}/%{_webapp}/group
 
@@ -422,6 +432,8 @@ done
 %{_datadir}/media
 %{_datadir}/ssi
 %{_datadir}/images/favicon.ico
+%{_datadir}/images/marker.png
+%{_datadir}/images/shadow50.png
 
 %files theme-default
 %defattr(644,root,root,755)
@@ -429,6 +441,8 @@ done
 %{_datadir}/includes/*
 %{_datadir}/images/*
 %exclude %{_datadir}/images/favicon.ico
+%exclude %{_datadir}/images/marker.png
+%exclude %{_datadir}/images/shadow50.png
 %{_datadir}/stylesheets/*
 
 %files devel
This page took 0.159775 seconds and 4 git commands to generate.