Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

check_zfs_linux

Current Version
0.9.3
Last Release Date
2013-08-21
Compatible With
  • Nagios 3.x
Owner
Hits
33304
Files:
FileDescription
check_zfscheck_zfs perl script
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
Monitor ZFS pools on Linux.
This plugin was adopted from check_zfs for Solaris (http://exchange.nagios.org/directory/Plugins/Operating-Systems/Solaris/check_zfs/details) to run on Linux with ZFS-on-Linux (http://zfsonlinux.org) installed.

It has been tested on CentOS 6.4 so far.
Reviews (1)
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 (/^NAME\s+SIZE\s+ALLOC\s+FREE\s+EXPANDSZ\s+FRAG\s+CAP\s+DEDUP\s+HEALTH\s+ALTROOT/);
+ NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
+ next if (/^NAME\s+SIZE\s+ALLOC\s+FREE\s+CAP\s+DEDUP\s+HEALTH\s+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 (/^NAME\s+SIZE\s+ALLOC\s+FREE\s+CAP\s+DEDUP\s+HEALTH\s+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} %s\n", $pool, $health, $size, $used, $avail, $sizex, $frag, $cap, $dedup, $dmge;
+$msg = sprintf "ZPOOL %s : %s {Size:%s Used:%s Avail:%s Cap:%s} %s\n", $pool, $health, $size, $used, $avail, $cap, $dmge;
print $state, " ", $msg;
exit ($ERRORS{$state});