* [pve-devel] host cpu stats: read_proc_stat "used" value don't count all needed fields
@ 2022-01-06 9:57 DERUMIER, Alexandre
0 siblings, 0 replies; only message in thread
From: DERUMIER, Alexandre @ 2022-01-06 9:57 UTC (permalink / raw)
To: pve-devel
Hi,
I'm currently comparing the proxmox rrd stats with my other monitoring
tools,
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)
https://git.proxmox.com/?p=pve-
common.git;a=blobdiff;f=src/PVE/ProcFSTools.pm;h=a75274a9faf03130c41376
ec329a07098c4a58c6;hp=ff30e4bfaf8df985cb1d667777363451dd0ad606;hb=5a82e
b712e4c879a271686f07c589fadc0b09185;hpb=576dadb1379da130f4ea77f775ea9bb
985419616
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:
https://stackoverflow.com/questions/23367857/accurate-calculation-of-cpu-usage-given-in-percentage-in-linux
also pointing to htop source code
https://github.com/htop-dev/htop/blob/15652e7b8102e86b3405254405d8ee5d2a239004/linux/LinuxProcessList.c
Also, to compute the total diff, we use
my $diff = ($ctime - $last_proc_stat->{ctime}) * $clock_ticks *
$cpucount;
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 +
softIrq;
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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-06 9:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06 9:57 [pve-devel] host cpu stats: read_proc_stat "used" value don't count all needed fields DERUMIER, Alexandre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox