mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-09 14:37:56 +00:00
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@profihost.ag>
This commit is contained in:
parent
6735c379f5
commit
0455911df1
@ -124,6 +124,7 @@ __PACKAGE__->register_method ({
|
|||||||
{ name => 'aplinfo' },
|
{ name => 'aplinfo' },
|
||||||
{ name => 'startall' },
|
{ name => 'startall' },
|
||||||
{ name => 'stopall' },
|
{ name => 'stopall' },
|
||||||
|
{ name => 'netstat' },
|
||||||
];
|
];
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -273,6 +274,53 @@ __PACKAGE__->register_method({
|
|||||||
return $res;
|
return $res;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
__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({
|
__PACKAGE__->register_method({
|
||||||
name => 'node_cmd',
|
name => 'node_cmd',
|
||||||
path => 'status',
|
path => 'status',
|
||||||
|
Loading…
Reference in New Issue
Block a user