Module: check_mk
Branch: master
Commit: f4b84dbf2eeec40aa0538149b929658e3569dcb4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f4b84dbf2eeec4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 8 11:18:29 2010 +0100
heartbeat_rscstatus: Allowing a list as expected state to expect multiple OK states
---
ChangeLog | 1 +
checkman/heartbeat_rscstatus | 5 +++++
checks/heartbeat_rscstatus | 9 +++------
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 815e857..bcb06bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -59,6 +59,7 @@
* heartbeat_nodes: fix Linux agent for hostname with upper case letters (thanks to
Thorsten Robers)
* heartbeat_rscstatus: Catching empty output from agent correctly
+ * heartbeat_rscstatus: Allowing a list as expected state to expect multiple OK
states
* win_dhcp_pools agent plugin: Filtering additional error message on
systems without dhcp server
diff --git a/checkman/heartbeat_rscstatus b/checkman/heartbeat_rscstatus
index da8fdaa..84c383e 100644
--- a/checkman/heartbeat_rscstatus
+++ b/checkman/heartbeat_rscstatus
@@ -16,5 +16,10 @@ description:
The resource status can be "all", "foreign", "local" or
"none.
+[parameters]
+expected_state (string/list): The expected resource status. This can be one expected
+ state as string or multiple expected states given as list. The parameter defaults to
+ the resource status during inventory.
+
inventory:
Each node will get one service from this check.
diff --git a/checks/heartbeat_rscstatus b/checks/heartbeat_rscstatus
index 03a127e..67fe3ee 100644
--- a/checks/heartbeat_rscstatus
+++ b/checks/heartbeat_rscstatus
@@ -35,13 +35,10 @@
def inventory_heartbeat_rscstatus(checktype, info):
return [ (None, '"%s"' % line[0]) for line in info if line[0] !=
'' ]
-def check_heartbeat_rscstatus(item, expectedState, info):
- if len(info) == 0 or len(info[0]) == 0:
- return (3, "UNKNOWN - Got no data from agent")
-
- if info[0][0] == expectedState:
+def check_heartbeat_rscstatus(item, expected_state, info):
+ if (type(expected_state) == list and info[0][0] in expected_state) or info[0][0] ==
expected_state:
return (0, "OK - Current state: %s" % (info[0][0]))
else:
- return (2, "CRITICAL - Current state: %s (Expected: %s)" % (info[0][0],
expectedState))
+ return (2, "CRITICAL - Current state: %s (Expected: %s)" % (info[0][0],
expected_state))
check_info['heartbeat_rscstatus'] = (check_heartbeat_rscstatus, "Heartbeat
Ressource Status", 0, inventory_heartbeat_rscstatus)