svn commit: r660 - trunk/mapbender/http/php/mod_monitorCapabilities_main.php

christoph at osgeo.org christoph at osgeo.org
Tue Jul 18 06:53:52 EDT 2006


Author: christoph
Date: 2006-07-18 10:53:52+0000
New Revision: 660

Modified:
   trunk/mapbender/http/php/mod_monitorCapabilities_main.php

Log:
added email notification for root user

Modified: trunk/mapbender/http/php/mod_monitorCapabilities_main.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_monitorCapabilities_main.php?view=diff&rev=660&p1=trunk/mapbender/http/php/mod_monitorCapabilities_main.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_main.php&r1=659&r2=660
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_main.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_main.php	2006-07-18 10:53:52+0000
@@ -39,6 +39,8 @@
 //... und in diesen Array die GUI IDs eintragen, z.B.:
 //
 #$ownguis = array("gui", "gui1");
+// ACHTUNG: Mailbenachrichtigung muß ggf. angepaßt werden, s.u.!
+
 
 //
 //
@@ -49,14 +51,14 @@
 //
 // dann wäre folgende Zeile einzukommentieren
 #$ownguis = array($_SERVER["argv"][1]);
-
+// ACHTUNG: Mailbenachrichtigung muß ggf. angepaßt werden, s.u.!
 
 
 $wms_id_own = $admin->getWmsByOwnGuis($ownguis);
 
-echo "Starting monitoring cycle...<br><br>";
-echo "WMS services are requested for availabiltiy. "; 
-echo "Capabilities documents are requested and all changes synchronized with the database cache.<br><br>";
+echo "Starting monitoring cycle...\n<br/>\n<br/>";
+echo "WMS services are requested for availabiltiy.\n<br/> "; 
+echo "Capabilities documents are requested and all changes synchronized with the database cache.\n<br>\n<br>";
 
 $time = strval(time()-2);
 
@@ -107,5 +109,42 @@
 	}
 	exec($exec);
 }
-echo "Monitoring Cycle completed (total: " . count($wms_id_own) . " wms).";
+echo "Monitoring Cycle completed (total: " . count($wms_id_own) . " wms).\n\n";
+set_time_limit(2*TIME_LIMIT);
+sleep(TIME_LIMIT);
+
+$sql = "SELECT fkey_wms_id, status, status_comment, upload_url FROM mb_monitor WHERE upload_id = $1";
+$v = array($time);
+$t = array('i');
+$res = db_prep_query($sql,$v,$t);
+
+$cnt=0;
+while ($row = db_fetch_array($res)) {
+	$status[$cnt] = intval(db_result($res,$cnt,"status"));
+	$wms_id[$cnt] = db_result($res,$cnt,"fkey_wms_id");
+	$comment[$cnt] = db_result($res,$cnt,"status_comment");
+	$upload_url[$cnt] = db_result($res,$cnt,"upload_url");
+	$cnt++;
+}
+$body = "";
+for ($i=0; $i<$cnt; $i++) {
+	if ($status[$i] == -1) {
+		$body .= $admin->getWmsTitleByWmsId($wms_id[$i]) . " (" . $wms_id[$i] . "): " . $comment[$i] . "\n\n";
+	}
+}
+if ($body) {
+	$error_msg = "";
+	if ($admin->getEmailByUserId(1)) {
+		$admin->sendEmail(MAILADMIN, MAILADMINNAME, $admin->getEmailByUserId(1), $admin->getUserNameByUserId(1), "WMS monitor report " . date("F j, Y, G:i:s", $time), utf8_decode($body), &$error_msg);
+	}
+	else {
+		$error_msg = "Email address of user '" . $admin->getUserNameByUserId(1) . "' unknown!\n";
+	}
+	if ($error_msg) {
+		echo "\n ERROR: " . $error_msg;
+	}
+}
+
+
+
 ?>




More information about the Mapbender_commits mailing list