Subject: Re: [vserver] Bandwidth monitoring
From: Laurens Vets <laurens@daemon.be>
Date: Tue, 23 Dec 2014 16:20:30 -0800

Does that mean that each vserver keeps its own statistics? Because 
vnstat also parses that output:

user@vserver:~$ strace -e trace=file vnstat -tr 2
execve("/usr/bin/vnstat", ["vnstat", "-tr", "2"], [/* 12 vars */]) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or 
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
open("/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY) = 3
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or 
directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY) = 3
open("/home/user/.vnstatrc", O_RDONLY) = -1 ENOENT (No such file or 
directory)
open("/etc/vnstat.conf", O_RDONLY)      = 3
open("/proc/net/dev", O_RDONLY)         = 3
Sampling eth0 (2 seconds average)...open("/proc/net/dev", O_RDONLY)     
    = 3
42 packets sampled in 2 seconds
Traffic average for eth0

       rx            8 kbit/s            10 packets/s
       tx           16 kbit/s            10 packets/s

user@vserver:~$

If I can just use vnstat that's fine by me, but I was under the 
impression that these statistics were shared?

On 2014-12-23 16:08, Jean Weisbuch wrote:
> You can read how much data has transited on each network interfaces
> inside a guest by reading : /proc/net/dev
> You just have to take the value at first then wait some time, take
> the new value, substract the first one to the second then divide it by
> how long in seconds you waited between the two checks.
> 
> If you want to check from the host, here is a script i made :
> http://paste.debian.net/137926/
> 
> Le 24/12/2014 00:45, Laurens Vets a écrit :
>> Hi list,
>> 
>> Is it possible to monitor the bandwidth of 1 particular guest from 
>> inside that guest?
>> 
>> Basically, I want to run vnstat inside a guest monitoring only the 
>> traffic that guest generates. Is that possible somehow?