Build precise queries to find exactly what you need
Press ESC to close
I like this little script because it does not ‘use’ things I don’t already have installed. In fact, it only ‘use strict’. The script is a few years old, so I’ve updated it for the latest ‘zpool list’ output from Ubuntu 16.04 0.6.5.6-0ubuntu10 / ZFS on Linux zfs-0.6.5.6 . The diff is below:
$ diff -Nurp check_zfs.2 check_zfs.0 — check_zfs.2 2016-07-11 17:10:43.981148057 -0400 +++ check_zfs.0 2016-07-11 16:11:33.460956749 -0400 @@ -61,14 +61,12 @@ if ($#ARGV+1 != 2) { my $pool=$ARGV[0]; my $verbose=$ARGV[1];
-my $size=””; # SIZE -my $used=””; # ALLOC -my $avail=””; # FREE -my $sizex=””; # EXPANDSZ -my $frag=””; # FRAG -my $cap=””; # CAP -my $dedup=””; # DEDUP -my $health=””; # HEALTH +my $size=””; +my $used=””; +my $avail=””; +my $cap=””; +my $dedup=””; +my $health=””; my $dmge=””;
if ($verbose 3) { @@ -77,30 +75,19 @@ if ($verbose 3) { }
my $statcommand=”zpool list $pool”; -# my $statcommand=”zpool list -o ‘name,size,alloc,free,cap,dedup,health,altroot'”;
if (! open STAT, “$statcommand|”) { print (“$state ‘$statcommand’ command returns no result! NOTE: This plugin needs OS support for ZFS, and execution with root privileges.n”); exit $ERRORS{$state}; }
-# NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT -# rpool 9.94G 718M 9.24G – 6% 7% 1.00x ONLINE – – while() { chomp; – NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT – next if (/^NAMEs+SIZEs+ALLOCs+FREEs+EXPANDSZs+FRAGs+CAPs+DEDUPs+HEALTHs+ALTROOT/); + NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT + next if (/^NAMEs+SIZEs+ALLOCs+FREEs+CAPs+DEDUPs+HEALTHs+ALTROOT/); if (/^${pool}s+/) { – ($size, $used, $avail, $sizex, $frag, $cap, $dedup, $health) = – /^${pool}s+(S+)s+(S+)s+(S+)s+(S+)s+(S+)s+(S+)s+(S+)s+(S+)/; + ($size, $used, $avail, $cap, $dedup, $health) = /^${pool}s+(S+)s+(S+)s+(S+)s+(S+)s+(S+)s+(S+)/; } – -# NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT -# next if (/^NAMEs+SIZEs+ALLOCs+FREEs+CAPs+DEDUPs+HEALTHs+ALTROOT/); -# if (/^${pool}s+/) { -# ($size, $used, $avail, $cap, $dedup, $health) = /^${pool}s+(S+)s+(S+)s+(S+)s+(S+)s+(S+)s+(S+)/; -# } }
close(STAT); @@ -218,6 +205,6 @@ while() {
## calling all goats!
-$msg = sprintf “ZPOOL %s : %s {Size:%s Used:%s Avail:%s Expand:%s Frag:%s Cap:%s Dedup:%s} %sn”, $pool, $health, $size, $used, $avail, $sizex, $frag, $cap, $dedup, $dmge; +$msg = sprintf “ZPOOL %s : %s {Size:%s Used:%s Avail:%s Cap:%s} %sn”, $pool, $health, $size, $used, $avail, $cap, $dmge; print $state, ” “, $msg; exit ($ERRORS{$state});
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!