also hier...
bin in der schule und kanns deswegen nicht als zip anhängen. (die rechner sind kacka).
db struktur:
CREATE TABLE `traffic` (
  `id` int(100) NOT NULL auto_increment,
  `day` int(2) NOT NULL default '0',
  `month` int(2) NOT NULL default '0',
  `year` int(4) NOT NULL default '0',
  `hour` int(2) NOT NULL default '0',
  `minute` int(2) NOT NULL default '0',
  `rx` bigint(255) NOT NULL default '0',
  `tx` bigint(255) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM
traffic.php (per cron ausführen (befehl: "php traffic.php"

, nicht im web ordner!)
<?php
/*
das problem:
der linux interne traffic zähler wird bei 4gb auf 0 gesetzt.
dieses script soll dem entgegen wirken, in dem es dauernd aufgerufen wird und somit den unterschied
auffasst und in einer datenbank ablegt.
Snake
*/
chdir('/root/traffic/' ;
;
function getfile($file) { return file_exists($file) ? file_get_contents($file) : 0; }
function setfile($file, $content, $mode='w' {
 {
        $fp = fopen($file, $mode);
        fwrite($fp, $content);
        fclose($fp);
}
require('traffic.lib.php' ;
;
$oldrx = getfile('temp.rx' ; //old stats since last script run
; //old stats since last script run
$oldtx = getfile('temp.tx' ;
;
setfile('temp.rx', $rx); //set new states for the next script run
setfile('temp.tx', $tx);
if($oldrx > $rx) { //if the new state is lower than the old, the timer was reset since the last run
        $rx = 4294967296-$oldrx+$rx;   //4294967296byte=4gb
} else {
        $rx = $rx-$oldrx; //no reset. new-old=since last script run
}
if($oldtx > $tx) { //same as rx
        $tx = 4294967296-$oldtx+$tx;   //4294967296byte=4gb
} else {
        $tx = $tx-$oldtx;//no reset. new-old=since last script run
}
$hMysql = mysql_connect('localhost', 'abcdef', 'abcdef' or die(__FILE__.':'.__LINE__.':'.mysql_error().chr(10));
 or die(__FILE__.':'.__LINE__.':'.mysql_error().chr(10));
mysql_select_db('traffic', $hMysql) or die(__FILE__.':'.__LINE__.':'.mysql_error().chr(10));
mysql_query('INSERT INTO `traffic` (`day`, `month`, `year`, `hour`, `minute`, `rx`, `tx`) VALUES
                        ('.date('d, m, Y, H, i' .' , '.$rx.', '.$tx.'
.' , '.$rx.', '.$tx.' ', $hMysql)  or die(__FILE__.':'.__LINE__.':'.mysql_error().chr(10));
', $hMysql)  or die(__FILE__.':'.__LINE__.':'.mysql_error().chr(10));
mysql_close($hMysql);
traffic.lib.php:
<?php
//read traffic from /proc/net/dev
// 07.01.06 user-303 <snake@s-n-a-k-e.net>
function gettraffic() {
        $traffic = file('/proc/net/dev' ;
;
        /*
        Inter-|   Receive                                                        |  Transmit
         face |bytes      packets    errs drop fifo  frame   compressed multicast|bytes        packets   errs  drop fifo  colls carrier    compressed
                lo:587345569  12585471     0    0    0     0          0         0      587345569   12585471     0    0    0     0       0          0
        venet0:3440747962 218989495    0    0    0     0          0         0      2674333424  344658534    0    0    0     0       0          0
        */
        //search line with 'eth0';
        for($i=0;$i<count($traffic);$i++) {
                if(substr(trim($traffic[$i]), 0, 4) == 'eth0' {
 {
                        $line = $traffic[$i];
                        break;
                }
        }
        if(!isset($line)) die(__FILE__.':'.__LINE__.': ethenet controler not active! abort!'.chr(10));
        $line = substr($line, strpos($line, ':' +1);
+1);
        while(strpos($line, '  ' >0) {
>0) {
                $line = str_replace('  ', ' ', $line); //remove all double spaces
        }
        $ex = explode(' ', trim($line));
        $rx = $ex[0]; //current states
        $tx = $ex[8];
        return array($rx, $tx);
}
list($rx, $tx) = gettraffic();
?>
nehmt es mir nicht übel, aber ich hatte das ding nie gecodet um es weiter zu geben. dementsprechend ist es auch geschrieben