Cleanup config.nodes_of
[check_mk.git] / checks / ibm_svc_nodestats
blob99fe1cc5b048b3c467f8425b577601eb7d338511
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 # Note: This file is almost identical with ibm_svc_nodestats. We should
28 # create an include file for sharing common code!
30 # Example output from agent:
31 # <<<ibm_svc_nodestats:sep(58)>>>
32 # 1:BLUBBSVC01:compression_cpu_pc:0:0:140325134931
33 # 1:BLUBBSVC01:cpu_pc:1:3:140325134526
34 # 1:BLUBBSVC01:fc_mb:35:530:140325134526
35 # 1:BLUBBSVC01:fc_io:5985:11194:140325134751
36 # 1:BLUBBSVC01:sas_mb:0:0:140325134931
37 # 1:BLUBBSVC01:sas_io:0:0:140325134931
38 # 1:BLUBBSVC01:iscsi_mb:0:0:140325134931
39 # 1:BLUBBSVC01:iscsi_io:0:0:140325134931
40 # 1:BLUBBSVC01:write_cache_pc:0:0:140325134931
41 # 1:BLUBBSVC01:total_cache_pc:70:77:140325134716
42 # 1:BLUBBSVC01:vdisk_mb:1:246:140325134526
43 # 1:BLUBBSVC01:vdisk_io:130:1219:140325134501
44 # 1:BLUBBSVC01:vdisk_ms:0:4:140325134531
45 # 1:BLUBBSVC01:mdisk_mb:17:274:140325134526
46 # 1:BLUBBSVC01:mdisk_io:880:1969:140325134526
47 # 1:BLUBBSVC01:mdisk_ms:1:5:140325134811
48 # 1:BLUBBSVC01:drive_mb:0:0:140325134931
49 # 1:BLUBBSVC01:drive_io:0:0:140325134931
50 # 1:BLUBBSVC01:drive_ms:0:0:140325134931
51 # 1:BLUBBSVC01:vdisk_r_mb:0:244:140325134526
52 # 1:BLUBBSVC01:vdisk_r_io:19:1022:140325134501
53 # 1:BLUBBSVC01:vdisk_r_ms:2:8:140325134756
54 # 1:BLUBBSVC01:vdisk_w_mb:0:2:140325134701
55 # 1:BLUBBSVC01:vdisk_w_io:110:210:140325134901
56 # 1:BLUBBSVC01:vdisk_w_ms:0:0:140325134931
57 # 1:BLUBBSVC01:mdisk_r_mb:1:265:140325134526
58 # 1:BLUBBSVC01:mdisk_r_io:15:1081:140325134526
59 # 1:BLUBBSVC01:mdisk_r_ms:5:23:140325134616
60 # 1:BLUBBSVC01:mdisk_w_mb:16:132:140325134751
61 # 1:BLUBBSVC01:mdisk_w_io:865:1662:140325134736
62 # 1:BLUBBSVC01:mdisk_w_ms:1:5:140325134811
63 # 1:BLUBBSVC01:drive_r_mb:0:0:140325134931
64 # 1:BLUBBSVC01:drive_r_io:0:0:140325134931
65 # 1:BLUBBSVC01:drive_r_ms:0:0:140325134931
66 # 1:BLUBBSVC01:drive_w_mb:0:0:140325134931
67 # 1:BLUBBSVC01:drive_w_io:0:0:140325134931
68 # 1:BLUBBSVC01:drive_w_ms:0:0:140325134931
69 # 5:BLUBBSVC02:compression_cpu_pc:0:0:140325134930
70 # 5:BLUBBSVC02:cpu_pc:1:2:140325134905
71 # 5:BLUBBSVC02:fc_mb:141:293:140325134755
72 # 5:BLUBBSVC02:fc_io:7469:12230:140325134750
73 # 5:BLUBBSVC02:sas_mb:0:0:140325134930
74 # 5:BLUBBSVC02:sas_io:0:0:140325134930
75 # [...]
78 def parse_ibm_svc_nodestats(info):
79 dflt_header = [
80 'node_id',
81 'node_name',
82 'stat_name',
83 'stat_current',
84 'stat_peak',
85 'stat_peak_time',
87 parsed = {}
88 for rows in parse_ibm_svc_with_header(info, dflt_header).itervalues():
89 for data in rows:
90 node_name = data['node_name']
91 stat_name = data['stat_name']
92 if stat_name in ("vdisk_r_mb", "vdisk_w_mb", "vdisk_r_io", "vdisk_w_io", "vdisk_r_ms",
93 "vdisk_w_ms"):
94 item_name = "VDisks %s" % node_name
95 stat_name = stat_name.replace("vdisk_", "")
96 elif stat_name in ("mdisk_r_mb", "mdisk_w_mb", "mdisk_r_io", "mdisk_w_io", "mdisk_r_ms",
97 "mdisk_w_ms"):
98 item_name = "MDisks %s" % node_name
99 stat_name = stat_name.replace("mdisk_", "")
100 elif stat_name in ("drive_r_mb", "drive_w_mb", "drive_r_io", "drive_w_io", "drive_r_ms",
101 "drive_w_ms"):
102 item_name = "Drives %s" % node_name
103 stat_name = stat_name.replace("drive_", "")
104 elif stat_name in ("write_cache_pc", "total_cache_pc", "cpu_pc"):
105 item_name = node_name
106 else:
107 continue
108 try:
109 stat_current = int(data['stat_current'])
110 except ValueError:
111 continue
112 parsed.setdefault(item_name, {}).setdefault(stat_name, stat_current)
113 return parsed
116 # .--disk IO-------------------------------------------------------------.
117 # | _ _ _ ___ ___ |
118 # | __| (_)___| | __ |_ _/ _ \ |
119 # | / _` | / __| |/ / | | | | | |
120 # | | (_| | \__ \ < | | |_| | |
121 # | \__,_|_|___/_|\_\ |___\___/ |
122 # | |
123 # '----------------------------------------------------------------------'
126 def inventory_ibm_svc_nodestats_diskio(info):
127 return [(node_name, None)
128 for node_name, data in parse_ibm_svc_nodestats(info).iteritems()
129 if 'r_mb' in data and 'w_mb' in data]
132 def check_ibm_svc_nodestats_diskio(item, _no_params, info):
133 data = parse_ibm_svc_nodestats(info).get(item)
134 if data is None:
135 return
137 read_bytes = data['r_mb'] * 1024 * 1024
138 write_bytes = data['w_mb'] * 1024 * 1024
139 perfdata = [("read", read_bytes), ("write", write_bytes)]
141 return 0, "%s/s read, %s/s write" % \
142 (get_bytes_human_readable(read_bytes), get_bytes_human_readable(write_bytes)), \
143 perfdata
146 check_info["ibm_svc_nodestats.diskio"] = {
147 "check_function": check_ibm_svc_nodestats_diskio,
148 "inventory_function": inventory_ibm_svc_nodestats_diskio,
149 "service_description": "Disk IO %s",
150 "includes": ["ibm_svc.include"],
151 "has_perfdata": True,
155 # .--iops----------------------------------------------------------------.
156 # | _ |
157 # | (_) ___ _ __ ___ |
158 # | | |/ _ \| '_ \/ __| |
159 # | | | (_) | |_) \__ \ |
160 # | |_|\___/| .__/|___/ |
161 # | |_| |
162 # '----------------------------------------------------------------------'
165 def inventory_ibm_svc_nodestats_iops(info):
166 return [(node_name, None)
167 for node_name, data in parse_ibm_svc_nodestats(info).iteritems()
168 if 'r_io' in data and 'w_io' in data]
171 def check_ibm_svc_nodestats_iops(item, _no_params, info):
172 data = parse_ibm_svc_nodestats(info).get(item)
173 if data is None:
174 return
176 read_iops = data['r_io']
177 write_iops = data['w_io']
178 perfdata = [("read", read_iops), ("write", write_iops)]
180 return 0, "%s IO/s read, %s IO/s write" % (read_iops, write_iops), perfdata
183 check_info["ibm_svc_nodestats.iops"] = {
184 "check_function": check_ibm_svc_nodestats_iops,
185 "inventory_function": inventory_ibm_svc_nodestats_iops,
186 "service_description": "Disk IOPS %s",
187 "has_perfdata": True,
191 # .--disk latency--------------------------------------------------------.
192 # | _ _ _ _ _ |
193 # | __| (_)___| | __ | | __ _| |_ ___ _ __ ___ _ _ |
194 # | / _` | / __| |/ / | |/ _` | __/ _ \ '_ \ / __| | | | |
195 # | | (_| | \__ \ < | | (_| | || __/ | | | (__| |_| | |
196 # | \__,_|_|___/_|\_\ |_|\__,_|\__\___|_| |_|\___|\__, | |
197 # | |___/ |
198 # '----------------------------------------------------------------------'
201 def inventory_ibm_svc_nodestats_disk_latency(info):
202 return [(node_name, None)
203 for node_name, data in parse_ibm_svc_nodestats(info).iteritems()
204 if 'r_ms' in data and 'w_ms' in data]
207 def check_ibm_svc_nodestats_disk_latency(item, _no_params, info):
208 data = parse_ibm_svc_nodestats(info).get(item)
209 if data is None:
210 return
212 read_latency = data['r_ms']
213 write_latency = data['w_ms']
214 perfdata = [("read_latency", read_latency), ("write_latency", write_latency)]
216 return 0, "Latency is %s ms for read, %s ms for write" % (read_latency, write_latency), perfdata
219 check_info["ibm_svc_nodestats.disk_latency"] = {
220 "check_function": check_ibm_svc_nodestats_disk_latency,
221 "inventory_function": inventory_ibm_svc_nodestats_disk_latency,
222 "service_description": "Disk Latency %s",
223 "has_perfdata": True,
227 # .--cpu-----------------------------------------------------------------.
228 # | |
229 # | ___ _ __ _ _ |
230 # | / __| '_ \| | | | |
231 # | | (__| |_) | |_| | |
232 # | \___| .__/ \__,_| |
233 # | |_| |
234 # | |
235 # '----------------------------------------------------------------------'
237 ibm_svc_cpu_default_levels = (90.0, 95.0)
240 def inventory_ibm_svc_nodestats_cpu(info):
241 return [(node_name, "ibm_svc_cpu_default_levels")
242 for node_name, data in parse_ibm_svc_nodestats(info).iteritems()
243 if 'cpu_pc' in data]
246 def check_ibm_svc_nodestats_cpu(item, params, info):
247 data = parse_ibm_svc_nodestats(info).get(item)
248 if data is None:
249 return
250 return check_cpu_util(data['cpu_pc'], params)
253 check_info["ibm_svc_nodestats.cpu_util"] = {
254 "check_function": check_ibm_svc_nodestats_cpu,
255 "inventory_function": inventory_ibm_svc_nodestats_cpu,
256 "service_description": "CPU utilization %s",
257 "has_perfdata": True,
258 "group": "cpu_utilization_multiitem",
259 "includes": ["cpu_util.include"],
263 # .--cache---------------------------------------------------------------.
264 # | _ |
265 # | ___ __ _ ___| |__ ___ |
266 # | / __/ _` |/ __| '_ \ / _ \ |
267 # | | (_| (_| | (__| | | | __/ |
268 # | \___\__,_|\___|_| |_|\___| |
269 # | |
270 # '----------------------------------------------------------------------'
273 def inventory_ibm_svc_nodestats_cache(info):
274 return [(node_name, None)
275 for node_name, data in parse_ibm_svc_nodestats(info).iteritems()
276 if 'write_cache_pc' in data and 'total_cache_pc' in data]
279 def check_ibm_svc_nodestats_cache(item, _no_params, info):
280 data = parse_ibm_svc_nodestats(info).get(item)
281 if data is None:
282 return
284 write_cache_pc = data["write_cache_pc"]
285 total_cache_pc = data["total_cache_pc"]
286 perfdata = [("write_cache_pc", write_cache_pc, None, None, 0, 100),
287 ("total_cache_pc", total_cache_pc, None, None, 0, 100)]
289 return 0, "Write cache usage is %d %%, total cache usage is %d %%" % \
290 (write_cache_pc, total_cache_pc), perfdata
293 check_info["ibm_svc_nodestats.cache"] = {
294 "check_function": check_ibm_svc_nodestats_cache,
295 "inventory_function": inventory_ibm_svc_nodestats_cache,
296 "service_description": "Cache %s",
297 "has_perfdata": True,