Module: check_mk
Branch: master
Commit: 78013be3cefcbde8d36107de61e9ea1967673891
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=78013be3cefcbd…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Jul 3 09:23:26 2015 +0200
Updated #2317: ruckus_spot_ap now works with items
---
checks/ruckus_spot_ap | 67 ++++++++++++++++++++--------------
web/plugins/metrics/check_mk.py | 65 ++++++++++++++-------------------
web/plugins/wato/check_parameters.py | 37 ++++---------------
3 files changed, 76 insertions(+), 93 deletions(-)
diff --git a/checks/ruckus_spot_ap b/checks/ruckus_spot_ap
index 5fda396..468bb0e 100644
--- a/checks/ruckus_spot_ap
+++ b/checks/ruckus_spot_ap
@@ -34,11 +34,14 @@
# 1-16 1
# 1-9 1
-def inventory_ruckus_spot_ap(info):
- # 4 tuples of warn, crit
- yield None, ((None,None),) * 4
-def check_ruckus_spot_ap(_no_item, params, info):
+ruckus_spot_ap_bands = {
+ "1": "2.4 GHz",
+ "2": "5 GHz",
+}
+ruckus_spot_ap_default_levels = ((None, None), (None, None))
+
+def parse_ruckus_spot_ap(info):
bands = {}
current_band = None
for line in info:
@@ -47,38 +50,48 @@ def check_ruckus_spot_ap(_no_item, params, info):
bands.setdefault(current_band, [])
else:
bands[current_band].append(line)
+ return bands
+
+def inventory_ruckus_spot_ap(parsed):
+ for band in parsed.keys():
+ if band in ruckus_spot_ap_bands:
+ yield ruckus_spot_ap_bands[band], "ruckus_spot_ap_default_levels"
+
+def check_ruckus_spot_ap(item, params, parsed):
+ inverse_map = dict((v, k) for k, v in ruckus_spot_ap_bands.items())
+ band = parsed.get(inverse_map.get(item))
+ if not band:
+ return
- for band, band_id, name, params_offset in [ ("2_4ghz", "1",
"2.4 GHz", 0), ("5ghz", "2", "5 GHz", 2) ]:
- (drift_warn, drift_crit), (down_warn, down_crit) =
params[params_offset+0:params_offset+2]
- if band_id in bands:
- state = 0
- info = 0
- num_devices = len(bands[band_id])
- perfdata = [("ap_devices_total_%s" % band, num_devices)]
+ (drift_warn, drift_crit), (down_warn, down_crit) = params
+ state = 0
+ info = 0
+ perfdata = [("ap_devices_total", len(band))]
- extra_info = []
- for what, ap_state, warn, crit in [ ("drifted",
"2", drift_warn, drift_crit),
- ("not responding",
"0", down_warn, down_crit) ]:
- problems = len([x for x in bands[band_id] if x[1] == ap_state])
+ extra_info = []
+ for what, ap_state, warn, crit in [ ("drifted", "2",
drift_warn, drift_crit),
+ ("not responding", "0",
down_warn, down_crit) ]:
+ problems = len([x for x in band if x[1] == ap_state])
+ if crit and problems >= crit:
+ state = 2
+ elif warn and problems >= warn:
+ state = 1
- if crit and problems >= crit:
- state = 2
- elif warn and problems >= warn:
- state = 1
+ if problems:
+ extra_info.append("%d %s%s" % (problems, what,
state_markers[state]))
+ perfdata.append(("ap_devices_%s" % what.replace(" ",
"_"), problems, warn, crit))
- if problems:
- extra_info.append("%d %s" % (problems, what))
- perfdata.append(("ap_devices_%s_%s" % (what.replace("
", "_"), band), problems))
- info = "%s: %d devices" % (name, num_devices)
- if extra_info:
- info += " (%s)" % " / ".join(extra_info)
+ info = "%d devices" % len(band)
+ if extra_info:
+ info += " (%s)" % " / ".join(extra_info)
- yield state, info, perfdata
+ yield state, info, perfdata
check_info["ruckus_spot_ap"] = {
+ "parse_function" : parse_ruckus_spot_ap,
"inventory_function" : inventory_ruckus_spot_ap,
"check_function" : check_ruckus_spot_ap,
- "service_description" : "Ruckus Spot Access Points",
+ "service_description" : "Ruckus Spot Access Points %s",
"group" : "ruckus_ap",
"has_perfdata" : True
}
diff --git a/web/plugins/metrics/check_mk.py b/web/plugins/metrics/check_mk.py
index d33ee01..4967766 100644
--- a/web/plugins/metrics/check_mk.py
+++ b/web/plugins/metrics/check_mk.py
@@ -2334,24 +2334,23 @@ metric_info["harddrive_udma_crc_errors"] = {
"color" : "46/a",
}
-for what, perfname, shading in [ ("2.4", "2_4", "a"),
("5", "5", "b") ]:
- metric_info["ap_devices_total_%sghz" % perfname] = {
- "title" : _("Total %s GHz devices") % what,
- "unit" : "count",
- "color" : "51/%s" % shading,
- }
+metric_info["ap_devices_total"] = {
+ "title" : _("Total devices"),
+ "unit" : "count",
+ "color" : "51/a"
+}
- metric_info["ap_devices_drifted_%sghz" % perfname] = {
- "title" : _("Time drifted %s GHz devices") % what,
- "unit" : "count",
- "color" : "23/%s" % shading,
- }
+metric_info["ap_devices_drifted"] = {
+ "title" : _("Time drifted devices"),
+ "unit" : "count",
+ "color" : "23/a"
+}
- metric_info["ap_devices_not_responding_%sghz" % perfname] = {
- "title" : _("Not responding %s GHz devices") % what,
- "unit" : "count",
- "color" : "14/%s" % shading,
- }
+metric_info["ap_devices_not_responding"] = {
+ "title" : _("Not responding devices"),
+ "unit" : "count",
+ "color" : "14/a"
+}
metric_info["request_rate"] = {
"title" : _("Request rate"),
@@ -3164,18 +3163,11 @@ check_metrics["check_mk-ps.perf"] = ps_translation
# The label of dual and stacked is taken from the definition of the contained
Perf-O-Meters
-perfometer_info.append(("stacked", [
- {
- "type" : "linear",
- "segments" : [ "ap_devices_drifted_2_4ghz",
"ap_devices_not_responding_2_4ghz" ],
- "total" : "ap_devices_total_2_4ghz",
- },
- {
- "type" : "linear",
- "segments" : [ "ap_devices_drifted_5ghz",
"ap_devices_not_responding_5ghz" ],
- "total" : "ap_devices_total_5ghz",
- }])
-)
+perfometer_info.append({
+ "type" : "linear",
+ "segments" : [ "ap_devices_drifted",
"ap_devices_not_responding" ],
+ "total" : "ap_devices_total",
+})
perfometer_info.append({
"type" : "linear",
@@ -5147,13 +5139,12 @@ graph_info.append({
],
})
-for what, perfname in [ ("2.4", "2_4"), ("5",
"5") ]:
- graph_info.append({
- "title" : _("%s GHz band" % what),
- "metrics" : [
- ( "ap_devices_total_%sghz" % perfname, "area" ),
- ( "ap_devices_drifted_%sghz" % perfname, "area" ),
- ( "ap_devices_not_responding_%sghz" % perfname, "stack"
),
- ]
- })
+graph_info.append({
+ "title" : _("Access point statistics"),
+ "metrics" : [
+ ( "ap_devices_total", "area"),
+ ( "ap_devices_drifted", "area"),
+ ( "ap_devices_not_responding", "stack"),
+ ]
+})
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 9f345e7..0f801c2 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -471,8 +471,8 @@ register_check_parameters(
],
),
sameline = True,
- label = _("Levels 2.4 GHz band time drifted"),
- none_label = _("Time drifted levels for 2.4 GHz band not
set"),
+ label = _("Levels device time drifted"),
+ none_label = _("Time drifted levels not set"),
none_value = (None, None)
),
Optional(
@@ -483,37 +483,16 @@ register_check_parameters(
],
),
sameline = True,
- label = _("Levels 2.4 GHz band not responding"),
- none_label = _("Not responding levels for 2.4 GHz band not
set"),
- none_value = (None, None)
- ),
- Optional(
- Tuple(
- elements = [
- Integer(title = _("Warning at"), default_value = 1,
unit = _("devices")),
- Integer(title = _("Critical at"), default_value = 1,
unit = _("devices")),
- ],
- ),
- sameline = True,
- label = _("Levels 5 GHz band time drifted"),
- none_label = _("Time drifted levels for 5 GHz not set"),
- none_value = (None, None)
- ),
- Optional(
- Tuple(
- elements = [
- Integer(title = _("Warning at"), default_value = 1,
unit = _("devices")),
- Integer(title = _("Critical at"), default_value = 1,
unit = _("devices")),
- ],
- ),
- sameline = True,
- label = _("Levels 5 GHz band not responding"),
- none_label = _("Not responding levels for 5 GHz band not
set"),
+ label = _("Levels device not responding"),
+ none_label = _("Not responding levels not set"),
none_value = (None, None)
),
],
),
- None,
+ TextAscii(
+ title = _("Band"),
+ help = _("Name of the band, e.g. 5 GHz"),
+ ),
"first"
)