Commit 471e1bd0 authored by 's avatar
Browse files

packetloss + EXPIRED_FLOWS:

added timestamps to flow records (only close flow records are paired)

reverted/removed fix introduced in revision 1235, because timestamps should
solve the problem too. Expired flows cannot be "fragmented" in different read_results
-- these "fragments" are not fragments, but different flows (with same IPs, ports...
but different timestamps since now).
So these flows are not joined, but keep separately and distinguished by timestamps.

Note:

historically timestamp was transformed to epoch counter,
since now timestamps are timestamps, epochs are epochs :)

eflow_data is flow record with epoch (internal)
 flow_data is flow record without epoch (to send out)


packetloss GUI:

everything *Top renamed to *Status
added "restart" button (requires some back-end shell script)
some logging/debugging ability
some reorganization...



git-svn-id: file:///home/svn/mapi/trunk@1367 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent bc0f576e
......@@ -7,7 +7,7 @@
#define CGI_FILENAME BASENAME".cgi"
#define CGI_PACKETCOUNT_FILENAME "packetcount.cgi"
#define TOP_FILENAME BASENAME"_top.html" // right frame
#define TOP_FILENAME_CSV BASENAME"_top.csv"
#define TOP_FILENAME_CSV BASENAME"_status.csv"
static char cgi_head[] = "\
#!/usr/bin/rrdcgi\n\
......
......@@ -217,7 +217,7 @@ div.altitle-acronym { /* Do NOT remove -- altitle depends on this. */
opacity: 0.85 /* CSS3 */
}
div.altitle-top {
div.altitle-status {
border-width: 1px;
border-color: #666666;
border-style: dashed;
......
......@@ -8,9 +8,9 @@ require_once "${DIR}lib/config.php";
# }}}
readfile($config->abspath($config->packetloss_home, $config->packetloss_top));
readfile($config->abspath($config->packetloss_home, $config->packetloss_status));
//$content = "";
//$fp = fopen($config->abspath($config->packetloss_home, $config->packetloss_top), "r");
//$fp = fopen($config->abspath($config->packetloss_home, $config->packetloss_status), "r");
//while (!feof($fp)) $content .= fgets($fp, 4096);
//echo $content;
//fclose($fp);
......
......@@ -4,20 +4,24 @@
# packetloss home
packetloss_home = "/path/to/packetloss"
# packetloss restart command
packetloss_restart = "/path/to/packetloss.sh restart '%filter%'"
# rrdtool binary
rrdtool = "rrdtool"
# log file
# rrdtool log file
rrdtool_error_log = "log/packetloss_rrdtool_error.log"
# rrds
packetloss_rrd = "packetloss.rrd"
packetcount_rrd = "packetloss_packets.rrd"
# packetloss top file
packetloss_top = "packetloss_top.csv"
# packetloss status file
packetloss_status = "packetloss_status.csv"
# enable or disable tops
enable_packetloss_top
# enable or disable status
enable_packetloss_status
# packetloss GUI home
......
......@@ -3,11 +3,13 @@
# Includes {{{
require_once "lib/misc.php";
require_once "lib/page.php";
require_once "lib/config.php";
require_once "lib/logger.php";
require_once "lib/graph.php";
require_once "lib/packetlossTop.php";
require_once "lib/packetlossStatus.php";
require_once "lib/packetlossAdmin.php";
require_once "lib/formElement.php";
......@@ -19,10 +21,11 @@ require_once "lib/highlight.php";
$debug = false;
$logging = false;
$advanced = false;
# }}}
$packetlossTop = new packetlossTop($config->abspath($config->packetloss_home, $config->packetloss_top));
$packetlossStatus = new packetlossStatus($config->abspath($config->packetloss_home, $config->packetloss_status));
# initialize form elements {{{
......@@ -30,14 +33,14 @@ $form = array();
$form["host0"] = new FormElement( // radio
"host0",
$packetlossTop->hostarr,
"" //array_keys($packetlossTop->hostarr)
$packetlossStatus->hostarr,
"" //array_keys($packetlossStatus->hostarr)
);
$form["host1"] = new FormElement( // checkbox
$form["host1"] = new FormElement( // checkboxes
"host1",
$packetlossTop->hostarr,
"" // array_keys($packetlossTop->hostarr)
$packetlossStatus->hostarr,
"" // array_keys($packetlossStatus->hostarr)
);
$form["time_type"] = new FormElement( // radio
......@@ -58,10 +61,10 @@ $form["times"] = new FormElement( // checkboxes
"3h_180_900" => "3 hours (int 3 min, max 15 min)",
"1d_300_3600" => "1 day (int 5 min, max 1 hour)",
"1w_1800_21600" => "1 week (int 30 min, max 6 hour)",
"1m_7200_86400" => "1 month (int 2 hour, max 1 day)",
"1M_7200_86400" => "1 month (int 2 hour, max 1 day)",
),
array(
"1h_60_0"
"1d_300_3600"
)
);
......@@ -136,7 +139,7 @@ $form["consolidation"] = new FormElement( // checkboxes
)
);
$form["characteristics"] = new FormElement( // checkbox
$form["characteristics"] = new FormElement( // checkboxes
"characteristics",
array(
"packetloss" => "Packet Lost Ratio",
......@@ -158,78 +161,84 @@ $form["graph_size"] = new FormElement( // radio
"normal"
);
$form["features"] = new FormElement( // checkbox
$form["features"] = new FormElement( // checkboxes
"features",
array(
"drag" => "Draggable graphs",
),
array(
"drag"
// "drag"
)
);
$form["top_stats"] = new FormElement(
"top_stats",
$form["status_stats"] = new FormElement( // checkboxes
"status_stats",
array(
"line" => array(
"label" => "Line stats",
"peer" => array(
"label" => "Peer stats",
"description" => "Basic stats: Classic and simple view."),
"host" => array(
"label" => "Host stats",
"description" => "Advanced stats: Check this to view stats related to monitoring hosts.\nDo not forget to concretize the host(s) and stats below."),
"overall" => array(
"label" => "Overall stats",
"description" => "Show overall statistics, not specific for any of Host 1 or Host 2.\nNote: These stats should be implemented for host-to-host (line) view soon..."),
// "overall" => array(
// "label" => "<i>Overall stats (depreceted)</i>",
// "description" => "Show overall statistics, not specific for any of Host 1 or Host 2.\nNote: These stats should be implemented for host-to-host (peer) view soon..."),
),
array(
"line",
"peer",
// "host",
// "overall"
)
);
$form["top_host"] = new FormElement(
"top_host",
$form["status_host"] = new FormElement( // checkboxes
"status_host",
array(
"host0" => array(
"label" => "Host 1",
"description" => "Check this to see stats from 'Host 1' point of view too."),
"host1" => array(
"label" => "Host 2",
"description" => "Check this to see stats from 'Host 2' point of view too."),
"int_stats" => array(
"label" => "Internal stats (\"at host\")",
"description" => "Statistics generated at host/interface.\nDue to resource limits, some flows (records of flows) can be ignored or dropped already at host/interface, so some informations about them appers in 'internal stats'. However, they are not counted into 'external stats', as they are simply not shipped from host/interface to packetloss application."),
"ext_stats" => array(
"label" => "External stats (\"from host\")",
"description" => "Statistics generated by packetloss application based on data received from monitoring hosts."),
"devices" => array(
"label" => "Separate interfaces",
"description" => "Show statistics per interface, not just per host.")
"label" => "Host(s) 2",
"description" => "Check this to see stats from 'Host(s) 2' point of view too."),
// "int_stats" => array(
// "label" => "Internal stats (\"at host\")",
// "description" => "Statistics generated at host/interface.\nDue to resource limits, some flows (records of flows) can be ignored or dropped already at host/interface, so some informations about them appers in 'internal stats'. However, they are not counted into 'external stats', as they are simply not shipped from host/interface to packetloss application."),
// "ext_stats" => array(
// "label" => "External stats (\"from host\")",
// "description" => "Statistics generated by packetloss application based on data received from monitoring hosts."),
),
array(
// "host0",
// "host1",
// "int_stats",
// "ext_stats",
// "devices"
)
);
$form["top_rd"] = new FormElement(
"top_rd",
$form["status_r"] = new FormElement( // checkboxes
"status_r",
array(
"devices" => array(
"label" => "Separate interfaces",
"description" => "Show statistics per interface, not just per host."),
"rd" => array(
"label" => "Separate directions",
"description" => "Resolve from/to direction.")
"description" => "Resolve from/to direction."),
"rp" => array(
"label" => "Separate protocols",
"description" => "Resolve protocals by destination port number.")
),
array(
"rd"
// "devices"
"rd",
// "rp"
)
);
$form["top_ct"] = new FormElement(
"top",
if($advanced) {
$form["status_ct"] = new FormElement( // checkboxes
"status",
array(
"c" => array(
"label" => "Current values",
......@@ -244,8 +253,10 @@ $form["top_ct"] = new FormElement(
)
);
$form["top_unit"] = new FormElement(
"top_unit",
}
$form["status_unit"] = new FormElement( // checkboxes
"status_unit",
array(
"flows" => array("label" => "Flows", "description" => "Check this if you are interested in flows counts."),
"pkts" => array("label" => "Packets", "description" => "Check this if you are interested in packets counts."),
......@@ -258,19 +269,39 @@ $form["top_unit"] = new FormElement(
)
);
$form["action"] = new FormElement( // button
$form["action"] = new FormElement( // hidden
"action",
"",
""
);
$form["time"] = new FormElement( // select - option (more selects)
$form["gen_graph"] = new FormElement( // submit
"gen_graph",
"",
""
);
$form["filter"] = new FormElement( // text
"filter",
"",
""
);
$form["restart"] = new FormElement( // submit
"restart",
"",
""
);
$now = @time();
$form["time"] = new FormElement( // select - option
"time",
"",
getdate(@time())
getdate($now)
);
#
// Note: "time" is tricky. There are more selects in one FormElement. I am not sure if this is cool or poor. Using "unknown constant 'seconds'" in time[hours] (instead of time["hours"]) might be a problem someday, however... it was too seductive simplification!
@$seconds = mktime(
$form["time"]->selectedvals[hours],
......@@ -281,6 +312,8 @@ $form["time"] = new FormElement( // select - option (more selects)
$form["time"]->selectedvals[year]
);
#
$i = 0;
foreach($form["host1"]->elementvals as $host1id => $host1name) {
$checked1 = $form["host1"]->isChecked($host1id);
......@@ -291,9 +324,13 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
# }}}
header("Content-Type: $page->contenttype; charset=$page->charset");
header("Content-Script-Type: text/javascript");
header("Content-Style-Type: text/css");
echo $page->xmldeclaration;
echo $page->doctype;
?>
<?php echo "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs">
<head>
......@@ -319,7 +356,7 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
<?php } ?>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/packetlossTop.js"></script>
<script type="text/javascript" src="js/packetlossStatus.js"></script>
<script type="text/javascript" src="js/mouse.js"></script>
<script type="text/javascript" src="js/altitle.js"></script>
......@@ -346,9 +383,6 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
margin-top: 1em;
}
.steps .step {
clear: left;
}
.steps label {
display: block;
width: 100%;
......@@ -408,7 +442,7 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
margin-left: 1em;
}
.tops {
.status {
clear: left;
margin-top: 2em;
border-top: 5px solid #F0F0F0;
......@@ -416,14 +450,15 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
.table {
width: 90%;
}
.thetop {
.thestatus {
border: 1px solid black;
margin-top: 2em;
}
.thetop th {
.thestatus th {
border-bottom: 1px dashed #A0A0A0;
font-family: arial, helvetica, sans-serif;
}
.thetop td {
.thestatus td {
border-top: none;
border-right: none;
border-bottom: 1px dashed #A0A0A0;
......@@ -432,10 +467,10 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
text-align: right;
font-family: arial, helvetica, sans-serif;
}
.thetop tr.delimiter {
.thestatus tr.delimiter {
border-top: 2px solid #808080;
}
.thetop th.right {
.thestatus th.right {
text-align: right;
}
......@@ -460,6 +495,14 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
color: green;
}
.host3 {
color: #DD7700;
}
.host4 {
color: #FFAA00;
}
<?php if($logging) { ?>
#debug {
clear: left;
......@@ -508,36 +551,69 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
else element.className=element.className.replace(focusedRegExp,''); // XXX can not start class="focused…"
}
function switch_hosts() { // TODO length == undefined
var h0i;
var h1i;
var host0 = document.forms["form"].host0;
var host1 = document.forms["form"].host1;
for(i = 0; i < host0.length; i++)
if(host0[i].checked) h0i = i;
for(i = 0; i < host1.length; i++)
if(host1[i].checked) h1i = i;
host0[h1i].checked = true;
host1[h0i].checked = true;
//alert(document.getElementById("_host0_h" + h1i));
//alert(document.getElementById("_host0_h" + h1i).className);
document.getElementById("l_host0_h" + h0i).className = "";
document.getElementById("l_host0_h" + h1i).className = "strong host0";
document.getElementById("l_host1_h" + h1i).className = "";
document.getElementById("l_host1_h" + h0i).className = "strong host1";
function show(id) {
document.getElementById(id).style.display = "block";
//document.getElementById(id).style.color = "black";
}
function hide(id) {
document.getElementById(id).style.display = "none";
//document.getElementById(id).style.color = "gray";
}
function show_hide(element) {
switch(element) {
case document.forms["form"].id_time_type_predefined:
if(element.checked) {
show("h_predefined");
hide("h_user_defined");
}
else {
hide("h_predefined");
show("h_user_defined");
}
break;
case document.forms["form"].id_time_type_start_time:
case document.forms["form"].id_time_type_end_time:
if(element.checked) {
show("h_user_defined");
hide("h_predefined");
}
else {
hide("h_user_defined");
show("h_predefined");
}
break;
case document.forms["form"].id_status_stats_peer:
case document.forms["form"].id_status_stats_host:
if(document.forms["form"].id_status_stats_host.checked) {
show("h_status_host");
}
else {
hide("h_status_host");
}
break;
}
}
//]]> }}}
</script>
<script type="text/javascript">
//<![CDATA[ {{{
exists = false;
function init() {
if(exists) return false;
exists = true;
packetlossTop.setRefreshDelay(document.forms["refreshform"].refresh.value);
packetlossStatus.setRefreshDelay(document.forms["refreshform"].refresh.value);
show_hide(document.forms["form"].id_time_type_predefined);
show_hide(document.forms["form"].id_status_stats_host);
}
window_onDOMContentLoaded_add(init);
//]]> }}}
</script>
<title>Packetloss – Distributed Packet Loss Measurement</title>
</head>
......@@ -555,11 +631,11 @@ foreach($form["host1"]->elementvals as $host1id => $host1name) {
<?php # Steps {{{ ?>
<div class="steps">
<form name="form" method="get" action="index.php">
<form id="form" method="get" action="index.php">
<div class="step">
<h2>Step 1: Select monitoring hosts</h2>
<div class="medium floatleft">
<span class="th host0">Host 1:</span>
<h4 class="host0">Host 1:</h4>
<?php
$name = $form["host0"]->name;
foreach($form["host0"]->elementvals as $key => $val) {
......@@ -575,7 +651,7 @@ EOD;
?>
</div>
<div class="medium floatleft">
<span class="th host1">Host 2:</span>
<h4 class="host1">Host(s) 2:</h4>
<?php
$i = 1;
$name = $form["host1"]->name;
......@@ -584,7 +660,7 @@ EOD;
$class = $checked ? " class=\"strong host$i\"" : "";
echo <<<EOD
<div class="medium tr">
<span class="th"><label id="l_${name}_$key"for="id_${name}_$key"$class>$val</label></span>
<span class="th"><label id="l_${name}_$key" for="id_${name}_$key"$class>$val</label></span>
<span class="td"><input id="id_${name}_$key" name="${name}[]" type="checkbox" value="$key"$checked /></span>
</div>\n
EOD;
......@@ -592,367 +668,375 @@ EOD;
}
?>
</div>
<div class="clear"></div>
<!--div class="clear"></div-->
<!-- input type="button" value="&lt;&lt;—Switch—&gt;&gt;" onclick="switch_hosts()" / -->
</div>
<div class="step">
<div class="step floatleft clear">
<h2>Step 2: Select time period and granularity:</h2>
<div class="substep">
<div class="substep floatleft clear">
<h4>Time type:</h4>
<?php
$name = $form["time_type"]->name;
foreach($form["time_type"]->elementvals as $key => $val) {
$checked = $form["time_type"]->isChecked($key);
$class = ($key == "start_time" ? " clear" : "");
echo <<<EOD
<div class="tr$class">
<div class="tr floatleft clear">
<span class="th"><label for="id_${name}_$key">$val</label></span>
<span class="td"><input id="id_${name}_$key" name="${name}" type="radio" value="$key"$checked /></span>
<span class="td"><input id="id_${name}_$key" name="${name}" type="radio" value="$key"$checked onclick="show_hide(this)" /></span>
</div>\n
EOD;
}
?>
<div class="clear"></div>
<!--div class="clear"></div-->
</div>
<div class="substep">
<div class="substep floatleft clear" id="h_predefined">
<h4>Predefined:</h4>
<?php
$name = $form["times"]->name;
foreach($form["times"]->elementvals as $key => $val) {
$checked = $form["times"]->isChecked($key);
echo <<<EOD
<div class="tr">
<span class="th"><label for="id_$name_$key">$val</label></span>
<span class="td"><input id="id_$name_$key" name="${name}[]" type="checkbox" value="$key"$checked /></span>
<div class="tr floatleft clear">
<span class="th"><label for="id_${name}_$key">$val</label></span>
<span class="td"><input id="id_${name}_$key" name="${name}[]" type="checkbox" value="$key"$checked /></span>
</div>\n
EOD;
}
?>
<div class="clear"></div>
<!--div class="clear"></div-->
</div>
<div class="substep">
<div class="substep floatleft" id="h_user_defined">
<h4>User defined:</h4>
<div class="tr widetd">
<span class="th"><label>Start or end time:</label></span>
<select name="time[hours]" size="1">
<div class="tr widetd">
<span class="th"><label>Start or end time:</label></span>
<select name="time[hours]" size="1">
<?php
for($i = 0; $i <= 23; $i++) {
$selected = $form["time"]->selectedvals[hours] == $i ? " selected=\"selected\"" : "";
$value = $i < 10 ? "0".$i : $i;
echo <<<EOD
<option value="$i"$selected>$value</option>\n
<option value="$i"$selected>$value</option>\n
EOD;
}
?>
</select>
:
<select name="time[minutes]" size="1">
</select>
:
<select name="time[minutes]" size="1">
<?php
for($i = 0; $i <= 59; $i++) {
$selected = $form["time"]->selectedvals[minutes] == $i ? " selected=\"selected\"" : "";
$value = $i < 10 ? "0".$i : $i;
echo <<<EOD
<option value="$i"$selected>$value</option>\n
<option value="$i"$selected>$value</option>\n
EOD;
}
?>
</select>
&nbsp;
<select name="time[mday]" size="1">
</select>
&nbsp;