From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 44B851FF137 for ; Tue, 17 Feb 2026 15:16:24 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5F08F3B0B; Tue, 17 Feb 2026 15:15:27 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [RFC ha-manager 12/21] env: pve2: implement dynamic node and service stats Date: Tue, 17 Feb 2026 15:14:19 +0100 Message-ID: <20260217141437.584852-26-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260217141437.584852-1-d.kral@proxmox.com> References: <20260217141437.584852-1-d.kral@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1771337677870 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.981 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_MAILER 2 Automated Mailer Tag Left in Email SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: TGKS37NTEZIAEQYQ4QPI6RT4VKEZMNXW X-Message-ID-Hash: TGKS37NTEZIAEQYQ4QPI6RT4VKEZMNXW X-MailFrom: d.kral@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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Fetch dynamic node and service stats from the rrd_dump() propagated through the pmxcfs periodically. Signed-off-by: Daniel Kral --- src/PVE/HA/Env/PVE2.pm | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm index d5c20460..bb0d8c74 100644 --- a/src/PVE/HA/Env/PVE2.pm +++ b/src/PVE/HA/Env/PVE2.pm @@ -559,6 +559,30 @@ sub get_static_service_stats { return $stats; } +sub get_dynamic_service_stats { + my ($self, $id) = @_; + + my $rrd = PVE::Cluster::rrd_dump(); + + my $stats = get_cluster_service_stats(); + for my $sid (keys %$stats) { + my $id = $stats->{$sid}->{id}; + my $rrdentry = $rrd->{"pve-vm-9.0/$id"} // []; + + # FIXME $rrdentry->[5] is the problematic $d->{cpus} from vmstatus + my $maxcpu = ($rrdentry->[5] || 0.0) + 0.0; + + $stats->{$sid}->{usage} = { + maxcpu => $maxcpu, + cpu => (($rrdentry->[6] || 0.0) + 0.0) * $maxcpu, + maxmem => int($rrdentry->[7] || 0), + mem => int($rrdentry->[8] || 0), + }; + } + + return $stats; +} + sub get_static_node_stats { my ($self) = @_; @@ -578,6 +602,32 @@ sub get_static_node_stats { return $stats; } +sub get_dynamic_node_stats { + my ($self) = @_; + + my $rrd = PVE::Cluster::rrd_dump(); + + my $stats = {}; + for my $key (keys %$rrd) { + my ($nodename) = $key =~ m/^pve-node-9.0\/(\w+)$/; + + next if !$nodename; + + my $rrdentry = $rrd->{$key} // []; + + my $maxcpu = int($rrdentry->[4] || 0); + + $stats->{$nodename} = { + maxcpu => $maxcpu, + cpu => (($rrdentry->[5] || 0.0) + 0.0) * $maxcpu, + maxmem => int($rrdentry->[7] || 0), + mem => int($rrdentry->[8] || 0), + }; + } + + return $stats; +} + sub get_node_version { my ($self, $node) = @_; -- 2.47.3