Subject: Re: [vserver] Bandwidth monitoring
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Wed, 24 Dec 2014 04:06:31 +0100

On Wed, Dec 24, 2014 at 01:31:14AM +0100, Jean Weisbuch wrote:
> By default, a VServer has its own virtual interface with its
> own statistics, its possible to share an interface with the
> host but its not the default setup.

Last time I checked IP isolation was still the default.

Nevertheless, with network namespaces, this should work.

Best,
Herbert

> And if vnstat runs on VServer it should work fine, as the /proc
> and /sys on a VServer is "limited" compared to a normal system.
> Tools relying on values not present on a VServer guest might
> not work out of the box but as vnstat it reads /proc/net/dev,
> it seems to be working fine.

> Le 24/12/2014 01:20, Laurens Vets a écrit :
> >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?