Module: check_mk
Branch: master
Commit: 5c04f311cfc6a2dc81f33e1bf956c80ed61c679b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c04f311cfc6a2…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Dec 13 16:34:47 2018 +0100
6826 FIX kemp_loadmaster_services: Do not discover disabled services
Change-Id: Id60ae52f562a34e9b80803c855bbb4d07b7bd759
---
.werks/6826 | 11 ++++++++++
checks/kemp_loadmaster_services | 47 ++++++++++++++++++++---------------------
2 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/.werks/6826 b/.werks/6826
new file mode 100644
index 0000000..09a2301
--- /dev/null
+++ b/.werks/6826
@@ -0,0 +1,11 @@
+Title: kemp_loadmaster_services: Do not discover disabled services
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1544714022
+
+
diff --git a/checks/kemp_loadmaster_services b/checks/kemp_loadmaster_services
index 1b0ae84..8a23c1d 100644
--- a/checks/kemp_loadmaster_services
+++ b/checks/kemp_loadmaster_services
@@ -53,44 +53,43 @@ kemp_loadmaster_service_default_levels = (1500, 2000)
def parse_kemp_loadmaster_services(info):
- map_states = {
- "1": (0, 'in service'),
- "2": (2, 'out of service'),
- "3": (2, 'failed'),
- "4": (3, 'disabled'),
- "5": (1, 'sorry'),
- "6": (0, 'redirect'),
- "7": (2, 'error message'),
- }
-
parsed = {}
for name, status, conns in info:
- if not (name == "" or len(status) > 1):
- parsed.setdefault(name, {"state": map_states[status]})
- if conns.isdigit():
- parsed[name].update({"conns": int(conns)})
+ if name == "" or len(status) > 1:
+ continue
+ inst = parsed.setdefault(name, {"device_state": status})
+ try:
+ inst.update({"conns": int(conns)})
+ except ValueError:
+ pass
return parsed
def inventory_kemp_loadmaster_services(parsed):
for item, iteminfo in parsed.items():
- if iteminfo["state"] not in ["4", ""]:
+ if iteminfo["device_state"] not in ["4", ""]:
yield item, kemp_loadmaster_service_default_levels
def check_kemp_loadmaster_services(item, _no_params, parsed):
+ map_states = {
+ "1": (0, 'in service'),
+ "2": (2, 'out of service'),
+ "3": (2, 'failed'),
+ "4": (3, 'disabled'),
+ "5": (1, 'sorry'),
+ "6": (0, 'redirect'),
+ "7": (2, 'error message'),
+ }
+
if item in parsed:
data = parsed[item]
- state, state_readable = data["state"]
- infotext = "State: %s" % state_readable
-
- perfdata = []
- if data.get("conns"):
- infotext += ", Active connections: %s" % data["conns"]
- perfdata.append(('conns', data["conns"]))
-
- return state, infotext, perfdata
+ state, state_readable = map_states[data["device_state"]]
+ yield state, "Status: %s" % state_readable
+ conns = data.get("conns")
+ if conns is not None:
+ yield 0, "Active connections: %s" % conns, [('conns',
conns)]
check_info["kemp_loadmaster_services"] = {