]> git.proxmox.com Git - pve-common.git/commitdiff
ProcFSTools: add read_pressure
authorAlexandre Derumier <aderumier@odiso.com>
Tue, 6 Oct 2020 11:58:39 +0000 (13:58 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 13 Oct 2020 05:32:42 +0000 (07:32 +0200)
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>
src/PVE/ProcFSTools.pm

index 7cf14721c2f2bb872ae41ae301a3d6a095826c26..7687c13c4e30b9d483ebb624c8d522ca8a74ca3d 100644 (file)
@@ -132,6 +132,24 @@ sub read_loadavg {
     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 {