2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2016 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_instance:sep(41)>>>
28 # QMNAME(QMIMIQ11) STATUS(Running)
29 # INSTANCE(iasv0001) MODE(Active)
30 # INSTANCE(tasv0397) MODE(Standby)
31 # MQv8.0.0.5,p800-005-160516.2,64-bit;
32 # QMNAME(QMIMIQ11) STATUS(Running) DEFAULT(no) STANDBY(Permitted) INSTNAME(Installation1) INSTPATH(/usr/mqm) INSTVER(8.0.0.5)$
34 # <<<websphere_mq_instance:sep(41)>>>
35 # QMNAME(QMTEMQS02A) STATUS(Ended immediately)
36 # QMNAME(QMTEMQS02) STATUS(Running)
37 # INSTANCE(tasv0065) MODE(Active)
38 # MQv8.0.0.4,p800-004-151017,64-bit;
39 # QMNAME(QMTEMQS02A) STATUS(Ended immediately) DEFAULT(no) STANDBY(Not applicable) INSTNAME(Installation1) INSTPATH(/usr/mqm) INSTVER(8.0.0.4)
40 # QMNAME(QMTEMQS02) STATUS(Running) DEFAULT(yes) STANDBY(Not permitted) INSTNAME(Installation1) INSTPATH(/usr/mqm) INSTVER(8.0.0.4)
42 # <<<websphere_mq_instance:sep(41)>>>
43 # QMNAME(QMIMIQ11) STATUS(Running as standby)
44 # INSTANCE(iasv0001) MODE(Active)
45 # INSTANCE(tasv0397) MODE(Standby)
46 # MQv8.0.0.5,p800-005-160516.2,64-bit;
47 # QMNAME(QMIMIQ11) STATUS(Running as standby) DEFAULT(yes) STANDBY(Permitted) INSTNAME(Installation1) INSTPATH(/usr/mqm) INSTVER(8.0.0.5)
49 # .--helpers-------------------------------------------------------------.
51 # | | |__ ___| |_ __ ___ _ __ ___ |
52 # | | '_ \ / _ \ | '_ \ / _ \ '__/ __| |
53 # | | | | | __/ | |_) | __/ | \__ \ |
54 # | |_| |_|\___|_| .__/ \___|_| |___/ |
56 # '----------------------------------------------------------------------'
59 def get_websphere_mq_status(what
, status
, params
):
62 "Starting": (0, "starting"),
63 "Running": (0, "running"),
64 "Running as standby": (0, "running_as_standby"),
65 "Running elsewhere": (0, "running_elsewhere"),
66 "Quiescing": (0, "quiescing"),
67 "Ending immediately": (0, "ending_immediately"),
68 "Ending pre-emptively": (0, "ending_pre_emptively"),
69 "Ended normally": (0, "ended_normally"),
70 "Ended immediately": (0, "ended_immediately"),
71 "Ended unexpectedly": (2, "ended_unexpectedly"),
72 "Ended pre-emptively": (1, "ended_pre_emptively"),
73 "Status not available": (0, "status_not_available"),
76 "Permitted": (0, "permitted"),
77 "Not permitted": (0, "not_permitted"),
78 "Not applicable": (0, "not_applicable"),
81 "Active": (0, "active"),
82 "Standby": (0, "standby"),
84 }[what
].get(status
, (3, "unknown"))
86 if statekey
in dict(params
.get("map_%s_states" % what
, [])):
87 return dict(params
["map_%s_states" % what
])[statekey
]
91 def parse_websphere_mq_instance(info
):
92 def get_data_of_line(line
):
96 key
, exp
= elem
.split("(", 1)
97 data
.setdefault(key
.strip(), exp
.strip())
100 parsed
= {"manager": {}, "instances": {}}
102 data
= get_data_of_line(line
)
105 this_qm_name
= data
["QMNAME"]
106 parsed
["manager"].setdefault(this_qm_name
, {})
107 parsed
["manager"][this_qm_name
].update(data
)
109 elif "INSTANCE" in data
:
110 this_inst_name
= data
["INSTANCE"]
111 parsed
["instances"].setdefault(this_inst_name
, {})
112 parsed
["instances"][this_inst_name
].update(data
)
113 if this_qm_name
is not None:
114 parsed
["instances"][this_inst_name
].setdefault("QMNAME", this_qm_name
)
120 # .--instances-----------------------------------------------------------.
122 # | (_)_ __ ___| |_ __ _ _ __ ___ ___ ___ |
123 # | | | '_ \/ __| __/ _` | '_ \ / __/ _ \/ __| |
124 # | | | | | \__ \ || (_| | | | | (_| __/\__ \ |
125 # | |_|_| |_|___/\__\__,_|_| |_|\___\___||___/ |
127 # '----------------------------------------------------------------------'
130 def inventory_websphere_mq_instance(parsed
):
131 return [(item
, {}) for item
in parsed
["instances"]]
134 def check_websphere_mq_instance(item
, params
, parsed
):
135 if item
in parsed
["instances"]:
136 data
= parsed
["instances"][item
]
138 qm_name
= data
["QMNAME"]
139 return get_websphere_mq_status("instance", mode
, params
), \
140 'Status: %s, Manager: %s' % (mode
.lower(), qm_name
)
143 check_info
['websphere_mq_instance'] = {
144 'parse_function': parse_websphere_mq_instance
,
145 'inventory_function': inventory_websphere_mq_instance
,
146 'check_function': check_websphere_mq_instance
,
147 'service_description': 'MQ Instance %s',
148 'group': 'websphere_mq_instance',
152 # .--manager-------------------------------------------------------------.
154 # | _ __ ___ __ _ _ __ __ _ __ _ ___ _ __ |
155 # | | '_ ` _ \ / _` | '_ \ / _` |/ _` |/ _ \ '__| |
156 # | | | | | | | (_| | | | | (_| | (_| | __/ | |
157 # | |_| |_| |_|\__,_|_| |_|\__,_|\__, |\___|_| |
159 # '----------------------------------------------------------------------'
162 def inventory_websphere_mq_manager(parsed
):
163 for item
in parsed
["manager"]:
167 def check_websphere_mq_manager(item
, params
, parsed
):
168 if item
in parsed
["manager"]:
169 data
= parsed
["manager"][item
]
170 status
= data
["STATUS"]
171 standby
= data
.get("STANDBY", "")
172 installation_name
= data
.get("INSTNAME")
173 installation_path
= data
.get("INSTPATH")
174 installation_version
= data
.get("INSTVER")
177 for _instance
, instance_info
in parsed
["instances"].items():
178 if instance_info
["QMNAME"] == item
:
179 instances_modes
.append(instance_info
["MODE"])
181 yield get_websphere_mq_status("manager", status
, params
), \
182 'Status: %s' % status
.lower()
184 standby_info
= standby
.lower()
185 if standby
.startswith("Not"):
186 if len(instances_modes
) == 1:
188 standby_info
+= " (standalone)"
191 standby_info
+= " (standalone but %d instances)" % len(instances_modes
)
192 elif standby
== "Permitted":
193 if instances_modes
in [["Active", "Standby"], ["Standby", "Active"]]:
197 standby_info
+= " (Missing partner)"
200 standby_info
+= " (unknown)"
202 if "map_instance_states" in params
:
203 state
= get_websphere_mq_status("standby", standby
, params
)
205 yield state
, "Standby: %s" % standby_info
.strip()
206 yield 0, "Default: %s" % data
["DEFAULT"]
209 (installation_name
, "Name"),
210 (installation_path
, "Path"),
211 (installation_version
, "Version"),
214 yield 0, "%s: %s" % (title
, what
)
217 check_info
['websphere_mq_instance.manager'] = {
218 'inventory_function': inventory_websphere_mq_manager
,
219 'check_function': check_websphere_mq_manager
,
220 'service_description': 'MQ Manager %s',
221 'group': 'websphere_mq_manager',