Commit f6bb8a78 authored by 's avatar
Browse files

Sensor interface statistics added in packetloss web interface.


git-svn-id: file:///home/svn/mapi/trunk@1301 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 9179436d
......@@ -72,6 +72,39 @@ static char cgi_pkcount_head3[] = "\
// not a cgi header. Need in packetloss GUI (right frame)
static char top_page[] = "\
<html>\n<head>\n\
<script language=\"JavaScript\">\
function toggleDisplay(me,hnr){\
if (parent.hiddenFrame.hidden[hnr]==1){\
parent.hiddenFrame.hidden[hnr]=0;\
me.style.display=\"inline\";\
}\
else {\
if (parent.hiddenFrame.hidden[hnr]==0){\
parent.hiddenFrame.hidden[hnr]=1;\
me.style.display=\"none\";\
}\
}\
}\
function setdisplay(me, hnr) {\
if( parent.hiddenFrame.hidden[hnr] == 1 )\
me.style.display=\"none\";\
else\
me.style.display=\"inline\";\
}\
function appendmydiv(idname, htmltext, hnr) {\
var newhtml = document.createElement(\"div\");\
newhtml.id = idname;\
if( parent.hiddenFrame.hidden[hnr] == 1)\
newhtml.style.display = 'none';\
else\
newhtml.style.display = 'inline';\
newhtml.innerHTML = htmltext;\
var prtable = document.getElementById('protocolstable');\
document.body.insertBefore(newhtml, prtable);\
}\
var sensorstatshtml=\"%s\";\
var sensorsstatslink=\"%s\";\
</script>\
<style type=\"text/css\">\n\
<!--\
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}\n\
......@@ -85,7 +118,8 @@ static char top_page[] = "\
<META Http-Equiv=\"Pragma\" Content=\"no-cache\">\n\
<META Http-Equiv=\"Expires\" Content=\"0\">\n\
<META Http-Equiv=\"Refresh\" Content=\"10;url=./%s\">\
</head>\n<body><div class=style1><div class=style9>\n\
</head>\n<body onload='appendmydiv(\"sensorsstatslink\",sensorsstatslink,0), appendmydiv(\"sensorstats\",sensorstatshtml,1)'>\n\
<div class=style9 id='bigdiv'>\n\
<table><tr><td width=25%% align=\"center\">\n\
<a href=\"http://www.ist-lobster.org\" style=\"color: white\" target=_new title=\"Large-scale Monitoring of Broadband Internet Infrastructures\">\n\
<img src=\"/packetloss/img/lobster-logo.jpg\"></a></td></tr>\n\
......
<html>
<script language="JavaScript">
var hidden = new Array(2);
hidden[0] = 0;
hidden[1] = 1;
</script>
......@@ -3,11 +3,12 @@
<title>LOBSTER - Distributed PacketLoss</title>
</head>
<frameset cols="60%, 40%" framespacing="1" border="1">
<frameset cols="60%, 40%, *" framespacing="1" border="1">
<frameset rows="50%, 50%">
<frame src="cgi-bin/packetloss.cgi" name="packetloss">
<frame src="cgi-bin/appmon.cgi" name="appmon">
</frameset>
<frame src="./packetloss_top.html" name="top">
<frame name="hiddenFrame" id="hiddenFrame" src="./hidden.html">
</frameset>
</html>
......@@ -88,6 +88,8 @@ int main(int argc, char *argv[])
struct statistics stats[MAX_INTERFACES] = { {0, 0} };
FILE *fp = NULL, *fp_packetloss = NULL, *fp_packetloss_packets = NULL;
float speed = 0.0;
struct mapi_stat stats1, stats2;
char sensorstats[512], sensorstatslink[256];
signal(SIGINT, terminate);
signal(SIGQUIT, terminate);
......@@ -218,7 +220,18 @@ int main(int argc, char *argv[])
results = (mapi_results_t *) mapi_read_results(fd, fid_loss);
results_netload = (mapi_results_t *) mapi_read_results(fd, fid_load);
if (mapi_stats(argv[1], &stats1)<0) {
fprintf(stderr, "Error in mapi_stats using '%s'\n", argv[1]);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
if (mapi_stats(argv[2], &stats2)<0) {
fprintf(stderr, "Error in mapi_stats using '%s'\n", argv[2]);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
struct flow_data *flowdata;// = (struct flow_data *)((char *) i + sizeof(unsigned int));
// Store all the information from the sensors in the hashtable.
......@@ -453,9 +466,19 @@ int main(int argc, char *argv[])
refresh(); // refresh curses windows and lines
}
fp = fopen(TOP_FILENAME, "w"); // right frame (statistics)
sprintf(top_page_buf, top_page, TOP_FILENAME);
// Refresh the statistics on the right frame
fp = fopen(TOP_FILENAME, "w");
if( stats1.ps_drop != 0 || stats2.ps_drop != 0 || stats1.ps_ifdrop != 0 || stats2.ps_ifdrop != 0)
sprintf(sensorstatslink, "<center><a href='#' id='link' onClick='toggleDisplay(document.getElementById(\\\"sensorstats\\\"),1)'>Sensors Statistics</a><img src='./led-red.gif'>");
else
sprintf(sensorstatslink, "<center><a href='#' id='link' onClick='toggleDisplay(document.getElementById(\\\"sensorstats\\\"),1)'>Sensors Statistics</a><img src='./led-green.gif'>");
sprintf(sensorstats, "<center> <br> Sensor 1 interfaces stats:<br>received: %u<br>dropped: %u\
<br>dropped by interface: %u<br>Hostname: %s<br>Interface: %s<br>\
<br>Sensor 2 interfaces stats:<br>received: %u<br>dropped: %u<br>dropped by interface: %u<br>Hostname: %s<br>Interface: %s<br></center>",\
stats1.ps_recv,stats1.ps_drop,stats1.ps_ifdrop,stats1.hostname,stats1.dev,\
stats2.ps_recv,stats2.ps_drop,stats2.ps_ifdrop,stats2.hostname,stats2.dev);
sprintf(top_page_buf, top_page, sensorstats, sensorstatslink, TOP_FILENAME);
fprintf(fp, "%s", top_page_buf);
fprintf(fp, "<center> Total Packet Loss Ratio : %.2f %% (%llu pkts)<br>\n", (float) (totalpkcount ? (totalpkloss * 100) / (float) totalpkcount : totalpkcount), totalpkloss);
......@@ -467,16 +490,17 @@ int main(int argc, char *argv[])
fprintf(fp, "<center> Last 1 Month Packet Loss Ratio : %.2f %% (%llu pkts)<br>\n", (float) (onemonthpkcount ? (onemonthpkloss * 100) / (float) onemonthpkcount : onemonthpkcount), onemonthpkloss);
fprintf(fp, "<center> Last 1 Year Packet Loss Ratio : %.2f %% (%llu pkts)<br><hr>\n", (float) (oneyearpkcount ? (oneyearpkloss * 100) / (float) oneyearpkcount : oneyearpkcount), oneyearpkloss);
//TODO fprintf(fp, "<center> Last Hour Byte Loss Ratio : %.2f %% (%.2f Kbytes)<br><hr>\n", (float) (totalbyteslost * 100) / (float) totalbytescount, (float) (totalbyteslost / (float) 1024));
fprintf(fp, "<center> Total packets lost from <font color=\"#00FF00\"><b>%s</b></font> : %llu (%.2f %%) <br>\n", host1, totalpklossflow0, (float)(totalpkcount ? (totalpklossflow0 * 100) / (float) totalpkcount: totalpkcount));
fprintf(fp, "<center> Total packets lost from <font color='#00FF00'><b>%s</b></font> : %llu (%.2f %%) <br>\n", host1, totalpklossflow0, (float)(totalpkcount ? (totalpklossflow0 * 100) / (float) totalpkcount: totalpkcount));
fprintf(fp, "<center> Total packets lost from <font color=\"#0066FF\"><b>%s</b></font> : %llu (%.2f %%) <br><hr>\n", host2, totalpklossflow1, (float) (totalpkcount ? (totalpklossflow1 * 100) / (float) totalpkcount : totalpkcount));
fprintf(fp, "<center> Total packets captured at host <font color=\"#00FF00\"><b>%s</b></font> : %llu <br>\n", host1, pkcount0);
fprintf(fp, "<center> Total packets captured at host <font color=\"#0066FF\"><b>%s</b></font> : %llu <br><hr>\n", host2, pkcount1);
fprintf(fp, "<center> Total packets matched at host <font color=\"#00FF00\"><b>%s</b></font> : %llu <br>\n", host1, total_matched_pkts_flow0);
fprintf(fp, "<center> Total packets matched at host <font color=\"#0066FF\"><b>%s</b></font> : %llu <br><hr>\n", host2, total_matched_pkts_flow1);
fprintf(fp, "<center><i><u>Network Load</u></i> : %f Mbit/s<br><hr><br>\n", speed);
fprintf(fp, "<center><table border=\"0\" width=75%% bgcolor=\"#999999\" cellpadding=\"1\" cellspacing=\"1\" class=style9>\n");
fprintf(fp, "<tr bgcolor=\"#ffffff\" align=center><th>Protocol</th><th>Total pkts</th><th>Lost pkts</th></tr>\n");
fprintf(fp, "<center><i><u>Network Load</u></i> : %f Mbit/s<br><hr>\n", speed);
fprintf(fp, "</div><div id='protocolstable' ><center><table border=\"0\" width=75%% bgcolor=\"#999999\" cellpadding=\"1\" cellspacing=\"1\" class=style9>\n");
fprintf(fp, "<hr><tr bgcolor=\"#ffffff\" align=center><th>Protocol</th><th>Total pkts</th><th>Lost pkts</th></tr>\n");
print_protocols(fp, "HTTP", http_pkts, http_lost); // HyperText Transfer Protocol
print_protocols(fp, "HTTPs", https_pkts, https_lost); // HTTP over SSL/TLS
......@@ -490,7 +514,7 @@ int main(int argc, char *argv[])
print_protocols(fp, "RTSP", rtsp_pkts, rtsp_lost); // Real Time Streaming Protocol
print_protocols(fp, "MAPI", mapi_pkts, mapi_lost); // Monitoring Application Programming Interface
fprintf(fp, "</table></center></div></body></html>");
fprintf(fp, "</table></center></div></div></body></html>");
fclose(fp);
// remove old unmatched flow from hashtable
......@@ -501,6 +525,8 @@ int main(int argc, char *argv[])
return 0;
}
int print_flow(FILE * fp, flow_data * data, unsigned long long pkloss)
{
char tmp[30], spaces[] = " ";
......@@ -757,7 +783,7 @@ unsigned long long cmp_results(struct flow_data *data, unsigned int sensor, unsi
} else {
*matchedsensor = tmp->sensor;
totalpkcount += tmp2->data.packets_count; // total number of packets
totalbytescount += tmp->data.bytes_count; // total number of bytes
totalbytescount += tmp2->data.bytes_count; // total number of bytes
ret = tmp2->data.packets_count - tmp->data.packets_count; // packet loss
totalbyteslost += tmp2->data.bytes_count - tmp->data.bytes_count; // byte loss
if (*matchedsensor == 0) {
......
......@@ -18,6 +18,9 @@ chmod +x $1/packetloss/img/lobster-logo.jpg
cp index.html $1/packetloss
ln -fs `pwd`/packetloss_top.html $1/packetloss/packetloss_top.html
ln -fs `pwd`/hidden.html $1/packetloss/hidden.html
ln -fs `pwd`/led-green.gif $1/packetloss/led-green.gif
ln -fs `pwd`/led-red.gif $1/packetloss/led-red.gif
ln -fs `pwd`/packetloss.cgi $1/packetloss/cgi-bin/packetloss.cgi
ln -fs `pwd`/packetloss3.cgi $1/packetloss/cgi-bin/packetloss3.cgi
......
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