Changes
removed /etc/init.d/vz update-cron part (not implemented anymore)
Traffic Accounting through /proc/net/dev
== Introduction ==
Traffic accounting in OpenVZ can be done through data collection against <code>/proc/net/dev</code> in the individual VEs containers on a [[HN]].
== Prerequisites ==
Then install this script:
# list of intervals, 1d = last day, 1w = last week and so on
for INT in 1h 1d 1w 1m 1y
do
/usr/bin/rrdtool graph ${www_path}/${CTID}-${INT}.png \
--start now-$INT --end now \
-w 1000 -h 500 \
--title "CTID $CTID - Interval $INT" \
DEF:in=$RRD:IN:AVERAGE AREA:in#aea:'IN' LINE1:in#0e0 \
DEF:out=$RRD:OUT:AVERAGE AREA:out#eaa:'OUT' LINE1:out#e00
echo "<p><img src=\"${CTID}-${INT}.png\"><br/><br/></p>" >> ${www_path}/index.html
done
done
</source>
== Setup ==
Add this to cron to run <code>vz_direct_traffic_log</code> every 5 minutes and <code>vz_direct_traffic_render</code> every 30 minutes:
# cat "<< EOF >> /etc/crontab */5 * * * * root /path/to/script/vz_direct_traffic_log " > \ */etc30 * * * * root /crontab && path/etcto/init.dscript/crontab restartvz_direct_traffic_render EOF
To check the output of this later run:
# rrdtool fetch /var/lib/rrd/<veid>.rrd AVERAGE -s -3600
== See also ==
* [[Traffic accounting with iptables]]
* [[Monitoring bandwidth of containers]]
[[Category: Monitoring]]
[[Category: Networking]]