read new /proc/pressure/(cpu,disk,io) introduced in kernel 4.20.
This give more granular informations than loadaverage.
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
return wantarray ? (0, 0, 0) : 0;
}
return wantarray ? (0, 0, 0) : 0;
}
+sub read_pressure {
+
+ my $res = {};
+ foreach my $type (qw(cpu memory io)) {
+ if (my $fh = IO::File->new ("/proc/pressure/$type", "r")) {
+ while (defined (my $line = <$fh>)) {
+ if ($line =~ /^(some|full)\s+avg10\=(\d+\.\d+)\s+avg60\=(\d+\.\d+)\s+avg300\=(\d+\.\d+)\s+total\=(\d+)/) {
+ $res->{$type}->{$1}->{avg10} = $2;
+ $res->{$type}->{$1}->{avg60} = $3;
+ $res->{$type}->{$1}->{avg300} = $4;
+ }
+ }
+ $fh->close;
+ }
+ }
+ return $res;
+}
+
my $last_proc_stat;
sub read_proc_stat {
my $last_proc_stat;
sub read_proc_stat {