Module: check_mk
Branch: master
Commit: ab8730ccef7e0eb25ad709752e58a771726378c6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ab8730ccef7e0e…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Mon Jan 25 15:25:54 2016 +0100
#2938 websphere_mq_channels: check outcome based on channel state is now configurable
The agent reports channel states as "RUNNING", "STOPPED" or
"RETRYING", which will by default
make the check state become {OK}, {WARN} or {CRIT} respectively. Now this can be changed.
---
.werks/2938 | 10 +++++++
ChangeLog | 1 +
checks/websphere_mq_channels | 34 ++++++++++++-----------
checks/websphere_mq_queues | 11 +++++---
web/plugins/wato/check_parameters.py | 49 +++++++++++++++++++++++++++++-----
5 files changed, 79 insertions(+), 26 deletions(-)
diff --git a/.werks/2938 b/.werks/2938
new file mode 100644
index 0000000..ae51e44
--- /dev/null
+++ b/.werks/2938
@@ -0,0 +1,10 @@
+Title: websphere_mq_channels: check outcome based on channel state is now configurable
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453731797
+Class: feature
+
+The agent reports channel states as "RUNNING", "STOPPED" or
"RETRYING", which will by default
+make the check state become {OK}, {WARN} or {CRIT} respectively. Now this can be
changed.
diff --git a/ChangeLog b/ChangeLog
index a5778ea..15af17f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -96,6 +96,7 @@
* 2892 qlogic_fcport: now supports QLogic FC Switch SANBox 5802 series
* 2937 mrpe: check now supports service descriptions using percent-encoded
characters...
NOTE: Please refer to the migration notes!
+ * 2938 websphere_mq_channels: check outcome based on channel state is now
configurable...
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/checks/websphere_mq_channels b/checks/websphere_mq_channels
index ed51dca..7002599 100644
--- a/checks/websphere_mq_channels
+++ b/checks/websphere_mq_channels
@@ -36,35 +36,39 @@
# Anzahl_Message Channelname MaxMessages_Moeglich Status"
-websphere_mq_channels_default_levels = ( 900, 1000 )
+websphere_mq_channels_default_levels = {
+ 'message_count': ( 900, 1000 ),
+ 'status': {
+ 'RUNNING': 0,
+ 'STOPPED': 1
+ }
+}
+
def inventory_websphere_mq_channels(info):
return [ ( x[1], 'websphere_mq_channels_default_levels' ) for x in info ]
def check_websphere_mq_channels(item, params, info):
+ if isinstance(params, tuple):
+ params = {'message_count': params,
+ 'status':
websphere_mq_channels_default_levels['status']}
+
for messages, channel, max_messages, status in info:
if channel == item:
- warn, crit = params
+ warn, crit = params['message_count']
+
messages = saveint(messages)
max_messages = saveint(max_messages)
state = 0
- message = "%d/%d Messages" % ( messages, max_messages)
if messages >= crit:
state = 2
- message += "(!!)"
elif messages >= warn:
state = 1
- message += "(!)"
- message += ", Channel State: %s" % status
- if status == 'STOPPED':
- state = 1
- message += "(!)"
- elif status not in [ 'RUNNING' ]:
- state = 2
- message += "(!!)"
- perf = [ ('messages', messages, warn, crit, 0, max_messages) ]
- return state, message, perf
- return 3, "Channel not found in output"
+ yield (state, "%d/%d Messages" % (messages, max_messages),
+ [ ('messages', messages, warn, crit, 0, max_messages) ])
+
+ state = params['status'].get(status, 2)
+ yield state, "Channel State: %s" % status, []
check_info["websphere_mq_channels"] = {
diff --git a/checks/websphere_mq_queues b/checks/websphere_mq_queues
index 4ef4002..484ae17 100644
--- a/checks/websphere_mq_queues
+++ b/checks/websphere_mq_queues
@@ -39,12 +39,17 @@
# 0 CD.ISS.TIQS.REPLY.C000052
# 0 CD.ISS.VWD.REPLY.C000052
-websphere_mq_queues_default_levels = ( 1000, 1200 )
+websphere_mq_queues_default_levels = {
+ 'message_count': ( 1000, 1200 )
+}
def inventory_websphere_mq_queues(info):
return [ ( x[1], 'websphere_mq_queues_default_levels' ) for x in info ]
def check_websphere_mq_queues(item, params, info):
+ if isinstance(params, tuple):
+ params = {'message_count': params}
+
for line in info:
queue = line[1]
if queue == item:
@@ -56,7 +61,7 @@ def check_websphere_mq_queues(item, params, info):
length_info = ""
message = "%d%s messages in queue" % ( messages, length_info )
- warn, crit = params
+ warn, crit = params['message_count']
perf = [ ( "queue", messages, warn, crit ) ]
if messages >= crit:
return 2, message, perf
@@ -64,8 +69,6 @@ def check_websphere_mq_queues(item, params, info):
return 1, message, perf
return 0, message, perf
- return 3, "No message queue named %s in agent output" % item
-
check_info["websphere_mq_queues"] = {
"group" : "websphere_mq",
"check_function" : check_websphere_mq_queues,
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index bfba4c6..d5a25e9 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -289,19 +289,54 @@ register_check_parameters(
match_type = "dict",
)
+
+def transform_websphere_mq(source):
+ if isinstance(source, tuple):
+ return {"message_count": source}
+ else:
+ return source
+
register_check_parameters(
subgroup_applications,
"websphere_mq",
_("Maximum number of messages in Websphere Message Queues"),
- Tuple(
- title = _('Maximum number of messages'),
- elements = [
- Integer(title = _("Warning at"), default_value = 1000 ),
- Integer(title = _("Critical at"), default_value = 1200 ),
- ]
+ Transform(
+ Dictionary(
+ elements = [
+ ("message_count",
+ Tuple(
+ title = _('Maximum number of messages'),
+ elements = [
+ Integer(title = _("Warning at"), default_value = 1000
),
+ Integer(title = _("Critical at"), default_value = 1200
),
+ ]
+ )),
+ ("status",
+ Dictionary(
+ title = _('Override check state based on channel state'),
+ elements = [
+ ("STOPPED", MonitoringState(
+ title = _("State when channel is stopped"),
+ default_value = 1)),
+ ("RETRYING", MonitoringState(
+ title = _("State when channel is retrying"),
+ default_value = 2)),
+ ("RUNNING", MonitoringState(
+ title = _("State when channel is running"),
+ default_value = 0)),
+ ("other", MonitoringState(
+ title = _("State when channel status is
unknown"),
+ default_value = 2)),
+ ],
+ optional_keys = []
+ )),
+ ],
+ optional_keys = ["status"]
+ ),
+ forth = transform_websphere_mq
),
TextAscii(title = _("Name of Channel or Queue")),
- match_type = "first",
+ match_type = "dict",
)
register_check_parameters(