[Mapbender-commits] r2116 - in branches/2.5/http: php tools
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Feb 20 06:00:58 EST 2008
Author: christoph
Date: 2008-02-20 06:00:58 -0500 (Wed, 20 Feb 2008)
New Revision: 2116
Added:
branches/2.5/http/tools/mod_monitorCapabilities_main.php
branches/2.5/http/tools/mod_monitorCapabilities_read.php
branches/2.5/http/tools/mod_monitorCapabilities_read_single.php
branches/2.5/http/tools/mod_monitorCapabilities_write.php
Removed:
branches/2.5/http/php/mod_monitorCapabilities_main.php
branches/2.5/http/php/mod_monitorCapabilities_read.php
branches/2.5/http/php/mod_monitorCapabilities_read_single.php
branches/2.5/http/php/mod_monitorCapabilities_write.php
Log:
monitoring moved from php to tools
Deleted: branches/2.5/http/php/mod_monitorCapabilities_main.php
===================================================================
--- branches/2.5/http/php/mod_monitorCapabilities_main.php 2008-02-20 10:40:53 UTC (rev 2115)
+++ branches/2.5/http/php/mod_monitorCapabilities_main.php 2008-02-20 11:00:58 UTC (rev 2116)
@@ -1,213 +0,0 @@
-<?php
-# $Id: mod_monitorCapabilities_main.php 1240 2007-10-24 09:27:00Z baudson $
-# http://www.mapbender.org/index.php/Monitor_Capabilities
-# Copyright (C) 2002 CCGIS
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-//session_start();
-//import_request_variables("PG");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
-$admin = new administration();
-
-//$user = "root";
-$user = "";
-$gui = "";
-$cl = 0;
-
-
-function getConjunctionCharacter($onlineresource){
- if(strstr($onlineresource, "?")) {
- $lastChar = substr($onlineresource,strlen($onlineresource)-1, 1);
- if ($lastChar == "?" || $lastChar == "&") {return "";}
- else{return "&";}
- }
- else {return "?";}
-}
-
-// retrieve username and gui_id
-if ($_REQUEST['user']) {
- $cl = 0;
- //browser
- echo "browser";
- $user = $_REQUEST['user'];
- $gui = $_REQUEST['gui'];
-}
-elseif ($_SERVER["argv"][1]) {
- $cl = 1;
- //command line
- $p1 = $_SERVER["argv"][1];
- $p2 = $_SERVER["argv"][2];
- if (substr($p1, 0,5) == "user:") {
- $user = substr($p1, 5);
- if (substr($p2, 0,4) == "gui:") {
- $gui = substr($p2, 4);
- }
- }
-}
-else {
- echo "Please specify a username!\n";die();
-}
-
-$userid = $admin->getUserIdByUserName($user);
-
-/*
- * if the current user is a valid user...
- */
-if ($userid) {
- $ownguis = $admin->getGuisByOwner($userid,true);
- /*
- * if monitoring is restricted to a single GUI...
- */
- if ($gui) {
- // ... abort if the GUI doesn't exist
- if (!$admin->guiExists($gui)) {
- echo "GUI " . $gui . " doesn't exist.\n"; die();
- }
- // ... add the GUI to the array of GUIs that will be monitored
- elseif (in_array($gui, $ownguis)) {
- $ownguis = array($gui);
- }
- // ... abort if the GUI is not owned by the current user
- else {
- echo "User " . $user . " is not owner of GUI " . $gui . ".\n"; die();
- }
- }
-}
-/*
- * if current user is not a valid user, abort
- */
-else {
- echo $user . " is not a valid username.\n"; die();
-}
-
-/**
- * Array of WMS IDs. These are the WMS that the user owns.
- */
-$wms_id_own = $admin->getWmsByOwnGuis($ownguis);
-
-// initialise monitoring processes
-echo "Starting monitoring cycle...\n\n";
-if ($cl == 0) echo "<br/><br/>";
-echo "WMS services are requested for availability.\n";
-if ($cl == 0) echo "<br/>";
-echo "Capabilities documents are requested and all changes synchronized with the database cache.\n\n";
-if ($cl == 0) echo "<br/><br/>";
-
-$time = strval(time()-2);
-
-for ($k=0; $k<count($wms_id_own); $k++) {
- $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 == "") {
- $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];
- if ($version == "1.0.0" ) {
- $url = $capabilities . getConjunctionCharacter($capabilities) . "REQUEST=capabilities&WMTVER=1.0.0";
- }
- else {
- $url = $capabilities . getConjunctionCharacter($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);
-}
-
-for ($k=0; $k<count($wms_id_own); $k++) {
-
- if (intval(AUTO_UPDATE)) {
- $exec = PHP_PATH . "php5 mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 1 > ../tmp/output_".$time."_".$wms_id_own[$k].".txt &";
- }
- else {
- $exec = PHP_PATH . "php5 mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > ../tmp/output_".$time."_".$wms_id_own[$k].".txt &";
- }
- exec($exec);
-}
-echo "Monitoring Cycle completed (total: " . count($wms_id_own) . " wms).\n\n";
-if ($cl == 0) echo "<br/><br/>";
-set_time_limit(2*TIME_LIMIT);
-
-// wait until all monitoring processes are finished
-echo "please wait " . TIME_LIMIT . " seconds for the monitoring to finish...\n\n";
-if ($cl == 0) echo "<br/><br/>";
-sleep(TIME_LIMIT);
-
-$sql = "SELECT fkey_wms_id, status, status_comment, timestamp_begin, timestamp_end, 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");
- $timestamp_begin[$cnt] = db_result($res,0,"timestamp_begin");
- $timestamp_end[$cnt] = db_result($res,0,"timestamp_end");
- $cnt++;
-}
-
-$body = "";
-for ($i=0; $i<$cnt; $i++) {
- // if monitoring is still in progress and time limit has expired, update database
- if ($status[$i] == -2 && intval(time())-intval($timestamp_begin[$i]) > intval(TIME_LIMIT)) {
- $comment[$i] = "Monitoring process timed out.";
- $status[$i] = -1;
- $new_sql = "UPDATE mb_monitor SET status = '-1', isImage = '-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[$i])+intval(TIME_LIMIT)), $wms_id[$i], $time);
- $new_t = array('s', 'i', 's');
- $new_res = db_prep_query($new_sql,$new_v,$new_t);
- }
- // compose mail message
- echo $wms_id[$i] . ": status " . $status[$i] . "\n";
- if ($cl == 0) echo "<br/><br/>";
- if ($status[$i] == -1) {
- $body .= $admin->getWmsTitleByWmsId($wms_id[$i]) . " (" . $wms_id[$i] . "): " . $comment[$i] . "\n\n";
- }
-}
-
-// Send an email to the user
-if ($body) {
- $error_msg = "";
- if ($admin->getEmailByUserId($userid)) {
-// $admin->sendEmail(MAILADMIN, MAILADMINNAME, $admin->getEmailByUserId($userid), $user, "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($userid) . "' unknown!\n";
- }
- if ($error_msg) {
- echo "\n ERROR: " . $error_msg;
- }
-}
-?>
Deleted: branches/2.5/http/php/mod_monitorCapabilities_read.php
===================================================================
--- branches/2.5/http/php/mod_monitorCapabilities_read.php 2008-02-20 10:40:53 UTC (rev 2115)
+++ branches/2.5/http/php/mod_monitorCapabilities_read.php 2008-02-20 11:00:58 UTC (rev 2116)
@@ -1,247 +0,0 @@
-
-<?php
-# $Id: mod_monitorCapabilities_read.php 1283 2007-10-25 15:20:25Z baudson $
-# http://www.mapbender.org/index.php/Monitor_Capabilities
-# Copyright (C) 2002 CCGIS
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-session_start();
-import_request_variables("PG");
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-<head>
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
-?>
-</head>
-<body>
-<?php
-$admin = new administration();
-
-// update selected wms
-for ($i=0; $i < $_POST['cbs']; $i++) {
- $upd_wmsid = intval($_POST['cb'.$i]);
- if ($upd_wmsid) {
-
- $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['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['upl_id'.$i]." 1 > output.txt &";
- exec($exec);
- }
-}
-
-$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)){
- $wms[$cnt] = db_result($res,$cnt,"fkey_wms_id");
- $cnt++;
-}
-
-$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]] = NULL;
- }
- else {
- $avg_response_time[$wms[$i]] = round(db_result($res,0,1)-db_result($res,0,0), 1);
- }
-
- $sql = "SELECT status, status_comment, timestamp_begin, timestamp_end, upload_url, updated, image, map_url 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");
- $mapurl[$wms[$i]] = db_result($res,0,"map_url");
- $image[$wms[$i]] = db_result($res,0,"image");
-
- if ($status[$wms[$i]] == -2 && intval(time())-intval($timestamp_begin[$wms[$i]]) > intval(TIME_LIMIT)) {
- $comment[$wms[$i]] = "Monitoring process timed out.";
-
- $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);
- }
-
- $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);
- }
- elseif ($_GET['image'] == "last") {
- $newArray = $image;
- arsort($newArray);
- }
-}
-
-
-
-$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."?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=image'>image</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";
-
- 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'>";
-
- $str .= "<table bgcolor='black' border=1 cellspacing=1 cellpadding=0><tr><td height=20 width=20 align=center valign=middle bgcolor='";
-
- if ($image[$k] == -1) {
- $str .= "red";
- }
- elseif ($image[$k] == 0) {
- $str .= "yellow";
- }
- elseif ($image[$k] == 1) {
- $str .= "green";
- }
-
- if ($image[$k] != -1) {
- $str .= "'><a href='".$mapurl[$k]."'>o</a></td></tr></table></td>";
- }
- else {
- $str .= "'><a href='".$mapurl[$k]."'>x</a></td></tr></table></td>";
- }
-
- $str .= "\n\t\t\t<td valign='top' align = 'left'>";
- if ($avg_response_time[$k] == NULL) {
- $str .= "n/a";
- }
- else {
- $str .= $avg_response_time[$k] . " s";
- }
- $str .= "</td>";
- $str .= "\n\t\t\t<td valign='top'><b>" . $percentage[$k] . " %</b> <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<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='".$cnt."'>\n</form>";
-echo $str;
-
-?>
-</body></html>
\ No newline at end of file
Deleted: branches/2.5/http/php/mod_monitorCapabilities_read_single.php
===================================================================
--- branches/2.5/http/php/mod_monitorCapabilities_read_single.php 2008-02-20 10:40:53 UTC (rev 2115)
+++ branches/2.5/http/php/mod_monitorCapabilities_read_single.php 2008-02-20 11:00:58 UTC (rev 2116)
@@ -1,102 +0,0 @@
-
-<?php
-# $Id: mod_monitorCapabilities_read_single.php 76 2006-08-15 12:25:34Z heuser $
-# http://www.mapbender.org/index.php/Monitor_Capabilities
-# Copyright (C) 2002 CCGIS
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/../classes/class_administration.php");
-session_start();
-import_request_variables("PG");
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-<head>
-<meta http-equiv="cache-control" content="no-cache">
-<meta http-equiv="pragma" content="no-cache">
-<meta http-equiv="expires" content="0">
-<?php
-echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
-?>
-</head>
-<body>
-<?php
-$admin = new administration();
-
-if ($_GET['wmsid']) {
- $wms_id = intval($_GET['wmsid']);
-}
-else {
- echo "Invalid WMS ID.";
- die;
-}
-
-$sql = "SELECT upload_id, status, status_comment, timestamp_begin, timestamp_end, upload_url, updated FROM mb_monitor ";
-$sql .= "WHERE fkey_wms_id = $1 AND NOT status = '-2' ORDER BY upload_id DESC";
-$v = array($wms_id);
-$t = array('i');
-$res = db_prep_query($sql,$v,$t);
-
-$cnt=0;
-while ($row = db_fetch_array($res)) {
- $upload_id[$cnt] = db_result($res,$cnt,"upload_id");
- $status[$cnt] = intval(db_result($res,$cnt,"status"));
- $comment[$cnt] = db_result($res,$cnt,"status_comment");
- $timestamp_begin = db_result($res,$cnt,"timestamp_begin");
- $timestamp_end = db_result($res,$cnt,"timestamp_end");
- $upload_url[$cnt] = db_result($res,$cnt,"upload_url");
- if ($status[$cnt] == '0' || $status[$cnt] == '1') {
- $response_time[$cnt] = strval($timestamp_end-$timestamp_begin) . " s";
- }
- else {
- $response_time[$cnt] = "n/a";
- }
- $cnt++;
-}
-
-
-$str = "<span style='font-size:30'>monitoring results</span><hr><br>\n";
-$str .= "<b>" . $wms_id . "</b><br>" . $admin->getWmsTitleByWmsId($wms_id) . "<br><br><br>\n";
-$str .= "<table cellpadding=10 cellspacing=0 border=0>";
-$str .= "<tr bgcolor='#dddddd'><th align='left'>date</th><th align='left' colspan = 2>status</th><th align='center'>response time</th></tr>";
-
-for ($k=0; $k<count($upload_id); $k++) {
- $img = "stop.bmp";
- if ($status[$k]==0) $img = "wait.bmp";
- elseif ($status[$k]==1) $img = "go.bmp";
-
- if (fmod($k, 2) == 1) {
- $str .= "\n\t\t<tr bgcolor='#e6e6e6'>";
- }
- else {
- $str .= "\n\t\t<tr bgcolor='#f0f0f0'>";
- }
- $str .= "\n\t\t\t<td>".date("F j, Y, G:i:s", $upload_id[$k])."</td>";
- $str .= "\n\t\t\t<td><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>" . $comment[$k] . "</td>";
- $str .= "\n\t\t\t<td align='center'>" . $response_time[$k] . "</td>";
-
-# $str .= "\n\t\t\t<td><a href='output_".$wms_id[$k]."_".$max.".txt' target=_blank>log</a></td>";
-}
-$str .= "\n\t</table>\n\t";
-echo $str;
-
-?>
-</body></html>
\ No newline at end of file
Deleted: branches/2.5/http/php/mod_monitorCapabilities_write.php
===================================================================
--- branches/2.5/http/php/mod_monitorCapabilities_write.php 2008-02-20 10:40:53 UTC (rev 2115)
+++ branches/2.5/http/php/mod_monitorCapabilities_write.php 2008-02-20 11:00:58 UTC (rev 2116)
@@ -1,41 +0,0 @@
-<?php
-# $Id: mod_monitorCapabilities_write.php 1235 2007-10-23 15:42:55Z baudson $
-# http://www.mapbender.org/index.php/Monitor_Capabilities
-# Copyright (C) 2002 CCGIS
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-session_start();
-
-require_once(dirname(__FILE__)."/../classes/class_monitor.php");
-
-/*
- * incoming parameters from command line
- */
-if ($_SERVER["argc"] != 4) {
- echo "Insufficient arguments! Monitoring aborted.";
- die();
-}
-
-$wmsId = $_SERVER["argv"][1];
-$uploadId = $_SERVER["argv"][2];
-$autoUpdate = intval($_SERVER["argv"][3]);
-
-$monitor = new Monitor($wmsId, $uploadId, $autoUpdate);
-
-echo $monitor;
-
-$monitor->updateInDB();
-?>
\ No newline at end of file
Copied: branches/2.5/http/tools/mod_monitorCapabilities_main.php (from rev 2111, branches/2.5/http/php/mod_monitorCapabilities_main.php)
===================================================================
--- branches/2.5/http/tools/mod_monitorCapabilities_main.php (rev 0)
+++ branches/2.5/http/tools/mod_monitorCapabilities_main.php 2008-02-20 11:00:58 UTC (rev 2116)
@@ -0,0 +1,213 @@
+<?php
+# $Id: mod_monitorCapabilities_main.php 1240 2007-10-24 09:27:00Z baudson $
+# http://www.mapbender.org/index.php/Monitor_Capabilities
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+//session_start();
+//import_request_variables("PG");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+$admin = new administration();
+
+//$user = "root";
+$user = "";
+$gui = "";
+$cl = 0;
+
+
+function getConjunctionCharacter($onlineresource){
+ if(strstr($onlineresource, "?")) {
+ $lastChar = substr($onlineresource,strlen($onlineresource)-1, 1);
+ if ($lastChar == "?" || $lastChar == "&") {return "";}
+ else{return "&";}
+ }
+ else {return "?";}
+}
+
+// retrieve username and gui_id
+if ($_REQUEST['user']) {
+ $cl = 0;
+ //browser
+ echo "browser";
+ $user = $_REQUEST['user'];
+ $gui = $_REQUEST['gui'];
+}
+elseif ($_SERVER["argv"][1]) {
+ $cl = 1;
+ //command line
+ $p1 = $_SERVER["argv"][1];
+ $p2 = $_SERVER["argv"][2];
+ if (substr($p1, 0,5) == "user:") {
+ $user = substr($p1, 5);
+ if (substr($p2, 0,4) == "gui:") {
+ $gui = substr($p2, 4);
+ }
+ }
+}
+else {
+ echo "Please specify a username!\n";die();
+}
+
+$userid = $admin->getUserIdByUserName($user);
+
+/*
+ * if the current user is a valid user...
+ */
+if ($userid) {
+ $ownguis = $admin->getGuisByOwner($userid,true);
+ /*
+ * if monitoring is restricted to a single GUI...
+ */
+ if ($gui) {
+ // ... abort if the GUI doesn't exist
+ if (!$admin->guiExists($gui)) {
+ echo "GUI " . $gui . " doesn't exist.\n"; die();
+ }
+ // ... add the GUI to the array of GUIs that will be monitored
+ elseif (in_array($gui, $ownguis)) {
+ $ownguis = array($gui);
+ }
+ // ... abort if the GUI is not owned by the current user
+ else {
+ echo "User " . $user . " is not owner of GUI " . $gui . ".\n"; die();
+ }
+ }
+}
+/*
+ * if current user is not a valid user, abort
+ */
+else {
+ echo $user . " is not a valid username.\n"; die();
+}
+
+/**
+ * Array of WMS IDs. These are the WMS that the user owns.
+ */
+$wms_id_own = $admin->getWmsByOwnGuis($ownguis);
+
+// initialise monitoring processes
+echo "Starting monitoring cycle...\n\n";
+if ($cl == 0) echo "<br/><br/>";
+echo "WMS services are requested for availability.\n";
+if ($cl == 0) echo "<br/>";
+echo "Capabilities documents are requested and all changes synchronized with the database cache.\n\n";
+if ($cl == 0) echo "<br/><br/>";
+
+$time = strval(time()-2);
+
+for ($k=0; $k<count($wms_id_own); $k++) {
+ $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 == "") {
+ $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];
+ if ($version == "1.0.0" ) {
+ $url = $capabilities . getConjunctionCharacter($capabilities) . "REQUEST=capabilities&WMTVER=1.0.0";
+ }
+ else {
+ $url = $capabilities . getConjunctionCharacter($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);
+}
+
+for ($k=0; $k<count($wms_id_own); $k++) {
+
+ if (intval(AUTO_UPDATE)) {
+ $exec = PHP_PATH . "php5 mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 1 > ../tmp/output_".$time."_".$wms_id_own[$k].".txt &";
+ }
+ else {
+ $exec = PHP_PATH . "php5 mod_monitorCapabilities_write.php ".$wms_id_own[$k]." ".$time." 0 > ../tmp/output_".$time."_".$wms_id_own[$k].".txt &";
+ }
+ exec($exec);
+}
+echo "Monitoring Cycle completed (total: " . count($wms_id_own) . " wms).\n\n";
+if ($cl == 0) echo "<br/><br/>";
+set_time_limit(2*TIME_LIMIT);
+
+// wait until all monitoring processes are finished
+echo "please wait " . TIME_LIMIT . " seconds for the monitoring to finish...\n\n";
+if ($cl == 0) echo "<br/><br/>";
+sleep(TIME_LIMIT);
+
+$sql = "SELECT fkey_wms_id, status, status_comment, timestamp_begin, timestamp_end, 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");
+ $timestamp_begin[$cnt] = db_result($res,0,"timestamp_begin");
+ $timestamp_end[$cnt] = db_result($res,0,"timestamp_end");
+ $cnt++;
+}
+
+$body = "";
+for ($i=0; $i<$cnt; $i++) {
+ // if monitoring is still in progress and time limit has expired, update database
+ if ($status[$i] == -2 && intval(time())-intval($timestamp_begin[$i]) > intval(TIME_LIMIT)) {
+ $comment[$i] = "Monitoring process timed out.";
+ $status[$i] = -1;
+ $new_sql = "UPDATE mb_monitor SET status = '-1', isImage = '-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[$i])+intval(TIME_LIMIT)), $wms_id[$i], $time);
+ $new_t = array('s', 'i', 's');
+ $new_res = db_prep_query($new_sql,$new_v,$new_t);
+ }
+ // compose mail message
+ echo $wms_id[$i] . ": status " . $status[$i] . "\n";
+ if ($cl == 0) echo "<br/><br/>";
+ if ($status[$i] == -1) {
+ $body .= $admin->getWmsTitleByWmsId($wms_id[$i]) . " (" . $wms_id[$i] . "): " . $comment[$i] . "\n\n";
+ }
+}
+
+// Send an email to the user
+if ($body) {
+ $error_msg = "";
+ if ($admin->getEmailByUserId($userid)) {
+// $admin->sendEmail(MAILADMIN, MAILADMINNAME, $admin->getEmailByUserId($userid), $user, "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($userid) . "' unknown!\n";
+ }
+ if ($error_msg) {
+ echo "\n ERROR: " . $error_msg;
+ }
+}
+?>
Copied: branches/2.5/http/tools/mod_monitorCapabilities_read.php (from rev 2111, branches/2.5/http/php/mod_monitorCapabilities_read.php)
===================================================================
--- branches/2.5/http/tools/mod_monitorCapabilities_read.php (rev 0)
+++ branches/2.5/http/tools/mod_monitorCapabilities_read.php 2008-02-20 11:00:58 UTC (rev 2116)
@@ -0,0 +1,247 @@
+
+<?php
+# $Id: mod_monitorCapabilities_read.php 1283 2007-10-25 15:20:25Z baudson $
+# http://www.mapbender.org/index.php/Monitor_Capabilities
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+session_start();
+import_request_variables("PG");
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="0">
+<?php
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
+?>
+</head>
+<body>
+<?php
+$admin = new administration();
+
+// update selected wms
+for ($i=0; $i < $_POST['cbs']; $i++) {
+ $upd_wmsid = intval($_POST['cb'.$i]);
+ if ($upd_wmsid) {
+
+ $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['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['upl_id'.$i]." 1 > output.txt &";
+ exec($exec);
+ }
+}
+
+$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)){
+ $wms[$cnt] = db_result($res,$cnt,"fkey_wms_id");
+ $cnt++;
+}
+
+$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]] = NULL;
+ }
+ else {
+ $avg_response_time[$wms[$i]] = round(db_result($res,0,1)-db_result($res,0,0), 1);
+ }
+
+ $sql = "SELECT status, status_comment, timestamp_begin, timestamp_end, upload_url, updated, image, map_url 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");
+ $mapurl[$wms[$i]] = db_result($res,0,"map_url");
+ $image[$wms[$i]] = db_result($res,0,"image");
+
+ if ($status[$wms[$i]] == -2 && intval(time())-intval($timestamp_begin[$wms[$i]]) > intval(TIME_LIMIT)) {
+ $comment[$wms[$i]] = "Monitoring process timed out.";
+
+ $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);
+ }
+
+ $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);
+ }
+ elseif ($_GET['image'] == "last") {
+ $newArray = $image;
+ arsort($newArray);
+ }
+}
+
+
+
+$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."?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=image'>image</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";
+
+ 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'>";
+
+ $str .= "<table bgcolor='black' border=1 cellspacing=1 cellpadding=0><tr><td height=20 width=20 align=center valign=middle bgcolor='";
+
+ if ($image[$k] == -1) {
+ $str .= "red";
+ }
+ elseif ($image[$k] == 0) {
+ $str .= "yellow";
+ }
+ elseif ($image[$k] == 1) {
+ $str .= "green";
+ }
+
+ if ($image[$k] != -1) {
+ $str .= "'><a href='".$mapurl[$k]."'>o</a></td></tr></table></td>";
+ }
+ else {
+ $str .= "'><a href='".$mapurl[$k]."'>x</a></td></tr></table></td>";
+ }
+
+ $str .= "\n\t\t\t<td valign='top' align = 'left'>";
+ if ($avg_response_time[$k] == NULL) {
+ $str .= "n/a";
+ }
+ else {
+ $str .= $avg_response_time[$k] . " s";
+ }
+ $str .= "</td>";
+ $str .= "\n\t\t\t<td valign='top'><b>" . $percentage[$k] . " %</b> <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<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='".$cnt."'>\n</form>";
+echo $str;
+
+?>
+</body></html>
\ No newline at end of file
Copied: branches/2.5/http/tools/mod_monitorCapabilities_read_single.php (from rev 2111, branches/2.5/http/php/mod_monitorCapabilities_read_single.php)
===================================================================
--- branches/2.5/http/tools/mod_monitorCapabilities_read_single.php (rev 0)
+++ branches/2.5/http/tools/mod_monitorCapabilities_read_single.php 2008-02-20 11:00:58 UTC (rev 2116)
@@ -0,0 +1,102 @@
+
+<?php
+# $Id: mod_monitorCapabilities_read_single.php 76 2006-08-15 12:25:34Z heuser $
+# http://www.mapbender.org/index.php/Monitor_Capabilities
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+session_start();
+import_request_variables("PG");
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db(DB,$con);
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="0">
+<?php
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
+?>
+</head>
+<body>
+<?php
+$admin = new administration();
+
+if ($_GET['wmsid']) {
+ $wms_id = intval($_GET['wmsid']);
+}
+else {
+ echo "Invalid WMS ID.";
+ die;
+}
+
+$sql = "SELECT upload_id, status, status_comment, timestamp_begin, timestamp_end, upload_url, updated FROM mb_monitor ";
+$sql .= "WHERE fkey_wms_id = $1 AND NOT status = '-2' ORDER BY upload_id DESC";
+$v = array($wms_id);
+$t = array('i');
+$res = db_prep_query($sql,$v,$t);
+
+$cnt=0;
+while ($row = db_fetch_array($res)) {
+ $upload_id[$cnt] = db_result($res,$cnt,"upload_id");
+ $status[$cnt] = intval(db_result($res,$cnt,"status"));
+ $comment[$cnt] = db_result($res,$cnt,"status_comment");
+ $timestamp_begin = db_result($res,$cnt,"timestamp_begin");
+ $timestamp_end = db_result($res,$cnt,"timestamp_end");
+ $upload_url[$cnt] = db_result($res,$cnt,"upload_url");
+ if ($status[$cnt] == '0' || $status[$cnt] == '1') {
+ $response_time[$cnt] = strval($timestamp_end-$timestamp_begin) . " s";
+ }
+ else {
+ $response_time[$cnt] = "n/a";
+ }
+ $cnt++;
+}
+
+
+$str = "<span style='font-size:30'>monitoring results</span><hr><br>\n";
+$str .= "<b>" . $wms_id . "</b><br>" . $admin->getWmsTitleByWmsId($wms_id) . "<br><br><br>\n";
+$str .= "<table cellpadding=10 cellspacing=0 border=0>";
+$str .= "<tr bgcolor='#dddddd'><th align='left'>date</th><th align='left' colspan = 2>status</th><th align='center'>response time</th></tr>";
+
+for ($k=0; $k<count($upload_id); $k++) {
+ $img = "stop.bmp";
+ if ($status[$k]==0) $img = "wait.bmp";
+ elseif ($status[$k]==1) $img = "go.bmp";
+
+ if (fmod($k, 2) == 1) {
+ $str .= "\n\t\t<tr bgcolor='#e6e6e6'>";
+ }
+ else {
+ $str .= "\n\t\t<tr bgcolor='#f0f0f0'>";
+ }
+ $str .= "\n\t\t\t<td>".date("F j, Y, G:i:s", $upload_id[$k])."</td>";
+ $str .= "\n\t\t\t<td><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>" . $comment[$k] . "</td>";
+ $str .= "\n\t\t\t<td align='center'>" . $response_time[$k] . "</td>";
+
+# $str .= "\n\t\t\t<td><a href='output_".$wms_id[$k]."_".$max.".txt' target=_blank>log</a></td>";
+}
+$str .= "\n\t</table>\n\t";
+echo $str;
+
+?>
+</body></html>
\ No newline at end of file
Copied: branches/2.5/http/tools/mod_monitorCapabilities_write.php (from rev 2111, branches/2.5/http/php/mod_monitorCapabilities_write.php)
===================================================================
--- branches/2.5/http/tools/mod_monitorCapabilities_write.php (rev 0)
+++ branches/2.5/http/tools/mod_monitorCapabilities_write.php 2008-02-20 11:00:58 UTC (rev 2116)
@@ -0,0 +1,41 @@
+<?php
+# $Id: mod_monitorCapabilities_write.php 1235 2007-10-23 15:42:55Z baudson $
+# http://www.mapbender.org/index.php/Monitor_Capabilities
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+session_start();
+
+require_once(dirname(__FILE__)."/../classes/class_monitor.php");
+
+/*
+ * incoming parameters from command line
+ */
+if ($_SERVER["argc"] != 4) {
+ echo "Insufficient arguments! Monitoring aborted.";
+ die();
+}
+
+$wmsId = $_SERVER["argv"][1];
+$uploadId = $_SERVER["argv"][2];
+$autoUpdate = intval($_SERVER["argv"][3]);
+
+$monitor = new Monitor($wmsId, $uploadId, $autoUpdate);
+
+echo $monitor;
+
+$monitor->updateInDB();
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list