proxmox/proxmox-sys
Thomas Lamprecht cfae8ae3d2 linux/procfs: add read_proc_stat
For now we just parse the CPU "time-spent" counters and calculate the
CPU usage of the whole system. As we do not want a total average we
use a state-full implementation, which calculates the usage since the
last request (if older than 1 second).

Somewhat modeled after our Perl version of this. But for the "total"
we do not use the:
> ($ctime - $last_proc_stat->{ctime}) * $clock_ticks * $cpucount;
calculation, but just add _all_ fields together, as that is the total
of CPU time.

Use a Reader-Writer lock to sync updating. First check under the
reader lock if the data is recent enough, else update it under the
writer lock.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-12-18 17:00:51 +01:00
..
src linux/procfs: add read_proc_stat 2019-12-18 17:00:51 +01:00
Cargo.toml sys: get rid of Regex dependency 2019-11-13 14:49:11 +01:00