Module: check_mk
Branch: master
Commit: c57a8b1ee6ced657ba334ce35f2620a683d31ede
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c57a8b1ee6ced6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Sep 16 09:55:56 2011 +0200
mrpe: make check cluster-aware and work as clustered_service
---
ChangeLog | 1 +
checkman/mrpe | 8 ++++++++
checks/mrpe | 18 ++++++++++++++++--
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ba572e7..d3c66bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
1.1.12b1:
Checks & Agents:
* FIX: j4p_performance: fix inventory functions
+ * mrpe: make check cluster-aware and work as clustered_service
Multisite:
* FIX: fix rescheduling of host check
diff --git a/checkman/mrpe b/checkman/mrpe
index bfbcf6b..640bb11 100644
--- a/checkman/mrpe
+++ b/checkman/mrpe
@@ -16,6 +16,14 @@ description:
no parameters are needed here. Please refer to the online
documentation on how to configure the agent.
+ The current version of the {mrpe} check is now cluster-aware
+ and works well as a {clustered_service} (see article about
+ Check_MK cluster monitoring). If an MRPE check is found on
+ more than one node, then the best status of the checks is
+ being used. So if the check is critical on one of the nodes
+ and OK on another then the status, output and performance
+ data of the OK check is being used as the gross result of the check.
+
item:
The service description of the check as configured in {mrpe.cfg}
on the target host.
diff --git a/checks/mrpe b/checks/mrpe
index ce6a618..a79eff5 100644
--- a/checks/mrpe
+++ b/checks/mrpe
@@ -38,6 +38,12 @@ def inventory_mrpe(info):
def check_mrpe(item, params, info):
+ # This check is cluster-aware. An item might be found
+ # more than once. In that case we use the best of the
+ # multiple statuses.
+
+ best_state = None
+
for line in info:
if line[0].startswith("("):
check_name = line[0][1:-1]
@@ -65,8 +71,16 @@ def check_mrpe(item, params, info):
# name of check command needed for PNP to choose the correct template
if check_name:
perfdata.append(check_name)
- return (state, output, perfdata)
- return (3, "Check output not found in local checks")
+
+ if best_state in [ None, 2 ] \
+ or (state < best_state and state != 2):
+ best_result = state, output, perfdata
+ best_state = state
+
+ if best_state == None:
+ return (3, "Check output not found in local checks")
+ else:
+ return best_result
check_info['mrpe'] = (