Subject: Re: [vserver] Traffic accounting
From: Herbert Poetzl <herbert@13thfloor.at>
Date: Fri, 9 Jan 2009 22:47:17 +0100

On Fri, Jan 09, 2009 at 01:34:51PM -0500, Cedric Veilleux wrote:
> Hi,
> 
> I am using the vserver collectd plugin which gives me several nice
> graphs for each vservers.

> One of these is the inet traffic, which is built from the data obtained
> via the /proc/virtual/xid/cacct file (I didn't check collectd sources
> but I guess that's where the data come from).

> The problem is that the data for the traffic accounting seems to be
> wrong. It does make some kind of sense but seems to be always much much
> lower than the actual traffic transferred, maybe only 10% gets reported.

> I am basing my estimate on the fact that I also use pmacct, which does
> the accounting using libpcap on a per-IP basis, and pmacct's stats seems
> to be more accurate..

> The problem is that I prefer collectd since it gives the stats on a
> per vserver basis which is much more useful than on a per-IP basis..

do your guest _share_ IPs between them? 
if not, the best and simplest way to get proper
on-wire accounting is to add an iptables account
rule, and feed that into your collecting/graphing
solution

> Are there known problems with the vserver traffic accounting via proc?

besides the fact, that there is no traffic accounting
for Linux-VServer guests via proc, no :)

the cacct entry in /proc/virtual/<xid> accounts the
sockets (send/receive/fail) of a guest, which can be
a lot less than the actual on-wire traffic (due to
headers, retransmissions, etc)

HTC,
Herbert

> Below is the output of vserver-info:
> 
> 
> 
> 
> Versions:
>                    Kernel: 2.6.22-3-vserver-amd64
>                    VS-API: 0x00020200
>              util-vserver: 0.30.216-pre2772; Nov  8 2008, 21:49:08
> 
> Features:
> 		       CC: gcc, gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
>                       CXX: g++, g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
>                  CPPFLAGS: ''
>                    CFLAGS: '-Wall -g  -O2 -std=c99 -Wall -pedantic -W -funit-at-a-time'
>                  CXXFLAGS: '-g -O2 -ansi -Wall -pedantic -W -fmessage-length=0 -funit-at-a-time'
>                build/host: x86_64-pc-linux-gnu/x86_64-pc-linux-gnu
>              Use dietlibc: yes
>        Build C++ programs: yes
>        Build C99 programs: yes
>            Available APIs: v13,net,v21,v22,v23,netv2
>             ext2fs Source: e2fsprogs
>     syscall(2) invocation: alternative
>       vserver(2) syscall#: 236/glibc
>                crypto api: beecrypt
> 
> Paths:
>                    prefix: /usr
>         sysconf-Directory: /etc
>             cfg-Directory: /etc/vservers
>          initrd-Directory: $(sysconfdir)/init.d
>        pkgstate-Directory: /var/run/vservers
>           vserver-Rootdir: /var/lib/vservers
> 
> 
> 
> 
> -- 
> Cedric Veilleux <cveilleux@neopeak.com>
> Neopeak Internet Solutions inc.
>