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; }