Changes

Jump to: navigation, search

Traffic accounting through proc

99 bytes removed, 21:46, 12 January 2013
removed /etc/init.d/vz update-cron part (not implemented anymore)
# Parse out the inbound/outbound traffic and assign them to the corresponding variables
eval `/usr/sbin/vzctl exec $veid "grep venet0 /proc/net/dev" | \
awk -F: '{print $2}' | awk '{printf"CTIN=%-15ds\nCTOUT=%-15ds\n", $1, $9}'`
# Send the data to the corresponding RRD time with (N)now as the update time
rrd_path=/var/lib/rrd
www_path=/var/www/html/traf
 
# Clear out the old index, otherwise you end up with a repeating index. This would also be a good place to put a header.
rm ${www_path}/index.html
cd $rrd_path
*/30 * * * * root /path/to/script/vz_direct_traffic_render
EOF
 
Alternatively, use the cron system of OpenVZ
 
# cat << EOF > /etc/vz/cron/vz-traffic.sh
*/5 * * * * root /path/to/script/vz_direct_traffic_log
*/30 * * * * root /path/to/script/vz_direct_traffic_render
EOF
# /etc/init.d/vz update-cron
To check the output of this later run:
Anonymous user

Navigation menu