svn commit: r656 - trunk/mapbender/http/php

christoph at osgeo.org christoph at osgeo.org
Fri Jul 14 10:38:30 EDT 2006


Author: christoph
Date: 2006-07-14 14:38:30+0000
New Revision: 656

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

Log:
added new statistics plus detail view and enhanced visuals

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=656&p1=trunk/mapbender/http/php/mod_monitorCapabilities_main.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_main.php&r1=655&r2=656
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_main.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_main.php	2006-07-14 14:38:30+0000
@@ -91,20 +91,19 @@
 	
 	$sql = "INSERT INTO mb_monitor (upload_id, fkey_wms_id, status, status_comment, timestamp_begin, timestamp_end, upload_url, updated) ";
 	$sql .= "VALUES ($1, $2, $3, $4, $5, $6, $7, $8)";
-	$v = array($time,$wms_id_own[$k],"-2","Monitoring is still in progress...", $time,$time,$url,"0");
+	$v = array($time,$wms_id_own[$k],"-2","Monitoring is still in progress...", time(),time(),$url,"0");
 	$t = array('s', 'i', 's', 's', 's', 's', 's', 's');
 	$res = db_prep_query($sql,$v,$t);
 }
 
 for ($k=0; $k<count($wms_id_own); $k++) {
-#	$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output_" . $wms_id_own[$k] . "_" . $time . ".txt &";
 
 	if (intval(AUTO_UPDATE)) {
 		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 1 > output.txt &";
 	}
 	else {
-		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output_" . $time . "_" . $wms_id_own[$k] . ".txt &";
-#		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output.txt &";
+#		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output_" . $time . "_" . $wms_id_own[$k] . ".txt &";
+		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output.txt &";
 	}
 	exec($exec);
 }

Modified: trunk/mapbender/http/php/mod_monitorCapabilities_read.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_monitorCapabilities_read.php?view=diff&rev=656&p1=trunk/mapbender/http/php/mod_monitorCapabilities_read.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_read.php&r1=655&r2=656
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_read.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_read.php	2006-07-14 14:38:30+0000
@@ -38,6 +38,7 @@
 </head>
 <body>
 <?php
+$admin = new administration();
 
 // update selected wms
 for ($i=0; $i < $_POST['cbs']; $i++) {
@@ -46,77 +47,167 @@
 		
 		$now = time();
 		$sql = "UPDATE mb_monitor SET status = '-2', status_comment = 'Monitoring is still in progress...', timestamp_begin = $1, timestamp_end = $2 WHERE upload_id = $3 AND fkey_wms_id = $4";
-		$v = array($now, $now, $_POST['max_id'], $upd_wmsid);
+		$v = array($now, $now, $_POST['upl_id'.$i], $upd_wmsid);
 		$t = array('s', 's', 's', 'i');
 		$res = db_prep_query($sql,$v,$t);
 		
-		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$upd_wmsid." ".$_POST['max_id']." 1 > output.txt &";
+		$exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$upd_wmsid." ".$_POST['upl_id'.$i]." 1 > output.txt &";
 		exec($exec);
 	}
 }
 
-$admin = new administration();
-
-// get upload id
-$sql = "SELECT MAX(upload_id) FROM mb_monitor";
-$v = array();
-$t = array();
-$res = db_prep_query($sql,$v,$t);
+$sql = "SELECT DISTINCT fkey_wms_id FROM mb_monitor";
+$res = db_prep_query($sql, array(), array());
+$cnt = 0;
+$wms = array();
 while(db_fetch_row($res)){
-	$max = db_result($res,$cnt,0);
+	$wms[$cnt] = db_result($res,$cnt,"fkey_wms_id");
+	$cnt++;
 }
 
