From cfdd92b9c67e1de0c18ac0ee8edec0f59b0b730e Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 16 Dec 2021 16:46:43 +0100 Subject: [PATCH] Fix zpool iostat as /proc/spl/kstat/zfs/pool/io doesn't exist anymore --- zabbix_scripts/check_zfs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/zabbix_scripts/check_zfs b/zabbix_scripts/check_zfs index 4e00045..742ea26 100644 --- a/zabbix_scripts/check_zfs +++ b/zabbix_scripts/check_zfs @@ -163,13 +163,20 @@ sub convert_suffix { sub get_zpool_stats { my $pool = shift; my $stats = {}; - return $stats unless (-e "/proc/spl/kstat/zfs/$pool/io"); - open STAT, "){ - if (m/^(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)/){ - $stats->{$_} = $+{$_} foreach (keys %+); + open UPTIME, "; + chomp; + my ($uptime , undef) = split; + $uptime = int $uptime; + close UPTIME; + foreach my $line (qx($zpool iostat $pool -pH)){ + if ($line =~ m/^$pool\s+\d+\s+\d+\s+(?\d+)\s+(?\d+)\s+(?\d+)\s+(?\d+)/){ + # zpool iostat shows average IO since boot, so just multiply it + # by the uptime in seconds to get cumulated IO since boot + # Zabbix server will then be able to calculate the delta between two values + $stats->{$_} = $+{$_} * $uptime foreach (keys %+); + last; } } - close STAT; return $stats; }