6,534
edits
Changes
m
{{DISPLAYTITLE:Monitoring bandwith of containers}} Use the /proc/net/dev/net inside a container, dump stats into a round robin database (rrd)
no need for displaytitle
<pre>
BWDIR=var/rrd/vz
## Default folder for containers
VE_PRIVATE=/var/lib/vz/private
# Define the full path to the bandwidth VE directory and the storage dir.
CBWDIR=/vz/private$VE_PRIVATE/$BWVE/$BWDIR
# Test and make sure that directory is there, if not create it.
# Delete the .rrd file because its obviously not needed anymore.
if ! test -d /vz/private$VE_PRIVATE/$VES; then
echo $i will be deleted
rm -rf $CBWDIR/vps-$VES.rrd
X=`/usr/sbin/vzctl exec $i "grep venet0 /proc/net/dev"`
eval `echo $X | cut -f2 -d: | awk '{printf"IN=%-11ds\nOUT=%-11ds\n", $1, $9}'`
for g in IN OUT;do
[[Category: HOWTO]]
[[Category: Monitoring]]
[[Category: Networking]]