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 4EBCB1FF13B for ; Wed, 25 Mar 2026 22:42:51 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 39961365E6; Wed, 25 Mar 2026 22:43:10 +0100 (CET) Message-ID: <2204e330-7a13-4c8b-9b83-2f9c783dcf51@proxmox.com> Date: Wed, 25 Mar 2026 22:43:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH ha-manager v2 20/40] env: pve2: implement dynamic node and service stats To: Daniel Kral , pve-devel@lists.proxmox.com References: <20260324183029.1274972-1-d.kral@proxmox.com> <20260324183029.1274972-21-d.kral@proxmox.com> Content-Language: en-US From: Thomas Lamprecht In-Reply-To: <20260324183029.1274972-21-d.kral@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774474937926 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.011 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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: TZPLHP4UEEBGAX7L7GJE7AVE5XBGPUU6 X-Message-ID-Hash: TZPLHP4UEEBGAX7L7GJE7AVE5XBGPUU6 X-MailFrom: t.lamprecht@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: Am 24.03.26 um 19:31 schrieb Daniel Kral: > Fetch the dynamic node and service stats with rrd_dump(), which is > periodically sampled and broadcasted by the PVE nodes' pvestatd service > and propagated through the pmxcfs. one small code issue inline that can be fixed up too on applying if nothing else comes up. > > Signed-off-by: Daniel Kral > --- > changes v1 -> v2: > - use constants for the RRD entry indices > - add note about the capping of the maxcpu property for guests > > src/PVE/HA/Env/PVE2.pm | 63 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 63 insertions(+) > > diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm > index 04cd1bfe..4dfb304e 100644 > --- a/src/PVE/HA/Env/PVE2.pm > +++ b/src/PVE/HA/Env/PVE2.pm > @@ -569,6 +582,30 @@ sub get_static_service_stats { > return $stats; > } > > +sub get_dynamic_service_stats { > + my ($self, $id) = @_; this $id param is not directly used and no calling site passes any such param, and it's also shadowed by the one inside the loop below. > + > + 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"} // []; > + > + # NOTE the guests' broadcasted vmstatus() caps maxcpu at the node's maxcpu > + my $maxcpu = ($rrdentry->[RRD_VM_INDEX_MAXCPU] || 0.0) + 0.0; > + > + $stats->{$sid}->{usage} = { > + maxcpu => $maxcpu, > + cpu => (($rrdentry->[RRD_VM_INDEX_CPU] || 0.0) + 0.0) * $maxcpu, > + maxmem => int($rrdentry->[RRD_VM_INDEX_MAXMEM] || 0), > + mem => int($rrdentry->[RRD_VM_INDEX_MEM] || 0), > + }; > + } > + > + return $stats; > +} > + > sub get_static_node_stats { > my ($self) = @_; >