Changes

Jump to: navigation, search

Traffic accounting with iptables

383 bytes added, 19:49, 19 November 2006
Scripting
== Scripting ==
As you see this way can be time-consuming in case of big number of VEs.
So if anybody has scripts that automate all the process - you are welcome!
 
Here are some scripting ideas
</pre>
a small script to generate a traffic.log
<pre>
host2:~/bin# cat vz-iptables-traffic
trafficlog="./traffic.log"
for i in `./vz-all-running-ip` ;
do
echo -n `date "+%Y-%m-%d %H:%M:%S"` >> $trafficlog
echo -n " $i " >> $trafficlog
echo `iptables -nv -L FORWARD | grep $i | tr -s [:blank:] |cut -d' ' -f3| awk '{sum+=$1} END {print sum;}'` >> $trafficlog
done
iptables -Z
</pre>
As you see this way can be time-consuming in case of big number of VEs.
So if anybody has scripts that automate all the process - you are welcome!
[[Category: HOWTO]]
[[Category: Networking]]
22
edits

Navigation menu