Module: check_mk
Branch: master
Commit: 27f3b0777d06d7a0037e8868347b2332ef9e5412
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=27f3b0777d06d7…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Tue Mar 15 14:24:34 2016 +0100
3101 zpool: new check to monitor usage of zfs pools
There is already a check (zfsget) to monitor usage of zfs mountpoints, but in complex
setups where
the pools don't map 1:1 to mountpoints, the existing check doesn't give a correct
picture of the
underlying pools.
---
.werks/3101 | 11 +++++++
ChangeLog | 1 +
agents/check_mk_agent.solaris | 3 ++
checkman/zpool | 16 +++++++++
checks/zpool | 72 +++++++++++++++++++++++++++++++++++++++++
5 files changed, 103 insertions(+)
diff --git a/.werks/3101 b/.werks/3101
new file mode 100644
index 0000000..c41d185
--- /dev/null
+++ b/.werks/3101
@@ -0,0 +1,11 @@
+Title: zpool: new check to monitor usage of zfs pools
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1458048130
+Class: feature
+
+There is already a check (zfsget) to monitor usage of zfs mountpoints, but in complex
setups where
+the pools don't map 1:1 to mountpoints, the existing check doesn't give a correct
picture of the
+underlying pools.
diff --git a/ChangeLog b/ChangeLog
index d82beae..974f177 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,7 @@
* 3004 agent_vsphere: now able to configure used piggyback name for
virtualmachines...
* 3095 prism_info, prism_containers, prism_alerts: added checks to monitor a Nutanix
Prism cluster
* 3096 check_mailboxes: new active check to monitor age and count of mails in imap
mailboxes
+ * 3101 zpool: new check to monitor usage of zfs pools...
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index 3cf8046..cfccfda 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -239,6 +239,9 @@ echo $load 1/$ps $$ $procs
# zpool status
if [ -x /sbin/zpool ]; then
run_cached -s zpool_status 120 "/sbin/zpool status -x"
+
+ echo '<<<zpool>>>'
+ zpool list
fi
diff --git a/checkman/zpool b/checkman/zpool
new file mode 100644
index 0000000..f0ceb69
--- /dev/null
+++ b/checkman/zpool
@@ -0,0 +1,16 @@
+title: ZFS Storage Pool sizes
+agents: solaris
+catalog: os/storage
+license: GPL
+distribution: check_mk
+description:
+ Checks the current size and usage of ZFS storage pools. The information
+ is read by the agent from {zpool list}. This check can be configured
+ using the filesystem rule.
+
+ In a simple setup where a pool is mapped 1:1 to a mountpoint and where no
+ snapshots are used, this will report the same information as the zfsget
+ check.
+
+inventory:
+ The inventory will create one service per pool.
diff --git a/checks/zpool b/checks/zpool
new file mode 100644
index 0000000..d4b995b
--- /dev/null
+++ b/checks/zpool
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+# NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
+# app02 39.8G 14.1G 25.6G 35% ONLINE -
+# rpool 39.8G 32.9G 6.81G 82% ONLINE -
+
+
+def parse_zpool(info):
+ result = {}
+ header = [item.lower() for item in info[0]]
+ for line in info[1:]:
+ result[line[0]] = dict(zip(header, line))
+ return result
+
+def inventory_zpool(parsed):
+ return df_inventory(parsed.keys())
+
+
+def check_zpool(item, params, parsed):
+ def mb(val):
+ # split number from unit
+ for idx, ch in enumerate(val):
+ if ch not in "0123456789.-":
+ break
+ num = float(val[:idx])
+ unit = val[idx:].lstrip().lower()
+ unit = ["b", "k", "m", "g",
"t"].index(unit)
+
+ return num * (1024 ** (unit - 2))
+
+ fslist = []
+ for pool, entry in parsed.iteritems():
+ if "patterns" in params or item == pool:
+ fslist.append((pool, mb(entry['size']), mb(entry['free']),
0))
+
+ return df_check_filesystem_list(item, params, fslist)
+
+
+check_info['zpool'] = {
+ "check_function" : check_zpool,
+ "inventory_function" : inventory_zpool,
+ "parse_function" : parse_zpool,
+ "service_description" : "Pool %s",
+ "has_perfdata" : True,
+ "group" : "filesystem",
+}
+