Changes

Jump to: navigation, search

Traffic accounting with iptables

191 bytes added, 20:27, 25 November 2006
Scripting
</pre>
a small script to generate a traffic.log
<pre>
host2:~/bin# cat vz-generate-traffic-log
./vz-iptables-create-rules
# copy the trafficlog file to a webserver where users can take their traffic
# please mind to use
</pre>
SQL querry to get the traffic for the last 30 days
<pre>
SELECT sum(bytes)
FROM Traffic
WHERE ip = 'INSERT-YOUR-IP-HERE'
AND measuringtime > ( now() - INTERVAL 1 MONTH)
GROUP BY ip
</pre>
You can use crontab to run this script once per hour or day to collect your traffic statistics.
22
edits

Navigation menu