From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id BA2431FF170 for ; Thu, 24 Jul 2025 16:49:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 00C2A3E3F6; Thu, 24 Jul 2025 16:50:40 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Date: Thu, 24 Jul 2025 16:49:58 +0200 Message-Id: <20250724144959.374061-3-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250724144959.374061-1-s.hanreich@proxmox.com> References: <20250724144959.374061-1-s.hanreich@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.195 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH pve-manager 1/2] pvestatd: pull metric: use ip link to detect physical interfaces X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" 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 --- 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