Module: check_mk
Branch: master
Commit: 36795d2ab81db994e19e5d83cfc00339bd186985
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=36795d2ab81db9…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Sep 20 07:42:14 2016 +0200
3875 tsm_stagingpools: check is now cluster aware
---
.werks/3875 | 9 ++++++
ChangeLog | 1 +
checks/tsm_stagingpools | 82 +++++++++++++++++++++++++++++--------------------
3 files changed, 59 insertions(+), 33 deletions(-)
diff --git a/.werks/3875 b/.werks/3875
new file mode 100644
index 0000000..9c6f0fa
--- /dev/null
+++ b/.werks/3875
@@ -0,0 +1,9 @@
+Title: tsm_stagingpools: check is now cluster aware
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i1
+Date: 1474350106
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index bca09fc..8745e77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -166,6 +166,7 @@
* 3859 check_mail_loop.vbs: New MRPE script to perform a mail loop check via Outlook
MAPI...
* 3838 hitachi_hus_dku & hitachi_hus_dkc: more detailed output even if everything
is in state OK...
* 3839 filehandler: added new plugin for monitoring file handles in linux...
+ * 3875 tsm_stagingpools: check is now cluster aware
* 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/checks/tsm_stagingpools b/checks/tsm_stagingpools
index ed8d823..a2cbf93 100644
--- a/checks/tsm_stagingpools
+++ b/checks/tsm_stagingpools
@@ -42,45 +42,60 @@ factory_settings["tsm_stagingpools_default_levels"] = {
"free_below" : 70,
}
-# The agent plugin sometimes seems to mix two lines together some times.
-# detect and fix that.
def parse_tsm_stagingpools(info):
- parsed = []
- for line in info:
- if len(line) == 6:
- parsed.append(line[:3])
- parsed.append(line[3:])
+ parsed = {}
+ def add_item(node, lineinfo):
+ inst, pool, util = lineinfo
+ if inst == "default":
+ item = pool
else:
- parsed.append(line)
+ item = inst + " / " + pool
+ parsed.setdefault( item, {} )
+ parsed[item].setdefault( node, [] )
+ parsed[item][node].append( util )
+
+ for line in info:
+ node = line[0]
+ add_item(node, line[1:4])
+ # The agent plugin sometimes seems to mix two lines together some
+ # times. Detect and fix that.
+ if len(line) == 7:
+ add_item(node, line[4:])
+
return parsed
def inventory_tsm_stagingpools(parsed):
- items = set([])
- for inst, pool, util in parsed:
- if inst == "default":
- items.add(pool)
- else:
- items.add(inst + " / " + pool)
- return [ (item, "tsm_stagingpools_default_levels") for item in items ]
+ for item in parsed:
+ yield item, {}
def check_tsm_stagingpools(item, params, parsed):
- num_tapes = 0
+ if item not in parsed:
+ return 3, "Item not found in agent output"
+
+ datasets, nodeinfos = [], []
+ for node, data in parsed[item].items():
+ nodeinfos.append(node)
+ datasets.append( tuple(data) )
+
+ num_tapes = 0
num_free_tapes = 0
- utilization = 0.0 # in relation to one tape size
- for inst, pool, util in parsed:
- if inst + " / " + pool == item or pool == item:
- util = float(util) / 100.0
- utilization += util
- num_tapes += 1
- if util <= params["free_below"] / 100.0:
- num_free_tapes += 1
+ utilization = 0.0 # in relation to one tape size
+ for util in datasets[0]:
+ util = float(util) / 100.0
+ utilization += util
+ num_tapes += 1
+ if util <= params["free_below"] / 100.0:
+ num_free_tapes += 1
+ if nodeinfos:
+ infotext = "%s: " % "/".join( nodeinfos )
+ else:
+ infotext = ""
+ infotext += "Total tapes: %d, Tapes less then %d%% full: %d, Utilization: %.1f
tapes" % \
+ (num_tapes, params["free_below"], num_free_tapes,
utilization)
state = 0
- infotext = "total tapes: %d, tapes less then %d%% full: %d" % \
- (num_tapes, params["free_below"], num_free_tapes)
- infotext += ', utilization: %.1f tapes' % utilization
if "levels" in params:
warn, crit = params["levels"]
if num_free_tapes < crit:
@@ -96,12 +111,13 @@ def check_tsm_stagingpools(item, params, parsed):
state = 3
infotext = "no tapes in this pool or pool not existant"
- perfdata = [
- ("tapes", num_tapes),
- ("free", num_free_tapes, warn, crit),
- ("util", utilization) ]
+ # In cluster mode we check if data sets are equal from all nodes
+ # else we have only one data set
+ if len(set( datasets )) > 1:
+ state = 3
+ infotext += ", Cluster: data from nodes are not equal"
- return (state, infotext, perfdata)
+ return state, infotext, [ ("tapes", num_tapes), ("free",
num_free_tapes, warn, crit), ("util", utilization) ]
check_info['tsm_stagingpools'] = {
@@ -112,5 +128,5 @@ check_info['tsm_stagingpools'] = {
"has_perfdata" : True,
"group" : "tsm_stagingpools",
"default_levels_variable" : "tsm_stagingpools_default_levels",
+ "node_info" : True,
}
-