Changes

Jump to: navigation, search

Traffic accounting with iptables

4 bytes added, 16:13, 4 July 2011
Sample php script to store the trafficlog in a database
$MySQL_Passw="INSERT-YOUR-MYSQL-PASSWORD-HERE";
mysql_connect("$MySQL_Host","$MySQL_User","$MySQL_Passw");
$HN=trim(addslashes($_GET["HN"])); // Hardware Node
$handle = fopen ("tmp/{$HN}-traffic","r");
while (!feof($handle)) {
$line = fgets($handle, 4096);
list($date,$time,$ip,$traffic)=explode(" ",$line);
if($traffic>0) {mysql($db,"insert into Traffic (ip,measuringtime,bytes) values('{$ip}','{$date } {$time}','{$traffic}')");}
}
fclose($handle);
Anonymous user

Navigation menu