proxmox/proxmox-sys/src
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
..
linux linux/procfs: add read_proc_stat 2019-12-18 17:00:51 +01:00
lib.rs cargo fmt --all 2019-06-12 09:48:30 +02:00
linux.rs src/linux/procfs.rs: moved from proxmox-backup 2019-08-03 16:19:11 +02:00