Cleanup config.nodes_of
[check_mk.git] / checks / websphere_mq_channels
blob508562c9cb725ca5902772aae445f916360b5e80
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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 # Anzahl_Message Channelname MaxMessages_Moeglich Status"
28 # <<<websphere_mq_channels>>>
29 # 0 CHANNEL(C000052.C000051) 5000 Unknown
30 # 0 CHANNEL(C000052.CATSOS.03) 5000 RUNNING
31 # 0 CHANNEL(C000052.DXUZ001) 5000 RUNNING
32 # 0 CHANNEL(C000052.N000011) 5000 RUNNING
33 # 0 CHANNEL(C000052.SI0227450.T1) 10000 RUNNING
34 # 0 CHANNEL(C000052.SOX10.T1) 10000 STOPPED
35 # 0 CHANNEL(C000052.SV1348520.T1) 5000 RUNNING
36 # 0 CHANNEL(C000052.SV2098742.T1) 5000 Unknown
38 factory_settings["websphere_mq_channels_default_levels"] = {
39 'message_count': (900, 1000),
40 'status': {
41 'RUNNING': 0,
42 'STOPPED': 1
47 def parse_websphere_mq_channels(info):
48 parsed = {}
49 for line in info:
50 if len(line) == 2:
51 messages, max_messages = 0, 0
52 channel_name = line[0]
53 channel_status = line[1]
54 elif len(line) == 4:
55 messages = int(line[0])
56 channel_name = line[1]
57 max_messages = int(line[2])
58 channel_status = line[3]
59 else:
60 continue
62 parsed.setdefault(channel_name, {
63 "messages": messages,
64 "max_messages": max_messages,
65 "channel_status": channel_status,
67 return parsed
70 def inventory_websphere_mq_channels(parsed):
71 for channel_name in parsed:
72 yield channel_name, {}
75 def check_websphere_mq_channels(item, params, parsed):
76 if isinstance(params, tuple):
77 params = {
78 'message_count': params,
79 'status': {
80 'RUNNING': 0,
81 'STOPPED': 1,
85 if item in parsed:
86 data = parsed[item]
87 messages = data["messages"]
88 max_messages = data["max_messages"]
89 channel_status = data["channel_status"]
91 state = params['status'].get(channel_status, params['status'].get('other', 2))
92 yield state, "Channel status: %s" % channel_status, []
94 infotext = "%d/%d messages" % (messages, max_messages)
95 state = 0
96 if params['message_count']:
97 warn, crit = params['message_count']
98 if messages >= crit:
99 state = 2
100 elif messages >= warn:
101 state = 1
102 if state > 0:
103 infotext += " (warn crit at %d/%d messages)" % (warn, crit)
104 else:
105 warn, crit = None, None
107 yield state, infotext, [('messages', messages, warn, crit, 0, max_messages)]
109 if params.get("message_count_perc") and max_messages > 0:
110 warn, crit = params["message_count_perc"]
111 messages_perc = 1.0 * messages / max_messages
112 infotext = get_percent_human_readable(messages_perc)
113 state = 0
115 if messages_perc >= crit:
116 state = 2
117 elif messages_perc >= warn:
118 state = 1
119 if state > 0:
120 infotext += " (warn/crit at %s/%s)" % (get_percent_human_readable(warn),
121 get_percent_human_readable(crit))
123 yield state, infotext
126 check_info["websphere_mq_channels"] = {
127 "parse_function": parse_websphere_mq_channels,
128 "check_function": check_websphere_mq_channels,
129 "inventory_function": inventory_websphere_mq_channels,
130 "service_description": "MQ Channel %s",
131 "has_perfdata": True,
132 "default_levels_variable": "websphere_mq_channels_default_levels",
133 "group": "websphere_mq_channels",