.
#
# }}}
#
include("defs.php3");
#
# Only known and logged in users.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify page arguments.
#
$optargs = OptionalPageArguments("showtype", PAGEARG_STRING,
"plain", PAGEARG_BOOLEAN);
#
# Show argument.
#
if (! isset($showtype))
$showtype="delay";
if (! isset($plain))
$plain=0;
if (! $plain) {
PAGEHEADER("Wide Area Link Characteristics");
echo "Show:
Delay,
Bandwidth,
Lossrate,
Dates,
All. ";
echo "Format:
Text.";
echo "
\n";
}
else {
header("Content-Type: text/plain");
echo "\n";
}
#
# Convert showtype to quicker compare
#
if (!strcmp($showtype, "all"))
$showtype = 1;
elseif (!strcmp($showtype, "delay"))
$showtype = 2;
elseif (!strcmp($showtype, "bw"))
$showtype = 3;
elseif (!strcmp($showtype, "plr"))
$showtype = 4;
elseif (!strcmp($showtype, "dates"))
$showtype = 5;
else
$showtype = 1;
function SPITDATA($table, $title, $showtype, $plain)
{
$query_result1 =
DBQueryFatal("select t.*,n.priority from $table as t ".
"left join nodes as n on n.node_id=t.node_id1 ".
"order by n.priority");
# PHP arrays are strange wrt "each" function. Need two copies.
$nodenamesrow = array();
$nodenamescol = array();
while ($row = mysql_fetch_array($query_result1)) {
$node_id1 = $row["node_id1"];
$iface1 = $row["iface1"];
$node_id2 = $row["node_id2"];
$iface2 = $row["iface2"];
$time = $row["time"];
$bw = $row["bandwidth"];
$plr = $row["lossrate"];
$start = $row["start_time"];
$end = $row["end_time"];
$pri = $row["priority"];
$glom1 = $node_id1;
$glom2 = $node_id2;
#echo "Got $glom1 to $glom2 $pri
\n";
$nodenamesrow["$glom1"] = $pri;
$nodenamescol["$glom1"] = $pri;
# $nodenamesrow[$glom2] = 1;
# $nodenamescol[$glom2] = 1;
$speeds[ $glom1 . "+" . $glom2 ] = $time * 1000;
$bws[ $glom1 . "+" . $glom2 ] = $bw;
$plrs[ $glom1 . "+" . $glom2 ] = $plr * 100.0;
$dates[ $glom1 . "+" . $glom2 ] =
strftime("%m/%d-%H:%M", $start) . "
" .
strftime("%m/%d-%H:%M", $end);
}
asort($nodenamesrow, SORT_NUMERIC);
reset($nodenamesrow);
asort($nodenamescol, SORT_NUMERIC);
reset($nodenamescol);
if (! $plain) {
echo "
  | \n"; while (list($n1, $ignore1) = each($nodenamescol)) { echo "$n1 | \n"; } reset($nodenamescol); echo "|||||
$n1 | "; } else { printf("%10s ", "$n1"); } while (list($n2, $ignore2) = each($nodenamescol)) { if (strcmp($n1, $n2)) { $s = -1; $b = -1; $p = -1; $d = (($plain) ? "" : " "); $glom = $n1 . "+" . $n2; if (isset($speeds[$glom])) { $s = (int) $speeds[$glom]; $b = (int) $bws[$glom]; $p = sprintf("%.2f", $plrs[$glom]); $d = $dates[$glom]; } if ($plain) { if ($showtype == 1) printf("%10s ", "$s,$b,$p"); elseif ($showtype == 2) printf("%10s ", "$s"); elseif ($showtype == 3) printf("%10s ", "$b"); elseif ($showtype == 4) printf("%10s ", "$p"); elseif ($showtype == 5) printf("%10s ", "$d"); } else { if ($showtype == 1) echo "$s,$b,$p | "; elseif ($showtype == 2) echo "$s | "; elseif ($showtype == 3) echo "$b | "; elseif ($showtype == 4) echo "$p | "; elseif ($showtype == 5) echo "$d | "; } } else { if ($plain) printf("%10s ", "*"); else echo "![]() |