Module: check_mk
Branch: master
Commit: 7226ab7ce6938959fbc409e396eaa61e86e42777
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7226ab7ce69389…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Sat Oct 31 16:47:53 2015 +0100
#2441 NetApp 7Mode: Now able to monitor reserved snapshot space for volumes
---
.werks/2441 | 9 ++++++
ChangeLog | 1 +
agents/special/agent_netapp | 13 ++++++++
checkman/netapp_api_snapshots | 12 ++++++++
checks/netapp_api.include | 8 +++--
checks/netapp_api_snapshots | 67 +++++++++++++++++++++++++++++++++++++++++
6 files changed, 108 insertions(+), 2 deletions(-)
diff --git a/.werks/2441 b/.werks/2441
new file mode 100644
index 0000000..0c1a0da
--- /dev/null
+++ b/.werks/2441
@@ -0,0 +1,9 @@
+Title: NetApp 7Mode: Now able to monitor reserved snapshot space for volumes
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1446306382
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 2b46e7e..890e597 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@
* 2699 windows_tasks: new task success constant 'an instance of the task is
already running'
* 2671 df: avoid duplicate items for btrfs that is mounted several times...
NOTE: Please refer to the migration notes!
+ * 2441 NetApp 7Mode: Now able to monitor reserved snapshot space for volumes
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/agents/special/agent_netapp b/agents/special/agent_netapp
index b7c233a..a0e9d5b 100755
--- a/agents/special/agent_netapp
+++ b/agents/special/agent_netapp
@@ -619,6 +619,19 @@ else:
print format_config(aggregations, "aggregation", "name",
config_report = ["name", "size-total",
"size-available"])
+ # Snapshot info
+ for volume in volumes.children_get():
+ name = volume.child_get_string("name")
+
+ volume_snapshots_reserved = server.invoke("snapshot-get-reserve",
"volume", name)
+ dict_reserved = create_dict(volume_snapshots_reserved)
+ dict_reserved["size-total"] =
volume.child_get_string("size-total")
+ print format_dict(dict_reserved, prefix = "volume_snapshot %s" % name,
as_line = True)
+
+ volume_snapshots = server.invoke("snapshot-list-info",
"target-name", name, "target-type", "volume")
+ print format_config(volume_snapshots.child_get("snapshots"),
"volume_snapshot", name,
+ report = ["volume_snapshot",
"percentage-of-total-blocks", "cumulative-total"])
+
# Protocols
print "<<<netapp_api_protocol:sep(9)>>>"
diff --git a/checkman/netapp_api_snapshots b/checkman/netapp_api_snapshots
new file mode 100644
index 0000000..fcd0d2b
--- /dev/null
+++ b/checkman/netapp_api_snapshots
@@ -0,0 +1,12 @@
+title: NetApp Filers: Used Space in Filesystems
+agents: netapp
+catalog: hw/storagehw/netapp
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the reserved space for snapshots of NetApp volumes.
+ If the cumulative size of all snapshots for a volume exceeds the configured
+ reserved percentage the check goes CRIT.
+
+item:
+ The name of the volume
diff --git a/checks/netapp_api.include b/checks/netapp_api.include
index b31aca9..bbc28a3 100644
--- a/checks/netapp_api.include
+++ b/checks/netapp_api.include
@@ -27,7 +27,7 @@
# Transforms all lines into a dictionary.
# The first key is the dictionary key, unless modified by the custom_keys
-def netapp_api_parse_lines(info, custom_keys = []):
+def netapp_api_parse_lines(info, custom_keys = [], as_dict_list = False):
instances = {}
for line in info:
instance = {}
@@ -43,7 +43,11 @@ def netapp_api_parse_lines(info, custom_keys = []):
custom_name.append(instance[key])
name = ".".join(custom_name)
- instances[name] = instance
+ if as_dict_list:
+ instances.setdefault(name, [])
+ instances[name].append(instance)
+ else:
+ instances[name] = instance
return instances
diff --git a/checks/netapp_api_snapshots b/checks/netapp_api_snapshots
new file mode 100644
index 0000000..ed5fd58
--- /dev/null
+++ b/checks/netapp_api_snapshots
@@ -0,0 +1,67 @@
+#!/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-
+# ails. 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.
+
+# Agent output:
+# <<<netapp_api_snapshots:sep(9)>>>
+# volume_snapshot volch150 percent-reserved 22 blocks-reserved 3322 size-total
12122 ...
+# volume_snapshot volch150 percentage-of-total-blocks 0 cumulative-total 122924 ...
+
+def inventory_netapp_api_snapshots(parsed):
+ for key in parsed.keys():
+ yield key, {}
+
+def check_netapp_api_snapshots(item, _no_params, parsed):
+ data = parsed.get(item)
+
+ if not data:
+ return
+
+ snapshot_total = int(data[-1]["cumulative-total"]) * 1024.0
+ size_total = int(data[0]["size-total"])
+ reserved_percent = snapshot_total / size_total
+ reserved_bytes = int(data[0]["blocks-reserved"]) * 1024.0
+
+ state = 0
+ if reserved_percent > 100:
+ state = 2
+ yield state, "Reserve used: %.1f%% (%s)" % (reserved_percent,
+
get_bytes_human_readable(snapshot_total))
+
+ yield 0, "Total Reserve: %s%% (%s) of %s" %
(data[0]["percent-reserved"],
+
get_bytes_human_readable(reserved_bytes),
+ get_bytes_human_readable(size_total)),\
+ [("bytes", snapshot_total, 0,
0, 0, reserved_bytes)]
+
+check_info["netapp_api_snapshots"] = {
+ 'parse_function' : lambda info: netapp_api_parse_lines(info,
+ custom_keys = ["volume_snapshot"], as_dict_list
= True),
+ 'check_function' : check_netapp_api_snapshots,
+ 'inventory_function' : inventory_netapp_api_snapshots,
+ 'service_description' : 'Snapshots Volume',
+ 'has_perfdata' : True,
+ 'includes' : ["netapp_api.include"]
+}
+