[pve-devel] [PATCH] [V3] implement node netstat call to get current tap network counters
Dietmar Maurer
dietmar at proxmox.com
Thu Apr 18 11:17:58 CEST 2013
I am unable to apply that patch, I get
error: API2/Nodes.pm: does not exist in index
correct path is PVE/API2/Nodes.pm?
> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Stefan Priebe
> Sent: Donnerstag, 18. April 2013 09:04
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH] [V3] implement node netstat call to get current tap
> network counters
>
> Changes since V2:
> - swap in / out / transmit / receive again
>
> Changes since V1:
> - new return format (use an arrayref instead of a hash to be JS compatible)
> - swap in / out / transmit / receive
>
> Signed-off-by: Stefan Priebe <s.priebe at profihost.ag>
> ---
> API2/Nodes.pm | 48
> ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
>
> diff --git a/API2/Nodes.pm b/API2/Nodes.pm index 0dac6af..ee351c3 100644
> --- a/API2/Nodes.pm
> +++ b/API2/Nodes.pm
> @@ -123,6 +123,7 @@ __PACKAGE__->register_method ({
> { name => 'aplinfo' },
> { name => 'startall' },
> { name => 'stopall' },
> + { name => 'netstat' },
> ];
>
> return $result;
> @@ -273,6 +274,53 @@ __PACKAGE__->register_method({
> }});
>
> __PACKAGE__->register_method({
> + name => 'netstat',
> + path => 'netstat',
> + method => 'GET',
> + permissions => {
> + check => ['perm', '/nodes/{node}', [ 'Sys.Audit' ]],
> + },
> + description => "Read tap/vm network device interface counters",
> + proxyto => 'node',
> + parameters => {
> + additionalProperties => 0,
> + properties => {
> + node => get_standard_option('pve-node'),
> + },
> + },
> + returns => {
> + type => "array",
> + items => {
> + type => "object",
> + properties => {},
> + },
> + },
> + code => sub {
> + my ($param) = @_;
> +
> + my $res = [ ];
> +
> + 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;
> +
> + push(
> + @$res,
> + {
> + vmid => $vmid,
> + dev => "net$netid",
> + in => $netdev->{$dev}->{transmit},
> + out => $netdev->{$dev}->{receive},
> + }
> + );
> + }
> +
> + return $res;
> + }});
> +
> +__PACKAGE__->register_method({
> name => 'node_cmd',
> path => 'status',
> method => 'POST',
> --
> 1.7.10.4
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list