-// get all wms
-$sql = "SELECT upload_id, fkey_wms_id, status, status_comment, timestamp_begin, timestamp_end, upload_url, updated FROM mb_monitor WHERE upload_id = " . $max . " ORDER BY status, status_comment, timestamp_end, fkey_wms_id";
-$v = array();
-$t = array();
-$res = db_prep_query($sql,$v,$t);
-$cnt=0;
-while(db_fetch_row($res)){
-	$upload_id[$cnt] = db_result($res,$cnt,"upload_id");
-	$wms_id[$cnt] = db_result($res,$cnt,"fkey_wms_id");
-	$status[$cnt] = intval(db_result($res,$cnt,"status"));
-	$comment[$cnt] = db_result($res,$cnt,"status_comment");
-	$timestamp_begin[$cnt] = db_result($res,$cnt,"timestamp_begin");
-	$timestamp_end[$cnt] = db_result($res,$cnt,"timestamp_end");
-	$upload_url[$cnt] = db_result($res,$cnt,"upload_url");
-	$updated[$cnt] = db_result($res,$cnt,"updated");
+$status = array();
+$upload_id = array();
+for ($i=0; $i<count($wms); $i++) {
+	$wms_id[$wms[$i]] = $wms[$i];
+	// get upload id
+	$sql = "SELECT MAX(upload_id) FROM mb_monitor WHERE fkey_wms_id = $1";
+	$v = array($wms[$i]);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	$upload_id[$wms[$i]] = db_result($res,0,0);
+
+	$sql = "SELECT AVG(timestamp_begin), AVG(timestamp_end) FROM mb_monitor WHERE fkey_wms_id = $1 AND NOT status = '-1' AND NOT status = '-2'";
+	$v = array($wms[$i]);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	if (db_result($res,0,1) == 0 && db_result($res,0,0) == 0) {
+		$avg_response_time[$wms[$i]] = "n/a";	
+	}
+	else {
+		$avg_response_time[$wms[$i]] = strval(round(db_result($res,0,1)-db_result($res,0,0), 1)) . " s";
+	}
 	
-	if ($comment[$cnt] == "Monitoring is still in progress..." && intval(time())-intval($timestamp_begin[$cnt]) > intval(TIME_LIMIT)) {
-		$comment[$cnt] = "Monitoring process timed out.";	
+	$sql = "SELECT status, status_comment, timestamp_begin, timestamp_end, upload_url, updated FROM mb_monitor ";
+	$sql .= "WHERE upload_id = $1 AND fkey_wms_id = $2 ORDER BY status, status_comment, timestamp_end, fkey_wms_id";
+	$v = array($upload_id[$wms[$i]], $wms_id[$wms[$i]]);
+	$t = array('s', 'i');
+	$res = db_prep_query($sql,$v,$t);
+
+	$status[$wms[$i]] = intval(db_result($res,0,"status"));
+	$comment[$wms[$i]] = db_result($res,0,"status_comment");
+	$timestamp_begin[$wms[$i]] = db_result($res,0,"timestamp_begin");
+	$timestamp_end[$wms[$i]] = db_result($res,0,"timestamp_end");
+	$upload_url[$wms[$i]] = db_result($res,0,"upload_url");
+	$updated[$wms[$i]] = db_result($res,0,"updated");
+	
+ 	if ($comment[$wms[$i]] == "Monitoring is still in progress..." && intval(time())-intval($timestamp_begin[$wms[$i]]) > intval(TIME_LIMIT)) {
+		$comment[$wms[$i]] = "Monitoring process timed out.";	
 		
-		$new_sql = "UPDATE mb_monitor SET status_comment = 'Monitoring process timed out.', timestamp_end = $1 WHERE fkey_wms_id = $2 AND upload_id = $3";
-		$new_v = array((intval($upload_id[$cnt])+intval(TIME_LIMIT)), $wms_id[$cnt], $upload_id[$cnt]);
+		$new_sql = "UPDATE mb_monitor SET status = '-1', status_comment = 'Monitoring process timed out.', timestamp_end = $1 WHERE fkey_wms_id = $2 AND upload_id = $3";
+		$new_v = array((intval($upload_id[$wms[$i]])+intval(TIME_LIMIT)), $wms_id[$wms[$i]], $upload_id[$wms[$i]]);
 		$new_t = array('s', 'i', 's');
 		$new_res = db_prep_query($new_sql,$new_v,$new_t);
 	}
-	$cnt++;
-}	
+
+
+	$sql = "SELECT COUNT(upload_id) FROM mb_monitor WHERE fkey_wms_id = $1 AND NOT status = '-2'";
+	$v = array($wms[$i]);
+	$t = array('i');
+	$res = db_prep_query($sql, $v, $t);
+	$total[$wms[$i]] = db_result($res, 0, 0);
+
+	$sql = "SELECT COUNT(upload_id) FROM mb_monitor WHERE fkey_wms_id = $1 AND status = '-1'";
+	$v = array($wms[$i]);
+	$t = array('i');
+	$res = db_prep_query($sql, $v, $t);
+	$fail = db_result($res, 0, 0);
+	
+	$percentage[$wms[$i]] = 100 - round(100*floatval($fail)/floatval($total[$wms[$i]]), 1);
+}
+
+
+$newArray = $status;
+if ($_GET['sortby']) {
+	if ($_GET['sortby'] == "wms") {
+		$newArray = $wms_id;
+		asort($newArray);
+	}
+	elseif ($_GET['sortby'] == "status") {
+		$newArray = $status;
+		asort($newArray);
+	}
+	elseif ($_GET['sortby'] == "avgresp") {
+		$newArray = $avg_response_time;
+		asort($newArray);
+	}
+	elseif ($_GET['sortby'] == "avail") {
+		$newArray = $percentage;
+		arsort($newArray);
+	}
+	elseif ($_GET['sortby'] == "last") {
+		$newArray = $upload_id;
+		arsort($newArray);
+	}
+}
 
 
 
-$str = "<br><b>last monitoring cycle results</b> (" . date("F j, Y, G:i:s", $upload_id[0]) . ", " . count($upload_id). " wms)<br><br>\n";
-$str .= "<form name = 'form1' method='post' action='".$PHP_SELF."'>\n\t";
+$str = "<span style='font-size:30'>monitoring results</span><hr><br>\n";
+$str .= "<form name = 'form1' method='post' action='".$PHP_SELF."?sortby=".$_GET['sortby']."'>\n\t";
 $str .= "\n\t<input type=submit value='update selected WMS'>\n";
-$str .= "\n\t<input type=button onclick=\"self.location.href='".$PHP_SELF."'\" value='refresh'>\n<br/><br/>\n	";
-$str .= "<table cellpadding=5 border=1>";
-for ($k=0; $k<count($upload_id); $k++) {
+$str .= "\n\t<input type=button onclick=\"self.location.href='".$PHP_SELF."?sortby=".$_GET['sortby']."'\" value='refresh'>\n<br/><br/>\n	";
+$str .= "<table cellpadding=10 cellspacing=0 border=0>";
+$str .= "<tr bgcolor='#dddddd'><th></th><th align='left'><a href='".$PHP_SELF."?sortby=wms'>wms</a></th>";
+$str .= "<th align='left' colspan = 2><a href='".$PHP_SELF."?sortby=status'>current status</a></th>";
+$str .= "<th align='left'><a href='".$PHP_SELF."?sortby=avgresp'>avg. response time</a></th>";
+$str .= "<th align='left'><a href='".$PHP_SELF."?sortby=avail'>overall availability</a></th><th></th></tr>";
+
+$cnt = 0;
+foreach ($newArray as $k => $value) {
 	$img = "stop.bmp";
 	if ($status[$k]==0) $img = "wait.bmp";
 	elseif ($status[$k]==1) $img = "go.bmp";
 
 	if ($updated[$k] == "0" && $status[$k] == 0) $fill = "checked"; else $fill = "disabled";
 
-	$str .= "\n\t\t<tr>";
-	$str .= "\n\t\t\t<td><input name='cb".$k."' value='" . $wms_id[$k] . "' type=checkbox ".$fill." /></td>";
-	$str .= "\n\t\t\t<td><b>" . $wms_id[$k] . "</b><br>" . $admin->getWmsTitleByWmsId($wms_id[$k]) . "</td>";
-	$str .= "\n\t\t\t<td><a href='".$upload_url[$k]."' target=_blank><img border=0 src = '../img/trafficlights/". $img. "'></a></td>";
-	$str .= "\n\t\t\t<td>" . $comment[$k] . "</td>";
-	$str .= "\n\t\t\t<td>" . date("F j, Y, G:i:s", $timestamp_end[$k]) . "</td>";
+	if (fmod($cnt, 2) == 1) {
+		$str .= "\n\t\t<tr bgcolor='#e6e6e6'>";
+	}
+	else {
+		$str .= "\n\t\t<tr bgcolor='#f0f0f0'>";
+	}
+	$str .= "\n\t\t\t<td><input name='cb".$cnt."' value='" . $wms_id[$k] . "' type=checkbox ".$fill." /><input type=hidden name='upl_id".$cnt."' value='".$upload_id[$k]."'></td>";
+	$str .= "\n\t\t\t<td valign='top'><b>" . $wms_id[$k] . "</b><br>" . $admin->getWmsTitleByWmsId($wms_id[$k]) . "</td>";
+	$str .= "\n\t\t\t<td valign='top'><a href='".$upload_url[$k]."' target=_blank><img title='Connect to service' border=0 src = '../img/trafficlights/". $img. "'></a></td>";
+	$str .= "\n\t\t\t<td valign='top'>" . $comment[$k] . "<br><div style='font-size:12'>".date("F j, Y, G:i:s", $upload_id[$k])."</div></td>";
+	$str .= "\n\t\t\t<td valign='top' align = 'left'>" . $avg_response_time[$k] . "</td>";
+	$str .= "\n\t\t\t<td valign='top'><b>" . $percentage[$k] . " %</b>&nbsp;&nbsp;<span style='font-size:12'>(" . $total[$k] . " cycles)</span><br>";
+	$str .= "<table bgcolor='black' border=1 cellspacing=1 cellpadding=0><tr>";
+	$val = $percentage[$k];
+	for ($i=0; $i<10; $i++) {
+		if ($val>=10) {
+			$str .= "<td height=10 width='10' bgcolor='red'></td>";
+			$val-=10;
+		}
+		elseif($val>0){
+			$str .= "<td height=10 width='" . round($val) . "' bgcolor='red'></td>";
+			if (round($val) < 10) {
+				$str .= "<td height=10 width='" . (9-round($val)) . "' bgcolor='white'></td>";
+			}
+			$val=-1;
+		}
+		else {
+			$str .= "<td height=10 width='10' bgcolor='white'></td>";
+		}
+	}
+	$str .= "</tr></table></td>";
+	
 #	$str .= "\n\t\t\t<td><a href='output_".$wms_id[$k]."_".$max.".txt' target=_blank>log</a></td>";
-	$str .= "\n\t\t</tr>";
+	$str .= "\n\t\t<td><input type=button value='details' onclick=\"var newWindow = window.open('../php/mod_monitorCapabilities_read_single.php?wmsid=".$wms_id[$k]."','wms','width=500,height=700,scrollbars');newWindow.href.location='test.php'\"></td></tr>";
+	$cnt++;
 }
-$str .= "\n\t</table>\n\t<br/><input type=hidden name=cbs value='".count($upload_id)."'>\n<input type=hidden name=max_id value='".$max."'></form>";
+$str .= "\n\t</table>\n\t<br/><input type=hidden name=cbs value='".$cnt."'>\n</form>";
 echo $str;
+
 ?>
 </body></html>
\ No newline at end of file

Modified: trunk/mapbender/http/php/mod_monitorCapabilities_write.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_monitorCapabilities_write.php?view=diff&rev=656&p1=trunk/mapbender/http/php/mod_monitorCapabilities_write.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_write.php&r1=655&r2=656
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_write.php	(original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_write.php	2006-07-14 14:38:30+0000
@@ -59,12 +59,14 @@
 
 if ($myURL) {
 
+	$remoteWms = new wms();
+	$remoteWms->createObjFromXML($myURL);
+	$now = time();
+	$remoteXml = $remoteWms->wms_getcapabilities_doc;  
+
 	// compare the capabilities XML documents
 	$localXml = $capabilities_doc;
-	$x = new connector($myURL);
-	$z = new wms();
-	$remoteXml = $z->char_encode($x->file);
-
+	
 	if (!$remoteXml) {
 		$result = -1;
 		$comment = "Connection failed.";
@@ -104,9 +106,9 @@
 else {
 	$result = -1;
 	$comment = "Invalid upload URL.";
+	$now = time();
 }
 
-$now = time();
 echo "wmsid: " . $wmsId . "\nupload_id: " . $upload_id . "\n";
 echo "autoupdate: " . $auto_update . "\n";
 echo "result: " . $result . "\ncomment: " . $comment . "\n";




More information about the Mapbender_commits mailing list