2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # <<<websphere_mq_queues>>>
28 # 0 CD.ISS.CATSOS.REPLY.C000052 5000
29 # 0 CD.ISS.COBA.REPLY.C000052 5000
30 # 0 CD.ISS.DEUBA.REPLY.C000052 5000
31 # 0 CD.ISS.TIQS.REPLY.C000052 5000
32 # 0 CD.ISS.VWD.REPLY.C000052 5000
35 # <<<websphere_mq_queues>>>
36 # 0 CD.ISS.CATSOS.REPLY.C000052
37 # 0 CD.ISS.COBA.REPLY.C000052
38 # 0 CD.ISS.DEUBA.REPLY.C000052
39 # 0 CD.ISS.TIQS.REPLY.C000052
40 # 0 CD.ISS.VWD.REPLY.C000052
43 # <<<websphere_mq_queues>>>
44 # 0 BRK.REPLY.CONVERTQ 2016_04_08-15_31_43
45 # 0 BRK.REPLY.CONVERTQ 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
46 # 0 BRK.REPLY.FAILUREQ 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
47 # 0 BRK.REPLY.INQ 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
48 # 0 BRK.REPLY.OUTQ 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
49 # 0 BRK.REPLYQ.IMS.MILES 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
50 # 0 BRK.REPLYQ.MILES 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
51 # 0 BRK.REQUEST.FAILUREQ 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
52 # 0 BRK.REQUEST.INQ 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
53 # 0 BRK.REQUESTQ.MILES 5000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
54 # 0 DEAD.QUEUE.IGNORE 100000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
55 # 0 DEAD.QUEUE.SECURITY 100000 CURDEPTH(0)LGETDATE()LGETTIME() 2016_04_08-15_31_43
57 websphere_mq_queues_default_levels
= {
58 'message_count': (1000, 1200),
59 'message_count_perc': (80.0, 90.0)
63 def parse_websphere_mq_queues(info
):
70 parsed
.setdefault(queue_name
, {})
71 parsed
[queue_name
].setdefault('cur_depth', int(line
[0]))
75 parsed
[queue_name
].setdefault('max_depth', int(line
[2]))
78 for what
in "".join(line
[3:-1]).replace(" ", "").split(')'):
80 key
, val
= what
.split('(')
81 parsed
[queue_name
].setdefault(key
, val
)
83 parsed
[queue_name
].setdefault(
84 "time_on_client", time
.mktime(time
.strptime(line
[-1], "%Y_%m_%d-%H_%M_%S")))
89 def inventory_websphere_mq_queues(parsed
):
90 return [ ( queue_name
, 'websphere_mq_queues_default_levels' ) \
91 for queue_name
in parsed
]
94 def check_websphere_mq_queues(item
, params
, parsed
):
96 if isinstance(params
, tuple):
98 'message_count': params
,
99 'message_count_perc': websphere_mq_queues_default_levels
["message_count_perc"]
103 cur_depth
= data
['cur_depth']
104 infotext
= "%d" % cur_depth
107 if data
.get('max_depth'):
109 max_depth
= data
['max_depth']
110 infotext
+= "/%d" % max_depth
112 used_perc
= float(cur_depth
) / max_depth
* 100
113 info_perc
= "%.1f%%" % used_perc
115 if params
.get("message_count_perc"):
116 warn_perc
, crit_perc
= params
['message_count_perc']
117 if used_perc
>= crit_perc
:
119 elif used_perc
>= warn_perc
:
123 infotext
+= " messages in queue"
124 perfdata
= [("queue", cur_depth
, None, None, None, max_depth
)]
126 if params
.get("message_count"):
127 warn
, crit
= params
['message_count']
130 elif cur_depth
> warn
:
133 infotext
+= " (warn/crit at %d/%d)" % (warn
, crit
)
135 perfdata
= [("queue", cur_depth
, warn
, crit
, None, max_depth
)]
137 yield state
, infotext
, perfdata
139 if max_depth
is not None:
141 info_perc
+= " (warn/crit at %s%%/%s%%)" % (warn_perc
, crit_perc
)
143 yield state_perc
, info_perc
145 if data
.get("time_on_client") and \
146 "LGETDATE" in data
and "LGETTIME" in data
:
148 params
= params
.get("messages_not_processed", {})
150 if cur_depth
and data
["LGETDATE"] and data
["LGETTIME"]:
151 time_str
= "%s %s" % (data
['LGETDATE'], data
['LGETTIME'])
152 time_diff
= data
["time_on_client"] - \
153 time
.mktime(time
.strptime(time_str
, "%Y-%m-%d %H.%M.%S"))
155 info_diff
= "Messages not processed since %s" % get_age_human_readable(time_diff
)
158 warn_diff
, crit_diff
= params
['age']
160 if time_diff
>= crit_diff
:
162 elif time_diff
>= warn_diff
:
166 info_diff
+= " (warn/crit at %s/%s)" % \
167 (get_age_human_readable(warn_diff
),
168 get_age_human_readable(crit_diff
))
170 yield state_diff
, info_diff
173 yield params
.get("state", 0), "No age of %d message%s not processed" % \
174 (cur_depth
, cur_depth
> 1 and "s" or "")
177 yield 0, "Messages processed"
180 raise MKCounterWrapped("Login into database failed")
183 check_info
["websphere_mq_queues"] = {
184 "parse_function": parse_websphere_mq_queues
,
185 "inventory_function": inventory_websphere_mq_queues
,
186 "check_function": check_websphere_mq_queues
,
187 "service_description": "MQ Queue %s",
188 "has_perfdata": True,
189 "group": "websphere_mq",