[pve-devel] [PATCH container] fix #4765: pct: do not report cpu usage

Maximiliano Sandoval m.sandoval at proxmox.com
Thu Jun 29 13:34:23 CEST 2023


When running `pct status VMID` the variable
$last_proc_vmid_stat->{$vmid} is not set and pct reports no cpu usage.

For consistency with the qt command we do not print the cpu usage.

Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---

This is a different approach that the one tried at
https://lists.proxmox.com/pipermail/pve-devel/2023-June/057771.html.

While we could run the computation twice after a time delta to get *a* number
there are many open questions, like how would a user interpret this value, and
how is this time delta going to be documented, etc.

 src/PVE/CLI/pct.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index ff75d33..a0b9bce 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -67,6 +67,7 @@ __PACKAGE__->register_method ({
 	    foreach my $k (sort (keys %$stat)) {
 		my $v = $stat->{$k};
 		next if !defined($v);
+		next if $k eq 'cpu';
 		print "$k: $v\n";
 	    }
 	} else {
-- 
2.39.2






More information about the pve-devel mailing list