* [pmg-devel] [RFC pve-common] procfs tools: handle proc/stat without guest values
@ 2022-04-22 8:15 Fabian Ebner
2022-04-25 7:44 ` Fabian Ebner
2022-06-14 8:28 ` [pmg-devel] applied: " Fabian Ebner
0 siblings, 2 replies; 4+ messages in thread
From: Fabian Ebner @ 2022-04-22 8:15 UTC (permalink / raw)
To: pmg-devel
PMG is often run as a container, and in certain environments
(Parallels?), the last two values (guest and guest_nice) might not be
present. This led to a division by zero, because the total value was
never updated.
Reported in the community forum:
https://forum.proxmox.com/threads/106896/
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
src/PVE/ProcFSTools.pm | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm
index 88df5d2..d636427 100644
--- a/src/PVE/ProcFSTools.pm
+++ b/src/PVE/ProcFSTools.pm
@@ -168,9 +168,9 @@ sub read_proc_stat {
if (my $fh = IO::File->new ("/proc/stat", "r")) {
while (defined (my $line = <$fh>)) {
- if ($line =~ m|^cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)|) {
- $res->{user} = $1 - $9;
- $res->{nice} = $2 - $10;
+ if ($line =~ m|^cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)(?:\s+(\d+)\s+(\d+))?|) {
+ $res->{user} = $1 - ($9 // 0);
+ $res->{nice} = $2 - ($10 // 0);
$res->{system} = $3;
$res->{idle} = $4;
$res->{used} = $1+$2+$3+$6+$7+$8;
@@ -178,8 +178,8 @@ sub read_proc_stat {
$res->{irq} = $6;
$res->{softirq} = $7;
$res->{steal} = $8;
- $res->{guest} = $9;
- $res->{guest_nice} = $10;
+ $res->{guest} = $9 // 0;
+ $res->{guest_nice} = $10 // 0;
} elsif ($line =~ m|^cpu\d+\s|) {
$cpucount++;
}
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pmg-devel] [RFC pve-common] procfs tools: handle proc/stat without guest values
2022-04-22 8:15 [pmg-devel] [RFC pve-common] procfs tools: handle proc/stat without guest values Fabian Ebner
@ 2022-04-25 7:44 ` Fabian Ebner
2022-06-14 7:44 ` Wolfgang Bumiller
2022-06-14 8:28 ` [pmg-devel] applied: " Fabian Ebner
1 sibling, 1 reply; 4+ messages in thread
From: Fabian Ebner @ 2022-04-25 7:44 UTC (permalink / raw)
To: pmg-devel
Am 22.04.22 um 10:15 schrieb Fabian Ebner:
> PMG is often run as a container, and in certain environments
> (Parallels?), the last two values (guest and guest_nice) might not be
"(Parallels?)" should be replaced with "(like Virtuozzo 7)" in the
commit message.
Quoting from https://forum.proxmox.com/threads/106896/post-466350 :
> The kernel running below the Container is using Virtuozzo 7 with Kernel 3.10.0.
> On the Hostnode all 10 Digits are reachable. Only in the Container they are missing.
> The Patch you have sent to the mailing list is working. Now the error doesn't occurs any more.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pmg-devel] [RFC pve-common] procfs tools: handle proc/stat without guest values
2022-04-25 7:44 ` Fabian Ebner
@ 2022-06-14 7:44 ` Wolfgang Bumiller
0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Bumiller @ 2022-06-14 7:44 UTC (permalink / raw)
To: Fabian Ebner; +Cc: pmg-devel
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
On Mon, Apr 25, 2022 at 09:44:50AM +0200, Fabian Ebner wrote:
> Am 22.04.22 um 10:15 schrieb Fabian Ebner:
> > PMG is often run as a container, and in certain environments
> > (Parallels?), the last two values (guest and guest_nice) might not be
>
> "(Parallels?)" should be replaced with "(like Virtuozzo 7)" in the
> commit message.
can you fixup the message & push?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pmg-devel] applied: [RFC pve-common] procfs tools: handle proc/stat without guest values
2022-04-22 8:15 [pmg-devel] [RFC pve-common] procfs tools: handle proc/stat without guest values Fabian Ebner
2022-04-25 7:44 ` Fabian Ebner
@ 2022-06-14 8:28 ` Fabian Ebner
1 sibling, 0 replies; 4+ messages in thread
From: Fabian Ebner @ 2022-06-14 8:28 UTC (permalink / raw)
To: pmg-devel
Am 22.04.22 um 10:15 schrieb Fabian Ebner:
> PMG is often run as a container, and in certain environments
> (Parallels?), the last two values (guest and guest_nice) might not be
> present. This led to a division by zero, because the total value was
> never updated.
>
> Reported in the community forum:
> https://forum.proxmox.com/threads/106896/
>
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
applied, with updated commit message and Wolfang's A-B
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-14 8:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 8:15 [pmg-devel] [RFC pve-common] procfs tools: handle proc/stat without guest values Fabian Ebner
2022-04-25 7:44 ` Fabian Ebner
2022-06-14 7:44 ` Wolfgang Bumiller
2022-06-14 8:28 ` [pmg-devel] applied: " Fabian Ebner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox