[pve-devel] Count monthly traffic

Adrian Costin adrian.costin at gmail.com
Wed Apr 17 14:42:50 CEST 2013


I'm sorry to dropping in, but isn't Proxmox already counting traffic in
it's internal RRD? Couldn't the "rrddata" API call be used to retrieve the
data in the RRD externally and process it to count the total bandwidth used
in 1 month?

Maybe I've misunderstood what the issue is here...



Best regards,
Adrian Costin


On Wed, Apr 17, 2013 at 3:29 PM, Stefan Priebe - Profihost AG <
s.priebe at profihost.ag> wrote:

> Am 17.04.2013 14:17, schrieb Dietmar Maurer:
> >> Nowhere ;-) how about just return the counter values for the correct
> tap device
> >> through API?
> >>
> >> So it is basically:
> >> 1.) a wrapper from netX to correct tap
> >> 2.) query tap counter inout / output values
> >> 3.) allow to query this through API
> >>
> >> So it is at least possible to implement traffic account in external
> software. You
> >> jsut have to query the API every X seconds and detect resets yourself.
> It acts
> >> than basically like SNMP traffic counters in switches.
> >
> > sounds reasonable.
>
> Then let's go this way. It's much simpler than adding RRD.
>
> So the question is should this be a completely new call or do you want
> to add a new hash key to  sub vmstatus { ?
>
> this could be
>
>     my $netdev = PVE::ProcFSTools::read_proc_net_dev();
>     foreach my $dev (keys %$netdev) {
>         next if $dev !~ m/^tap([1-9]\d*)i/;
>         my $vmid = $1;
>         my $d = $res->{$vmid};
>         next if !$d;
>
>         $d->{netout} += $netdev->{$dev}->{receive};
>         $d->{netin} += $netdev->{$dev}->{transmit};
>     }
>
> converted to:
>
>     my $netdev = PVE::ProcFSTools::read_proc_net_dev();
>     foreach my $dev (keys %$netdev) {
>         next if $dev !~ m/^tap([1-9]\d*)i(\d+)/;
>         my $vmid = $1;
>         my $netid = $2;
>         my $d = $res->{$vmid};
>         next if !$d;
>
>         $d->{netout} += $netdev->{$dev}->{receive};
>         $d->{netin} += $netdev->{$dev}->{transmit};
>         $d->{traffic}{'net'.$netid}{netout} = $netdev->{$dev}{receive};
>         $d->{traffic}{'net'.$netid}{netin} = $netdev->{$dev}{transmit};
>     }
>
>
> Stefan
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.proxmox.com/pipermail/pve-devel/attachments/20130417/62ca6199/attachment.htm>


More information about the pve-devel mailing list