Server data transmit log
Posted: Sun Aug 10, 2003 3:37 pm
whilst looking for some cool scripts i came across one which displays a graph of server data transmissions.
so i 'stole' the part of the script which gets the data from the server. this is a very cut down version which i modified to show what it gets:
When ran it outputs:
put that in a database along with a timestamp.
run the script on each page.
do a comparison between the time between each record and data transmitted, and work out KB/s.
but any ideas about the fathom of info that eth0 spits out?
hope someone can help
Tom
so i 'stole' the part of the script which gets the data from the server. this is a very cut down version which i modified to show what it gets:
Code: Select all
<?php
$procfile="/proc/net/dev";
$proc=fopen($procfile,'r');
while(!feof($proc)) {
$line=fgets($proc,1024);
$rinterface=substr($line,2,5);
$values=substr($line,7,256);
echo "LINE:".$line."<BR>";
echo "RINTERFACE:".$rinterface."<BR>";
echo "INTERFACE:".$interface."<BR>";
// we parse the line
if($rinterface == $interface) {
sscanf($values,"%s %s %s %s %s %s %s %s %s",$rchars,$dummy,$dummy,$dummy,$dummy,$dummy,$dummy,$dummy,$tchars);
echo "<br>".sscanf($values,"%s %s %s %s %s %s %s %s %s",$rchars,$dummy,$dummy,$dummy,$dummy,$dummy,$dummy,$dummy,$tchars);
break;
}
}
?>the thing which interests me most isLINE:Inter-| Receive | Transmit
RINTERFACE:ter-|
INTERFACE:
LINE: face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
RINTERFACE:ace |
INTERFACE:
LINE: lo:65428759 208292 0 0 0 0 0 0 65428759 208292 0 0 0 0 0 0
RINTERFACE: lo:
INTERFACE:
LINE: eth0:318515552 2681176 0 0 0 0 0 0 1833500838 2067389 0 0 12 0 0 0
RINTERFACE:eth0:
INTERFACE:
LINE:
RINTERFACE:
INTERFACE:
-1
i presume some part of that shows the ammount of data that has gone thru eth0, so what im thinking is:LINE: eth0:318515552 2681176 0 0 0 0 0 0 1833500838 2067389 0 0 12 0 0 0
put that in a database along with a timestamp.
run the script on each page.
do a comparison between the time between each record and data transmitted, and work out KB/s.
but any ideas about the fathom of info that eth0 spits out?
hope someone can help
Tom