]> git.proxmox.com Git - pve-common.git/commitdiff
memory info: avoid errors if ZFS arc stat cannot be read
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 17 Apr 2023 14:14:14 +0000 (16:14 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 26 Apr 2023 10:20:33 +0000 (12:20 +0200)
E.g., if used in PMG and running on a kernel without ZFS.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/ProcFSTools.pm

index 0686c348fb6dc04e676cf03ed5dcbcb4222eaf3d..43ba49030aad9b232fca9914926c145fc20d28f7 100644 (file)
@@ -308,9 +308,9 @@ sub read_meminfo {
     my $spages = PVE::Tools::file_read_firstline("/sys/kernel/mm/ksm/pages_sharing") // 0 ;
     $res->{memshared} = int($spages) * 4096;
 
-    my $arcstats = PVE::Tools::file_get_contents("/proc/spl/kstat/zfs/arcstats");
-    if ($arcstats && $arcstats =~ m/size\s+\d+\s+(\d+)/m) {
-       $res->{arcsize} = int ($1);
+    my $arc_stats = eval { PVE::Tools::file_get_contents("/proc/spl/kstat/zfs/arcstats") };
+    if ($arc_stats && $arc_stats =~ m/size\s+\d+\s+(\d+)/m) {
+       $res->{arcsize} = int($1);
     }
 
     return $res;