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
Wolfgang Bumiller
6cf330c9d2
add tools::parse submodule, move hex_nibble to it
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-11-14 09:59:04 +01:00
Wolfgang Bumiller
db83a675f0
sys: get rid of Regex dependency
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-11-13 14:49:11 +01:00
Wolfgang Bumiller
b294fb1314
sys: add read_proc_pid_stat test
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-11-13 14:49:11 +01:00
Wolfgang Bumiller
a11f6e88f8
[clippy] sys: simplifications and optimizations
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-22 09:28:44 +02:00
Wolfgang Bumiller
45b5839e7e
replace std::mem::uninitialized
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 16:49:12 +02:00
Wolfgang Bumiller
aadb47a292
update nix to 0.15 for mkdirat
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-21 11:51:45 +02:00
Wolfgang Bumiller
ccce46eba4
formatting fixup
...
make fmt
(cargo fmt --all)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 14:14:23 +02:00
Wolfgang Bumiller
863a16a5bc
whitespace cleanup
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 14:13:37 +02:00
Wolfgang Bumiller
4c9a8b5c88
cleanup use statements
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 14:12:49 +02:00
Wolfgang Bumiller
f074a9e60b
cleanup Cargo.toml files
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 14:09:54 +02:00
Wolfgang Bumiller
1f11c4adf9
sys: rustfmt workaround
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-08-05 12:46:21 +02:00
Dietmar Maurer
d6d65be42e
add nodename helper (copied from proxmox-backup)
2019-08-03 17:00:02 +02:00
Dietmar Maurer
ce18d8c035
src/linux/procfs.rs: moved from proxmox-backup
2019-08-03 16:19:11 +02:00
Dietmar Maurer
909520d191
add src/linux/magic.rs - moved from proxmox-backup
2019-08-03 09:19:32 +02:00
Wolfgang Bumiller
024930f63c
cargo fmt --all
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Dietmar Maurer
71f2d48c2e
start proxmox-sys module
2019-06-07 18:03:07 +02:00