From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 1D8A71FF146 for ; Tue, 07 Jul 2026 12:56:28 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 108C521476; Tue, 07 Jul 2026 12:56:19 +0200 (CEST) From: Jakob Klocker To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 2/2] fix #7198: metric collection: count veth uplink when running in a container Date: Tue, 7 Jul 2026 12:56:01 +0200 Message-ID: <20260707105601.309299-3-j.klocker@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260707105601.309299-1-j.klocker@proxmox.com> References: <20260707105601.309299-1-j.klocker@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 2 AWL -0.326 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 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 Message-ID-Hash: IQNASTB5B557ZJXT3IMQ7VAFDALFX3BK X-Message-ID-Hash: IQNASTB5B557ZJXT3IMQ7VAFDALFX3BK X-MailFrom: jklocker@dev.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jakob Klocker X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When PBS runs inside an LXC container, the network uplink is one end of a veth pair rather than a physical NIC, so is_physical() returns false and the interface is excluded from network utilization stats unless its name happens to match PHYSICAL_NIC_REGEX. This drops graph data for interfaces with custom names (e.g. wan0). Check whether we are running in a container (via /run/systemd/container, cached in a OnceLock) and, if so, also count veth interfaces as physical for metric collection. This mirrors how a VM's NIC is already counted. Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7198 Signed-off-by: Jakob Klocker --- src/server/metric_collection/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server/metric_collection/mod.rs b/src/server/metric_collection/mod.rs index 18625b1a5..47882eb89 100644 --- a/src/server/metric_collection/mod.rs +++ b/src/server/metric_collection/mod.rs @@ -148,6 +148,11 @@ impl NetdevStat { } static NETWORK_INTERFACE_CACHE: OnceLock> = OnceLock::new(); +static IN_CONTAINER_CACHE: OnceLock = OnceLock::new(); + +fn running_in_container() -> bool { + Path::new("/run/systemd/container").exists() +} fn collect_netdev_stats() -> Option> { use proxmox_sys::linux::procfs::read_proc_net_dev; @@ -175,10 +180,11 @@ fn collect_netdev_stats() -> Option> { }; let mut stat_devs = Vec::with_capacity(net_devs.len()); + let in_container = *IN_CONTAINER_CACHE.get_or_init(running_in_container); for net_dev in net_devs { if let Some(ip_link) = ip_links.get(&net_dev.device) { - let ty = if ip_link.is_physical() { + let ty = if ip_link.is_physical() || (in_container && ip_link.is_veth()) { NetdevType::Physical } else { NetdevType::Virtual -- 2.47.3