pve-common now allows arbitrary names for physical interfaces, without being restricted by PHYSICAL_NIC_RE. In order to detect physical interfaces, pvestatd now needs to query 'ip link' for the type of an interface instead of relying on the regular expression.
On the receiving end, PullMetric cannot consult 'ip link' for determining which interface is physical or not. To work around that, introduce a new type key, that carries information about the type of an interface. When aggregating the metrics, PullMetric can now read this additional parameter, to infer the type of the interface. For now we only set the type for physical interfaces, otherwise to unknown. Signed-off-by: Stefan Hanreich <s.hanre...@proxmox.com> --- PVE/PullMetric.pm | 15 ++++++++++++--- PVE/Service/pvestatd.pm | 13 ++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/PVE/PullMetric.pm b/PVE/PullMetric.pm index f55653505..24310c30e 100644 --- a/PVE/PullMetric.pm +++ b/PVE/PullMetric.pm @@ -91,9 +91,18 @@ my sub get_node_metrics { push @$metrics, gauge($id, $timestamp, "uptime", $data->{uptime}); my ($netin, $netout) = (0, 0); - for my $dev (grep { /^$PVE::Network::PHYSICAL_NIC_RE$/ } keys $data->{nics}->%*) { - $netin += $data->{nics}->{$dev}->{receive}; - $netout += $data->{nics}->{$dev}->{transmit}; + + for my $dev (keys $data->{nics}->%*) { + my $nic_data = $data->{nics}->{$dev}; + + if ($nic_data->{type}) { + next if $nic_data->{type} ne 'physical'; + } else { + next if $dev !~ /^$PVE::Network::PHYSICAL_NIC_RE$/; + } + + $netin += $nic_data->{receive}; + $netout += $nic_data->{transmit}; } push @$metrics, derive($id, $timestamp, "net_in", $netin); push @$metrics, derive($id, $timestamp, "net_out", $netout); diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm index e645eec3c..c91adeca8 100755 --- a/PVE/Service/pvestatd.pm +++ b/PVE/Service/pvestatd.pm @@ -171,9 +171,20 @@ sub update_node_status { my $sublevel = $subinfo->{level} || ''; my $netdev = PVE::ProcFSTools::read_proc_net_dev(); + my $ip_links = PVE::Network::ip_link_details(); + # traffic from/to physical interface cards my ($netin, $netout) = (0, 0); - for my $dev (grep { /^$PVE::Network::PHYSICAL_NIC_RE$/ } keys %$netdev) { + for my $dev (keys %$netdev) { + my $ip_link = $ip_links->{$dev}; + + if (PVE::Network::ip_link_is_physical($ip_link)) { + $netdev->{$dev}->{type} = 'physical'; + } else { + $netdev->{$dev}->{type} = 'unknown'; + next; + } + $netin += $netdev->{$dev}->{receive}; $netout += $netdev->{$dev}->{transmit}; } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel