'; ?> id) { echo "
Skipped: " . $upd_wmsid . "
"; continue; } // update WMS from upload URL $mywms = new wms(); $mywms->createObjFromXML($uploadUrl); $mywms->optimizeWMS(); echo "
"; $mywms->updateObjInDB($upd_wmsid); echo "
Updated: " . $upd_wmsid . "
"; /* // start new monitoring for this WMS $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, $upload_id, $upd_wmsid); $t = array('s', 's', 's', 'i'); $res = db_prep_query($sql,$v,$t); $currentFilename = "wms_monitor_report_" . $upload_id . "_" . $upd_wmsid . "_" . $wmsOwner . ".xml"; $exec = PHP_PATH . "php5 ../../tools/mod_monitorCapabilities_write.php " . $currentFilename. " 0"; echo exec(escapeshellcmd($exec)); */ } echo "
Please note: The updated services need to be monitored again in order to update the database.

"; } $e = new mb_exception("mod_monitorCapabilities_read.php: userId: ".$_SESSION["mb_user_id"]); $sql = "SELECT DISTINCT mb_monitor.fkey_wms_id FROM mb_monitor, wms " . "WHERE mb_monitor.fkey_wms_id = wms.wms_id AND wms.wms_owner = $1"; $res = db_prep_query($sql, array($_SESSION["mb_user_id"]), array("i")); $wms = array(); while($row = db_fetch_array($res)){ $wms[] = $row["fkey_wms_id"]; $e = new mb_exception("mod_monitorCapabilities_read.php: wmsId: ".$row["fkey_wms_id"]); } $wms_id = array(); $status = array(); $upload_id = array(); $avg_response_time = array(); $comment = array(); $timestamp_begin = array(); $timestamp_end = array(); $upload_url = array(); $updated = array(); $mapurl = array(); $image = 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, cap_diff FROM mb_monitor, wms " . "WHERE upload_id = $1 AND fkey_wms_id = $2 AND wms_owner = $3 ORDER BY status, " . "status_comment, timestamp_end, fkey_wms_id"; $v = array($upload_id[$wms[$i]], $wms_id[$wms[$i]], $user->id); $t = array('s', 'i', '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"); $cap_diff[$wms[$i]] = db_result($res,0,"cap_diff"); 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 = "monitoring results

\n"; $str .= "
\n\t"; $str .= "\n\t\n"; $str .= "\n\t\n

\n "; $str .= ""; $str .= ""; $str .= ""; $str .= ""; $str .= ""; $str .= ""; $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"; } else { $str .= "\n\t\t"; } $str .= "\n\t\t\t"; $str .= "\n\t\t\t"; $str .= "\n\t\t\t"; $str .= "\n\t\t\t"; $str .= "\n\t\t\t"; } else { $str .= "'>x
wmscurrent statusimageavg. response timeoverall availabilityDiff
" . $wms_id[$k] . "
" . $admin->getWmsTitleByWmsId($wms_id[$k]) . "
" . $comment[$k] . "
".date("F j, Y, G:i:s", $upload_id[$k])."
"; $str .= "
o
"; } $str .= "\n\t\t\t"; if ($avg_response_time[$k] == NULL) { $str .= "n/a"; } else { $str .= $avg_response_time[$k] . " s"; } $str .= ""; $str .= "\n\t\t\t" . $percentage[$k] . " %  (" . $total[$k] . " cycles)
"; $str .= ""; $val = $percentage[$k]; for ($i=0; $i<10; $i++) { if ($val>=10) { $str .= ""; $val-=10; } elseif($val>0){ $str .= ""; if (round($val) < 10) { $str .= ""; } $val=-1; } else { $str .= ""; } } $str .= "
"; # $str .= "\n\t\t\tlog"; $str .= "\n\t\t"; $str .= "\n\t\t\t"; if ($cap_diff[$k] != "") #$str .= "view"; $str .= ""; $str .= ""; $cnt++; } $str .= "\n\t\n\t
\n
"; echo $str; ?>