Module: check_mk
Branch: master
Commit: c37a95e302c10bd0ddb693f8842ae239f80e387b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c37a95e302c10b…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Tue Sep 19 13:15:14 2017 +0200
5133 infoblox_services, infoblox_node_services: checks are now cluster aware
The checks infoblox_services and infoblox_node_services are now cluster aware,
i.e. the overall status of a clustered service is now the best status of all
nodes containing the service.
Change-Id: I534711c4ff639500285f79999493a0a6cd43c90b
---
.werks/5133 | 12 +++++++++
checkman/infoblox_node_services | 4 ++-
checkman/infoblox_services | 4 ++-
checks/infoblox.include | 55 +++++++++++++++++++++++++++--------------
checks/infoblox_node_services | 1 +
checks/infoblox_services | 1 +
6 files changed, 57 insertions(+), 20 deletions(-)
diff --git a/.werks/5133 b/.werks/5133
new file mode 100644
index 0000000..ad7a8d6
--- /dev/null
+++ b/.werks/5133
@@ -0,0 +1,12 @@
+Title: infoblox_services, infoblox_node_services: checks are now cluster aware
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1505819216
+Class: feature
+
+The checks infoblox_services and infoblox_node_services are now cluster aware,
+i.e. the overall status of a clustered service is now the best status of all
+nodes containing the service.
diff --git a/checkman/infoblox_node_services b/checkman/infoblox_node_services
index 4ffcafb..cfa0144 100644
--- a/checkman/infoblox_node_services
+++ b/checkman/infoblox_node_services
@@ -8,9 +8,11 @@ description:
support the IB-PLATFORMONE MIB.
The check is OK if the status of the service is working. It goes WARN
- if it is warning, the check reports CRIT, if it fails. Otherwise the
+ if it is warning, and reports CRIT, if it fails. Otherwise the
check goes UNKNOWN.
+ If the service is clustered the best status of all nodes is shown.
+
item:
The service name.
diff --git a/checkman/infoblox_services b/checkman/infoblox_services
index ed13309..b92dc1e 100644
--- a/checkman/infoblox_services
+++ b/checkman/infoblox_services
@@ -8,9 +8,11 @@ description:
support the IB-PLATFORMONE MIB.
The check is OK if the status of the service is working. It goes WARN
- if it is warning, the check reports CRIT, if it fails. Otherwise the
+ if it is warning, and reports CRIT, if it fails. Otherwise the
check goes UNKNOWN.
+ If the service is clustered the best status of all nodes is shown.
+
item:
The service name.
diff --git a/checks/infoblox.include b/checks/infoblox.include
index 380a0df..9d1af8e 100644
--- a/checks/infoblox.include
+++ b/checks/infoblox.include
@@ -103,11 +103,23 @@ def parse_infoblox_services(info):
"59" : "taxii",
}
+ map_status_id = {
+ "1" : "working",
+ "2" : "warning",
+ "3" : "failed",
+ "4" : "inactive",
+ "5" : "unknown",
+ }
+
parsed = {}
- for service_id, status, status_descr in info:
+ for _node, service_id, status_id, description in info:
+ status = map_status_id.get(status_id, "unexpected")
+ if status in ["inactive", "unknown"]:
+ continue
+
service_name = map_service_ids[service_id]
- if status not in [ "5", "4" ]:
- parsed.setdefault(service_name, (status, status_descr))
+ service_nodes = parsed.setdefault(service_name, [])
+ service_nodes.append((status, description))
return parsed
@@ -118,22 +130,29 @@ def inventory_infoblox_services(parsed):
def check_infoblox_services(item, _no_params, parsed):
- map_states = {
- "1" : (0, "working"),
- "2" : (1, "warning"),
- "3" : (2, "failed"),
- "4" : (3, "inactive"),
- "5" : (3, "unknown")
- }
-
if item in parsed:
- status, descr = parsed[item]
- state, state_readable = \
- map_states.get(status, (3, "unexpected(%s)" % status))
- extra_info = ""
- if descr:
- extra_info += " (%s)" % descr
- return state, "Status: %s%s" % (state_readable, extra_info)
+ map_status = {
+ "working": 0,
+ "warning": 1,
+ "failed": 2,
+ "unexpected": 3,
+ }
+ node_data = parsed[item]
+
+ # For a clustered service the best state is used
+ min_status, min_descr = node_data[0]
+ min_state = map_status[min_status]
+
+ for status, descr in node_data[1:]:
+ state = map_status[status]
+ if state < min_state:
+ min_state, min_status, min_descr = state, status, descr
+
+ infotext = "Status: %s" % min_status
+ if min_descr:
+ infotext += " (%s)" % min_descr
+
+ return min_state, infotext
#.
diff --git a/checks/infoblox_node_services b/checks/infoblox_node_services
index f48077e..a55a9d1 100644
--- a/checks/infoblox_node_services
+++ b/checks/infoblox_node_services
@@ -60,4 +60,5 @@ check_info['infoblox_node_services'] = {
]),
'snmp_scan_function' : scan_infoblox,
'includes' : [ "infoblox.include" ],
+ 'node_info' : True,
}
diff --git a/checks/infoblox_services b/checks/infoblox_services
index 078da22..6e1226c 100644
--- a/checks/infoblox_services
+++ b/checks/infoblox_services
@@ -63,4 +63,5 @@ check_info['infoblox_services'] = {
]),
'snmp_scan_function' : scan_infoblox,
'includes' : [ "infoblox.include" ],
+ 'node_info' : True,
}