Commit b1cd4ffe authored by 's avatar

Graphs can be plotted up to the current time when time range is

specified manually (corrected).


git-svn-id: file:///home/svn/mapi/trunk@1459 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 678e0b13
<?php <?php
require_once("conf.php"); require_once("conf.php");
require_once("common.php"); require_once("common.php");
/* /*
* Predefined time intervals and granularities * Predefined time intervals and granularities
...@@ -74,8 +74,8 @@ $graph_type_description=array("L3/L4 protocols", "Application protocols"); ...@@ -74,8 +74,8 @@ $graph_type_description=array("L3/L4 protocols", "Application protocols");
*/ */
if (!isset($default)) { if (!isset($default)) {
$graph_types[0]="apps"; $graph_types[0]="l4";
/* $graph_types[1]="l4" */; $graph_types[1]="apps";
$subject_all=1; $subject_all=1;
$times[0]=$r1[0] . "_" . $r2[0] . "_" . $time_length[0]; $times[0]=$r1[0] . "_" . $r2[0] . "_" . $time_length[0];
/* $times[1]=$r1[1] . "_" . $r2[1] . "_" . $time_length[1]; /* $times[1]=$r1[1] . "_" . $r2[1] . "_" . $time_length[1];
...@@ -125,9 +125,9 @@ function time_to_sec($number, $unit) { ...@@ -125,9 +125,9 @@ function time_to_sec($number, $unit) {
case "Weeks": case "Weeks":
return $number * 86400 * 7; return $number * 86400 * 7;
case "Months": case "Months":
return $number * 86400 * 30; return $number * 2628000; /* for non-leap years */
case "Years": case "Years":
return $number * 86400 * 365; return $number * 86400 * 365; /* for non-leap years */
default: default:
return -1; return -1;
} }
...@@ -161,14 +161,14 @@ syslog(LOG_INFO, "$func: starting"); ...@@ -161,14 +161,14 @@ syslog(LOG_INFO, "$func: starting");
echo "<html>\n"; echo "<html>\n";
echo "<head>\n"; echo "<head>\n";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"../style.css\">\n"; echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style.css\">\n";
echo "</head>\n"; echo "</head>\n";
echo "<body>\n"; echo "<body>\n";
if (defined('NET_IMG')) if (defined('NET_IMG'))
echo "<img id=\"logo\" src=\"" . NET_IMG . "\" align=\"right\">\n"; echo "<img id=\"logo\" src=\"" . NET_IMG . "\" align=\"right\" width=\"200\">\n";
echo "<h2>ABW - Passive bandwith usage monitoring</h2>\n"; echo "<h2>ABW - Passive capacity usage monitoring</h2>\n";
if (!isset($subject_selected)) if (!isset($subject_selected))
$subject_selected=1; $subject_selected=1;
...@@ -227,23 +227,27 @@ foreach ($subject_label as $key => $value) { ...@@ -227,23 +227,27 @@ foreach ($subject_label as $key => $value) {
/* if (($i%2)==0) /* if (($i%2)==0)
echo "<tr>\n"; */ echo "<tr>\n"; */
echo "<td>all links</td>\n"; echo "<tr><td>all links</td>\n";
echo "<td><input type=checkbox name=\"subject_all\""; echo "<td><input type=checkbox name=\"subject_all\"";
if ($subject_all) if (isset($subject_all))
echo " checked"; echo " checked";
echo "></td>\n"; echo "></td></tr>\n";
$i++; $i++;
if (($i%2)>0) /* if (($i%2)>0)
echo "<td>&nbsp;</td><td>&nbsp;</td>"; echo "<td>&nbsp;</td><td>&nbsp;</td>"; */
echo "</tr></table>\n"; echo "</table>\n";
/* echo "<p><i>Note: PIONIER monitoring stations are down due to moving to a different subnet.</i>\n"; */
/* /*
* Print form to select time granularities and periods * Print form to select time granularities and periods
*/ */
echo "<p>\n"; echo "<p>\n";
echo "<h3>Step 3: Select time period and granularity:</h3><p>\n"; echo "<h3>Step 3: Select time period and resolution:</h3>\n";
echo "(<a href=\"aggregation.html\">how is data aggregated</a>)\n";
echo "<p>\n";
echo "<p>Time type:<br>\n"; echo "<p>Time type:<br>\n";
echo "<table><tr><td>Predefined <input type=radio name=\"time_type\" value=\"predefined\""; echo "<table><tr><td>Predefined <input type=radio name=\"time_type\" value=\"predefined\"";
...@@ -279,7 +283,7 @@ foreach ($time_description as $key => $value) { ...@@ -279,7 +283,7 @@ foreach ($time_description as $key => $value) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td>all predefined time periods</td>\n"; echo "<td>all predefined time periods</td>\n";
echo "<td><input type=checkbox name=\"time_all\""; echo "<td><input type=checkbox name=\"time_all\"";
if ($time_all) if (isset($time_all))
echo " checked"; echo " checked";
echo "></td>\n"; echo "></td>\n";
echo "</tr>\n"; echo "</tr>\n";
...@@ -309,6 +313,7 @@ echo "<select name=time_minute>"; ...@@ -309,6 +313,7 @@ echo "<select name=time_minute>";
} }
echo "</select>\n"; echo "</select>\n";
echo "<p>Start or end date:<br>\n";
echo "<select name=time_day>"; echo "<select name=time_day>";
for ($i=1; $i<=31; $i++) { for ($i=1; $i<=31; $i++) {
echo "<option value=$i"; echo "<option value=$i";
...@@ -337,7 +342,11 @@ echo "<select name=time_year>"; ...@@ -337,7 +342,11 @@ echo "<select name=time_year>";
echo "</select>\n"; echo "</select>\n";
echo "<p>Time length:<br>\n"; echo "<p>Time length:<br>\n";
echo "<input type=text size=3 name=time_length_number value=\"$time_length_number\"></input>\n"; if (isset($time_length_number))
$time_length_number_preset=$time_length_number;
else
$time_length_number_preset="";
echo "<input type=text size=3 name=time_length_number value=\"$time_length_number_preset\"></input>\n";
echo "<select name=time_length_unit>"; echo "<select name=time_length_unit>";
$time_length_units=array("Minutes", "Hours", "Days", "Weeks", "Months", $time_length_units=array("Minutes", "Hours", "Days", "Weeks", "Months",
...@@ -351,7 +360,7 @@ foreach ($time_length_units as $value) { ...@@ -351,7 +360,7 @@ foreach ($time_length_units as $value) {
echo "</select>\n"; echo "</select>\n";
/* Interval + avg/max are as a separate table */ /* Interval + avg/max are as a separate table */
echo "<p><table><tr><td>Interval:</td><td>Avg/Max:</td></tr><tr>\n"; echo "<p><table><tr><td>Resolution:</td><td>Avg/Max:</td></tr><tr>\n";
echo "<td><input type=text size=3 name=r1_number value=\"$r1_number\"></input>\n"; echo "<td><input type=text size=3 name=r1_number value=\"$r1_number\"></input>\n";
echo "<select name=r1_unit>"; echo "<select name=r1_unit>";
$r1_units=array("Seconds", "Minutes", "Hours", "Days", "Weeks", "Months", $r1_units=array("Seconds", "Minutes", "Hours", "Days", "Weeks", "Months",
...@@ -419,12 +428,12 @@ if ($action=="gen_graph") { ...@@ -419,12 +428,12 @@ if ($action=="gen_graph") {
selected, then generate and show graphs */ selected, then generate and show graphs */
if (isset($graph_types) && if (isset($graph_types) &&
(isset($subjects) || $subject_all) && (isset($subjects) || isset($subject_all)) &&
(isset($times) || $time_all || strcmp($time_type, "predefined"))) { (isset($times) || isset($time_all) || strcmp($time_type, "predefined"))) {
$total_time=0; $total_time=0;
/* echo "<p>\n"; echo "<p>\n";
echo "<table border=1>\n"; /* echo "<table border=\"1\">\n";
echo "<tr><td>Graph type</td><td>Link</td><td>Time (gen / copy)</td></tr>\n"; */ echo "<tr><td>Graph type</td><td>Link</td><td>Time (gen / copy)</td></tr>\n"; */
mkdir($GRAPH_DIR . "/" . $session); mkdir($GRAPH_DIR . "/" . $session);
...@@ -439,17 +448,12 @@ if ($action=="gen_graph") { ...@@ -439,17 +448,12 @@ if ($action=="gen_graph") {
$i=0; $i=0;
foreach ($subject_label as $subject_key => $subject_value) { foreach ($subject_label as $subject_key => $subject_value) {
if (($subject_all || in_array($subject_value, $subjects)) && if ((isset($subject_all) || in_array($subject_value, $subjects)) &&
!$subject_disabled[$subject_key]) { !$subject_disabled[$subject_key]) {
$hostname=$subject_hostname[$i]; $hostname=$subject_hostname[$i];
if ($hostname!="localhost") $command="ssh " . $REMOTE_USERNAME . "@" . $subject_hostname[$i] . " \"" . $GRAPH_SCRIPT . " --session=" . $session . " --graph_type=" . $graph_type_value . " --label=" . $subject_value . " --parameters_id=1";
$command="ssh " . $REMOTE_USERNAME . "@" . $hostname;
else
$command="";
$command=$command . " \"" . $GRAPH_SCRIPT . " --session=" . $session . " --graph_type=" . $graph_type_value . " --label=" . $subject_value . " --parameters_id=1";
/* If maxline is not default ("a"), then request it */ /* If maxline is not default ("a"), then request it */
...@@ -463,8 +467,10 @@ if ($action=="gen_graph") { ...@@ -463,8 +467,10 @@ if ($action=="gen_graph") {
foreach ($time_description as $time_key => $time_value) { foreach ($time_description as $time_key => $time_value) {
$time_label=$r1[$time_key] . "_" . $r2[$time_key] . $time_label=$r1[$time_key] . "_" . $r2[$time_key] .
"_" . $time_length[$time_key]; "_" . $time_length[$time_key];
if ($time_all || in_array($time_label, $times)) { if (isset($time_all) || in_array($time_label, $times)) {
$hhmmYYYYMMDD=date("G:i Ymd", (int)(time() / $r2[$time_key]) * $r2[$time_key] - $r2[$time_key]); /* Rounding was removed */
$hhmmYYYYMMDD=date("G:i Ymd", (int)(time() ));
// $hhmmYYYYMMDD=date("G:i Ymd", (int)(time() / $r2[$time_key]) * $r2[$time_key]);
$command=$command . " --time=\\\"" . $command=$command . " --time=\\\"" .
$r1[$time_key] . " " . $r2[$time_key] . " " . $r1[$time_key] . " " . $r2[$time_key] . " " .
...@@ -489,17 +495,21 @@ if ($action=="gen_graph") { ...@@ -489,17 +495,21 @@ if ($action=="gen_graph") {
$r1_sec=time_to_sec($r1_number, $r1_unit); $r1_sec=time_to_sec($r1_number, $r1_unit);
$r2_sec=time_to_sec($r2_number, $r2_unit); $r2_sec=time_to_sec($r2_number, $r2_unit);
/* echo "r1_sec: $r1_sec, r2_sec: $r2_sec<br>\n"; */ /* echo "r1_sec: $r1_sec, r2_sec: $r2_sec<br>\n"; */
if ($r1_sec<=0 || $r2_sec<=0 || $r2_sec<$r1_sec || if ($r1_sec<=0 || $r2_sec<=0) {
($r2_sec%$r1_sec)>0) { echo "Incorrect time or date specification (resolution and avg/max must be greater than zero).<br>\n";
echo "Incorrect time or date specification.<br>\n"; exit();
}
if ($r2_sec<$r1_sec) {
echo "Incorrect time or date specification (avg/max must be greater than equal to resolution).<br>\n";
exit(); exit();
} }
$time_length_sec=time_to_sec($time_length_number, $time_length_sec=time_to_sec($time_length_number,
$time_length_unit); $time_length_unit);
$time_length_sec= /* Rounding was removed */
((int)($time_length_sec / $r2_sec)) * $r2_sec; // $time_length_sec=
// ((int)($time_length_sec / $r2_sec)) * $r2_sec;
if ($time_length_sec<=0) { if ($time_length_sec<=0) {
echo "Incorrect time or date specification.<br>\n"; echo "Incorrect time or date specification (time length must be greater than zero).<br>\n";
exit(); exit();
} }
...@@ -507,22 +517,26 @@ if ($action=="gen_graph") { ...@@ -507,22 +517,26 @@ if ($action=="gen_graph") {
$timestamp=strtotime($time_year . "-" . $time_month . "-" . $timestamp=strtotime($time_year . "-" . $time_month . "-" .
$time_day . " " . $time_hour . ":" . $time_minute); $time_day . " " . $time_hour . ":" . $time_minute);
/* Adjust timestamp to R2 boundary */
/* Rounding was removed */
// $timestamp=((int)($timestamp / $r2_sec)) * $r2_sec;
/* echo "timestamp: $timestamp<br>\n"; */ /* echo "timestamp: $timestamp<br>\n"; */
$hhmmYYYYMMDD=date("G:i Ymd", $timestamp);
/* echo "hhmmYYYYMMDD: $hhmmYYYYMMDD<br>\n"; */
/* If start time was given, then compute end time */ /* If start time was given, then compute end time */
if (!strcmp($time_type, "start_time")) { if (!strcmp($time_type, "start_time")) {
$timestamp=$timestamp + $time_length_sec; $timestamp=$timestamp + $time_length_sec;
/* echo "timestamp + time_length: $timestamp<br>\n"; */ /* echo "timestamp + time_length: $timestamp<br>\n"; */
$hhmmYYYYMMDD=date("G:i Ymd", $timestamp);
/* echo "hhmmYYYYMMDD + time_length: $hhmmYYYYMMDD<br>\n"; */
} }
if ($timestamp>time()) {
echo "Incorrect time or date specification (end time must not be in the future).<br>\n";
exit();
}
/* Adjust timestamp to R2 boundary */ $hhmmYYYYMMDD=date("G:i Ymd", $timestamp);
/* echo "hhmmYYYYMMDD + time_length: $hhmmYYYYMMDD<br>\n"; */
$timestamp=((int)($timestamp / $r2_sec)) * $r2_sec;
$command=$command . " --time=\\\"" . $r1_sec . " " . $command=$command . " --time=\\\"" . $r1_sec . " " .
$r2_sec . " " . $time_length_number . $r2_sec . " " . $time_length_number .
...@@ -543,12 +557,7 @@ if ($action=="gen_graph") { ...@@ -543,12 +557,7 @@ if ($action=="gen_graph") {
$graph_type_description[$graph_type_key], $subject_value, $graph_type_description[$graph_type_key], $subject_value,
$diff); */ $diff); */
if ($hostname!="localhost") $command="scp " . $REMOTE_USERNAME . "@" . $subject_hostname[$i] . ":" . $REMOTE_GRAPH_DIR . "/" . $session . "/* " . $GRAPH_DIR . "/" . $session;
$command="scp " . $REMOTE_USERNAME . "@" . $hostname . ":";
else
$command="cp ";
$command=$command . $REMOTE_GRAPH_DIR . "/" . $session . "/* " . $GRAPH_DIR . "/" . $session;
syslog(LOG_DEBUG, "Command: $command"); syslog(LOG_DEBUG, "Command: $command");
$time1=gettimeofday(TRUE); $time1=gettimeofday(TRUE);
system($command); system($command);
...@@ -568,7 +577,7 @@ if ($action=="gen_graph") { ...@@ -568,7 +577,7 @@ if ($action=="gen_graph") {
$graphs=0; $graphs=0;
foreach ($subject_label as $subject_key => $subject_value) { foreach ($subject_label as $subject_key => $subject_value) {
if (($subject_all || in_array($subject_value, $subjects)) && if ((isset($subject_all) || in_array($subject_value, $subjects)) &&
!$subject_disabled[$subject_key]) { !$subject_disabled[$subject_key]) {
if (!strcmp($time_type, "predefined")) { if (!strcmp($time_type, "predefined")) {
...@@ -576,7 +585,7 @@ if ($action=="gen_graph") { ...@@ -576,7 +585,7 @@ if ($action=="gen_graph") {
foreach ($time_description as $time_key => $time_value) { foreach ($time_description as $time_key => $time_value) {
$time_label=$r1[$time_key] . "_" . $r2[$time_key] . "_" . $time_label=$r1[$time_key] . "_" . $r2[$time_key] . "_" .
$time_length[$time_key]; $time_length[$time_key];
if ($time_all || in_array($time_label, $times)) { if (isset($time_all) || in_array($time_label, $times)) {
foreach($graph_types as $graph_type) { foreach($graph_types as $graph_type) {
$graph_filename="graph/" . $session . "/graph_" . $subject_value . "_" . $graph_filename="graph/" . $session . "/graph_" . $subject_value . "_" .
...@@ -590,10 +599,10 @@ if ($action=="gen_graph") { ...@@ -590,10 +599,10 @@ if ($action=="gen_graph") {
echo "<td width=430 align=center>\n"; echo "<td width=430 align=center>\n";
echo " <table>\n"; echo " <table>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align=center><a href=\"$graph_filename\"><img width=400 src=\"$graph_filename\"></a></td>\n"; echo " <td align=center width=450><a href=\"$graph_filename\"><img width=400 src=\"$graph_filename\"></a></td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align=center>" . $graph_type_description[array_search($graph_type, $graph_type_label)] . ", Monitored link: " . $subject_description[$subject_key] . "<br>$time_description[$time_key]</td>\n"; echo " <td align=center width=450>" . $graph_type_description[array_search($graph_type, $graph_type_label)] . ", Monitored link: " . $subject_description[$subject_key] . "<br>$time_description[$time_key]</td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo "</td>\n"; echo "</td>\n";
...@@ -620,10 +629,10 @@ if ($action=="gen_graph") { ...@@ -620,10 +629,10 @@ if ($action=="gen_graph") {
echo "<td width=430 align=center>\n"; echo "<td width=430 align=center>\n";
echo " <table>\n"; echo " <table>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align=center><a href=\"$graph_filename\"><img width=400 src=\"$graph_filename\"></a></td>\n"; echo " <td align=center width=450><a href=\"$graph_filename\"><img width=400 src=\"$graph_filename\"></a></td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align=center>" . $graph_type_description[array_search($graph_type, $graph_type_label)] . ", Monitored link: " . $subject_description[$subject_key] . "<br>$time_length_number $time_length_unit"; echo " <td align=center width=450>" . $graph_type_description[array_search($graph_type, $graph_type_label)] . ", Monitored link: " . $subject_description[$subject_key] . "<br>$time_length_number $time_length_unit";
if (!strcmp($time_type, "start_time")) if (!strcmp($time_type, "start_time"))
echo " from"; echo " from";
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment