all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH common v2] ProcFSTools: read_proc_stat: add more cpu stats from /proc/stat
@ 2021-07-28 12:12 Dominik Csapak
  2021-07-29  8:31 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2021-07-28 12:12 UTC (permalink / raw)
  To: pve-devel

those fields might be interesting to users. At the moment, this is
only used in the external metrics export.

These fields exist in the kernel since:
* irq - 2.6.0
* softirq - 2.6.0
* steal - 2.6.11
* guest - 2.6.24
* guest_nice - 2.6.33

so they must all exist

also add a 'total' field which simply sums up the (non-guest) fields

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* made the new fields non-optional (new kernel is a hard req.)
* added a new 'total' field which is the same as in pbs

 src/PVE/ProcFSTools.pm | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm
index ff30e4b..a75274a 100644
--- a/src/PVE/ProcFSTools.pm
+++ b/src/PVE/ProcFSTools.pm
@@ -168,13 +168,18 @@ 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|) {
+	    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;
 		$res->{nice} = $2;
 		$res->{system} = $3;
 		$res->{idle} = $4;
 		$res->{used} = $1+$2+$3;
 		$res->{iowait} = $5;
+		$res->{irq} = $6;
+		$res->{softirq} = $7;
+		$res->{steal} = $8;
+		$res->{guest} = $9;
+		$res->{guest_nice} = $10;
 	    } elsif ($line =~ m|^cpu\d+\s|) {
 		$cpucount++;
 	    }
@@ -186,6 +191,16 @@ sub read_proc_stat {
 
     my $ctime = gettimeofday; # floating point time in seconds
 
+    # the sum of all (non-guest) fields
+    $res->{total} = $res->{user}
+	+ $res->{nice}
+	+ $res->{system}
+	+ $res->{iowait}
+	+ $res->{irq}
+	+ $res->{softirq}
+	+ $res->{steal}
+	+ $res->{idle};
+
     $res->{ctime} = $ctime;
     $res->{cpu} = 0;
     $res->{wait} = 0;
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: Re: [PATCH common v2] ProcFSTools: read_proc_stat: add more cpu stats from /proc/stat
  2021-07-28 12:12 [pve-devel] [PATCH common v2] ProcFSTools: read_proc_stat: add more cpu stats from /proc/stat Dominik Csapak
@ 2021-07-29  8:31 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2021-07-29  8:31 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 28/07/2021 14:12, Dominik Csapak wrote:
> those fields might be interesting to users. At the moment, this is
> only used in the external metrics export.
> 
> These fields exist in the kernel since:
> * irq - 2.6.0
> * softirq - 2.6.0
> * steal - 2.6.11
> * guest - 2.6.24
> * guest_nice - 2.6.33
> 
> so they must all exist
> 
> also add a 'total' field which simply sums up the (non-guest) fields
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> changes from v1:
> * made the new fields non-optional (new kernel is a hard req.)
> * added a new 'total' field which is the same as in pbs
> 
>  src/PVE/ProcFSTools.pm | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-29  8:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-28 12:12 [pve-devel] [PATCH common v2] ProcFSTools: read_proc_stat: add more cpu stats from /proc/stat Dominik Csapak
2021-07-29  8:31 ` [pve-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal