Module: check_mk
Branch: master
Commit: 5773be63a6686ff88a0e2ce2a8cb7deb1ce53101
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5773be63a6686f…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Dec 4 14:36:19 2014 +0100
#1597 bluecat_dhcp, bluecat_dns: Checks can now be used in Check_MK Cluster Mode
---
.werks/1597 | 9 +++++++++
ChangeLog | 1 +
checks/bluecat_dhcp | 42 ++++++++++++++++++++++++++++++++----------
checks/bluecat_dns | 33 ++++++++++++++++++++++++++++-----
4 files changed, 70 insertions(+), 15 deletions(-)
diff --git a/.werks/1597 b/.werks/1597
new file mode 100644
index 0000000..1844979
--- /dev/null
+++ b/.werks/1597
@@ -0,0 +1,9 @@
+Title: bluecat_dhcp, bluecat_dns: Checks can now be used in Check_MK Cluster Mode
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417700149
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 128ace9..29f13a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,7 @@
* 1616 drbd: Added support for Ahead/Behind cluster states (DRBD >= 8.3.10)
* 1626 Renamed service descriptions of filesystem, process and logwatch checks...
* 1627 megaraid_ldisks: Warn if current cache or write policy differs from logical
drive default policy...
+ * 1597 bluecat_dhcp, bluecat_dns: Checks can now be used in Check_MK Cluster Mode
* 1478 FIX: kernel.util, statgrab_cpu: fix computation of utilization...
* 1480 FIX: brocade_vdx_status: disable check on some devices that do not support
it...
* 1485 FIX: dell_om_disks, dell_om_esmlog, dell_om_mem, dell_om_processors,
dell_om_sensors: detect more devices...
diff --git a/checks/bluecat_dhcp b/checks/bluecat_dhcp
index 79032ba..a0d250e 100644
--- a/checks/bluecat_dhcp
+++ b/checks/bluecat_dhcp
@@ -33,7 +33,7 @@ factory_settings["bluecat_dhcp"] = {
def inventory_bluecat_dhcp(info):
return [(None, None)]
-
+# [['dewedns1a', '2', '0'], ['dewedns1b', '1',
'0']]
def check_bluecat_dhcp(item, params, info):
oper_states = {
1 : "running normally",
@@ -42,20 +42,41 @@ def check_bluecat_dhcp(item, params, info):
4 : "currently stopping",
5 : "fault"
}
-
- if not info:
- return
-
- for line in info:
- oper_state, leases_sec = map(int, line)
+
+ ok_on_node = False
+ states = {}
+ state = 0
+
+ # Collect states of nodes
+ for node, oper_state, leases in info:
+ oper_state, leases_sec = map(int, (oper_state, leases))
+ temp_state = 0
if oper_state in params['oper_states']['warning']:
- state = 1
+ state = max(state, 1)
+ temp_state = 1
elif oper_state in params['oper_states']['critical']:
state = 2
+ temp_state = 2
+ else:
+ # If node one ok, the total check is ok
+ ok_on_node = node
+ # Only needed in cluster:
+ states[node] = {'oper_state' : oper_states[oper_state],
'leases_sec' : leases_sec, 'state' : temp_state }
+
+ # Are we in a Cluster?
+ if len(info) > 1:
+ if ok_on_node:
+ node = ok_on_node
+ # One Node is OK:
+ yield 0, "DHCP is %s on %s" % (states[ok]['oper_state'],
node)
+ yield 0, '%s Leases per second' %
(states[node]['leases_sec']), [ ('leases',
states[node]['leases_sec']) ]
else:
- state = 0
- break
+ # None of the nodes is ok:
+ for node, data in states.items():
+ yield data['state'], "%s on %s" %
(data['oper_state'], node)
+ return
+ # Default behavior without Cluster
yield state, "DHCP is %s" % oper_states[oper_state]
yield 0, '%s Leases per second' % leases_sec, [ ('leases', leases_sec
) ]
@@ -63,6 +84,7 @@ def check_bluecat_dhcp(item, params, info):
check_info["bluecat_dhcp"] = {
"check_function" : check_bluecat_dhcp,
"inventory_function" : inventory_bluecat_dhcp,
+ "node_info" : True,
"service_description" : "DHCP",
"has_perfdata" : True,
"default_levels_variable" : "bluecat_dhcp",
diff --git a/checks/bluecat_dns b/checks/bluecat_dns
index 8e25614..538309b 100644
--- a/checks/bluecat_dns
+++ b/checks/bluecat_dns
@@ -46,21 +46,44 @@ def check_bluecat_dns(item, params, info):
if not info:
return
- for line in info:
- oper_state = int(line[0])
+ ok_on_node = False
+ states = {}
+ state = 0
+
+ for node, oper_state in info:
+ oper_state = int(oper_state)
+ temp_state = 0
if oper_state in params['oper_states']['warning']:
- state = 1
+ state = max(1, state)
+ temp_state = 1
elif oper_state in params['oper_states']['critical']:
state = 2
+ temp_state = 2
+ else:
+ # If node one ok, the total check is ok
+ ok_on_node = node
+ # Only needed in cluster:
+ states[node] = {'oper_state' : oper_states[oper_state], 'state' :
temp_state }
+
+ # Are we in a Cluster?
+ if len(info) > 1:
+ if ok_on_node:
+ node = ok_on_node
+ # One Node is OK:
+ yield 0, "DHCP is %s on %s" % (states[node]['oper_state'],
node)
else:
- state = 0
- break
+ # None of the nodes is ok:
+ for node, data in states.items():
+ yield data['state'], "%s on %s" %
(data['oper_state'], node)
+ return
+ # Default behavior without Cluster
yield state, "DNS is %s" % oper_states[oper_state]
check_info["bluecat_dns"] = {
"check_function" : check_bluecat_dns,
"inventory_function" : inventory_bluecat_dns,
+ "node_info" : True,
"service_description" : "DNS",
"default_levels_variable" : "bluecat_dns",
"group" : "bluecat_dns",