[pve-devel] host cpu stats: read_proc_stat "used" value don't count all needed fields

DERUMIER, Alexandre Alexandre.DERUMIER at groupe-cyllene.com
Thu Jan 6 10:57:23 CET 2022


I'm currently comparing the proxmox rrd stats with my other monitoring
and I still have some missing cpu% in proxmox graphs.

I see that dominic have added missing parsed field recently (but only
for external metric server)


The current code only use
   $res->{user} = $1;
   $res->{nice} = $2;
   $res->{system} = $3;

(so missing at least irq && softirq,  in my production server it can be
around 5%)

I found some discussion about correct compute of usage here:

also pointing to htop source code

Also, to compute the total diff, we use

    my $diff = ($ctime - $last_proc_stat->{ctime}) * $clock_ticks *

Seem to be correct (Not sure about different freq scaling by cores) ,
but maybe reusing /proc/stats values could be more accurate ?   (we
could also compute value for each separate core for example).

from htop:

  // Guest time is already accounted in usertime
      usertime = usertime - guest;
      nicetime = nicetime - guestnice;
      // Fields existing on kernels >= 2.6
      // (and RHEL's patched kernel 2.4...)
      unsigned long long int idlealltime = idletime + ioWait;
      unsigned long long int systemalltime = systemtime + irq +
      unsigned long long int virtalltime = guest + guestnice;
      unsigned long long int totaltime = usertime + nicetime +
systemalltime + idlealltime + steal + virtalltime;

I'll try to implement this logic, and see the difference vs the current
used value.

More information about the pve-devel mailing list