svn commit: r649 - trunk/mapbender/http/php
christoph at osgeo.org
christoph at osgeo.org
Wed Jul 12 11:00:36 EDT 2006
Author: christoph
Date: 2006-07-12 15:00:35+0000
New Revision: 649
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:
improved manual update functionality, and some minor tidbits.
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=649&p1=trunk/mapbender/http/php/mod_monitorCapabilities_main.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_main.php&r1=648&r2=649
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_main.php (original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_main.php 2006-07-12 15:00:35+0000
@@ -57,23 +57,54 @@
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>";
-$time = time();
+
+$time = strval(time()-2);
+
for ($k=0; $k<count($wms_id_own); $k++) {
- $sql = "INSERT INTO mb_monitor (upload_id, fkey_wms_id, status, status_comment, mb_timestamp, upload_url, updated) ";
- $sql .= "VALUES ($1, $2, $3, $4, $5, $6, $7)";
- $v = array($time,$wms_id_own[$k],"-1","Monitoring is still in progress...", $time,"","0");
- $t = array('s', 'i', 's', 's', 's', 's', 's');
+ //get upload url
+ $sql = "SELECT wms_upload_url FROM wms WHERE wms_id = $1";
+ $v = array($wms_id_own[$k]);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ $someArray = db_fetch_row($res);
+ $url = $someArray[0];
+
+ if (!$upload_url || $upload_url == "") {
+ // get the wms version, capabilities, capabilities_doc
+ $sql = "SELECT wms_version, wms_getcapabilities FROM wms WHERE wms_id = $1";
+ $v = array($wms_id_own[$k]);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ $someArray = db_fetch_row($res);
+
+ $version = $someArray[0];
+ $capabilities = $someArray[1];
+
+ // construct capabilities URL
+ if ($version == "1.0.0" ) {
+ $url = $capabilities . "REQUEST=capabilities&WMTVER=1.0.0";
+ }
+ else {
+ $url = $capabilities . "REQUEST=GetCapabilities&SERVICE=wms&VERSION=" . $version;
+ }
+ }
+
+ $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");
+ $t = array('s', 'i', 's', 's', 's', 's', 's', 's');
$res = db_prep_query($sql,$v,$t);
}
-sleep(2);
+
for ($k=0; $k<count($wms_id_own); $k++) {
-# $exec = "/usr/local/bin/php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output_" . $wms_id_own[$k] . "_" . $time . ".txt &";
+# $exec = PHP_PATH . "php mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > output_" . $wms_id_own[$k] . "_" . $time . ".txt &";
- if (AUTO_UPDATE) {
+ 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.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=649&p1=trunk/mapbender/http/php/mod_monitorCapabilities_read.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_read.php&r1=648&r2=649
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_read.php (original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_read.php 2006-07-12 15:00:35+0000
@@ -39,13 +39,15 @@
<body>
<?php
+// update selected wms
for ($i=0; $i < $_POST['cbs']; $i++) {
$upd_wmsid = intval($_POST['cb'.$i]);
if ($upd_wmsid) {
- $sql = "UPDATE mb_monitor SET status = '-1', status_comment = 'Monitoring is still in progress...', mb_timestamp = $1 WHERE upload_id = $2 AND fkey_wms_id = $3";
- $v = array($_POST['max_id'], $_POST['max_id'], $upd_wmsid);
- $t = array('s', 's', 'i');
+ $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);
+ $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 &";
@@ -55,6 +57,7 @@
$admin = new administration();
+// get upload id
$sql = "SELECT MAX(upload_id) FROM mb_monitor";
$v = array();
$t = array();
@@ -63,7 +66,8 @@
$max = db_result($res,$cnt,0);
}
-$sql = "SELECT upload_id, fkey_wms_id, status, status_comment, mb_timestamp, upload_url, updated FROM mb_monitor WHERE upload_id = " . $max . " ORDER BY mb_timestamp, fkey_wms_id";
+// 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);
@@ -73,12 +77,24 @@
$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[$cnt] = db_result($res,$cnt,"mb_timestamp");
+ $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");
+
+ if ($comment[$cnt] == "Monitoring is still in progress..." && intval(time())-intval($timestamp_begin[$cnt]) > intval(TIME_LIMIT)) {
+ $comment[$cnt] = "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_t = array('s', 'i', 's');
+ $new_res = db_prep_query($new_sql,$new_v,$new_t);
+ }
$cnt++;
}
+
+
$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 .= "\n\t<input type=submit value='update selected WMS'>\n";
@@ -96,7 +112,7 @@
$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[$k]) . "</td>";
+ $str .= "\n\t\t\t<td>" . date("F j, Y, G:i:s", $timestamp_end[$k]) . "</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>";
}
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=649&p1=trunk/mapbender/http/php/mod_monitorCapabilities_write.php&p2=trunk/mapbender/http/php/mod_monitorCapabilities_write.php&r1=648&r2=649
==============================================================================
--- trunk/mapbender/http/php/mod_monitorCapabilities_write.php (original)
+++ trunk/mapbender/http/php/mod_monitorCapabilities_write.php 2006-07-12 15:00:35+0000
@@ -35,88 +35,75 @@
$upload_id = $_SERVER["argv"][2];
$auto_update = intval($_SERVER["argv"][3]);
+// get the uploadURL
+$sql = "SELECT upload_url FROM mb_monitor WHERE fkey_wms_id = $1 AND upload_id = $2";
+$v = array($wmsId, $upload_id);
+$t = array('i', 's');
+$res = db_prep_query($sql,$v,$t);
+$someArray = db_fetch_row($res);
+$myURL = $someArray[0];
-// get the wms version, capabilities, capabilities_doc
-$sql = "SELECT wms_title, wms_version, wms_getcapabilities, wms_getcapabilities_doc ";
-$sql .= "FROM wms WHERE wms_id = $1";
+// get the capabilities doc
+$sql = "SELECT wms_getcapabilities_doc FROM wms WHERE wms_id = $1";
$v = array($wmsId);
$t = array('i');
$res = db_prep_query($sql,$v,$t);
$someArray = db_fetch_row($res);
-
-$wms_title = $someArray[0];
-$version = $someArray[1];
-$capabilities = $someArray[2];
-$capabilities_doc = $someArray[3];
-
-// construct capabilities URL
-if ($version == "1.0.0" ) {
- $myURL = $capabilities . "REQUEST=capabilities&WMTVER=1.0.0";
-}
-else {
- $myURL = $capabilities . "REQUEST=GetCapabilities&SERVICE=wms&VERSION=" . $version;
-}
+$capabilities_doc = $someArray[0];
$comment = "";
$updated = "0";
$result = -1;
-set_time_limit(30);
+set_time_limit(TIME_LIMIT);
+if ($myURL) {
-if ($version == "1.1.1" || $version == "1.1.0" ||$version == "1.0.0") {
- if ($myURL) {
+ // compare the capabilities XML documents
+ $localXml = $capabilities_doc;
+ $x = new connector($myURL);
+ $z = new wms();
+ $remoteXml = $z->char_encode($x->file);
- // 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.";
+ if (!$remoteXml) {
+ $result = -1;
+ $comment = "Connection failed.";
+ }
+ elseif (!$localXml) {
+ $result = 0;
+ }
+ else {
+
+ if ($localXml == $remoteXml) {
+ $result = 1;
+ $comment = "WMS is stable.";
}
- elseif (!$localXml) {
+ else {
$result = 0;
}
- else {
-
- if ($localXml == $remoteXml) {
- $result = 1;
- $comment = "WMS is stable.";
+ }
+ if ($result == 0) {
+ $mywms = new wms();
+
+ if ($mywms->createObjFromXML($myURL)) {
+ if ($auto_update) {
+ $mywms->updateObjInDB($wmsId);
+ $updated = "1";
+ $comment = "WMS has been updated.";
}
else {
- $result = 0;
+ $comment = "WMS is not up to date.";
}
}
- if ($result == 0) {
- $mywms = new wms();
-
- if ($mywms->createObjFromXML($myURL)) {
- if ($auto_update) {
- $mywms->updateObjInDB($wmsId);
- $updated = "1";
- $comment = "WMS has been updated.";
- }
- else {
- $comment = "WMS is not up to date.";
- }
- }
- else {
- $result = -1;
- $comment = "Invalid getCapabilities request or service exception.";
- }
- }
- }
- else {
- $result = -1;
- $comment = "Invalid upload URL.";
+ else {
+ $result = -1;
+ $comment = "Invalid getCapabilities request/document or service exception.";
+ }
}
}
else {
$result = -1;
- $comment = "Invalid WMS version (" .$version . ").";
+ $comment = "Invalid upload URL.";
}
$now = time();
@@ -132,7 +119,7 @@
echo "-------------------------------------------------------------------\n";
-$sql = "UPDATE mb_monitor SET updated = $1, status = $2, status_comment = $3, upload_url = $4, mb_timestamp = $5 WHERE upload_id = $6 AND fkey_wms_id = $7";
+$sql = "UPDATE mb_monitor SET updated = $1, status = $2, status_comment = $3, upload_url = $4, timestamp_end = $5 WHERE upload_id = $6 AND fkey_wms_id = $7";
$v = array($updated, $result, $comment, $myURL, $now, $upload_id, $wmsId);
$t = array('s', 's', 's', 's', 's', 's', 'i');
$res = db_prep_query($sql,$v,$t);
More information about the Mapbender_commits
mailing list