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 # Note: This file is almost identical with ibm_svc_systemstats. We should
28 # create an include file for sharing common code!
30 # Example output from agent:
31 # <<<ibm_svc_systemstats:sep(58)>>>
32 # compression_cpu_pc:0:0:140325134929
33 # cpu_pc:2:2:140325134929
34 # fc_mb:640:1482:140325134754
35 # fc_io:46718:56258:140325134749
36 # sas_mb:0:0:140325134929
37 # sas_io:0:0:140325134929
38 # iscsi_mb:0:0:140325134929
39 # iscsi_io:0:0:140325134929
40 # write_cache_pc:0:1:140325134819
41 # total_cache_pc:70:75:140325134704
42 # vdisk_mb:207:533:140325134754
43 # vdisk_io:4827:5966:140325134819
44 # vdisk_ms:1:2:140325134759
45 # mdisk_mb:222:651:140325134754
46 # mdisk_io:4995:6741:140325134754
47 # mdisk_ms:1:3:140325134809
48 # drive_mb:0:0:140325134929
49 # drive_io:0:0:140325134929
50 # drive_ms:0:0:140325134929
51 # vdisk_r_mb:113:428:140325134524
52 # vdisk_r_io:2470:3672:140325134819
53 # vdisk_r_ms:1:4:140325134759
54 # vdisk_w_mb:93:143:140325134704
55 # vdisk_w_io:2359:3595:140325134859
56 # vdisk_w_ms:0:2:140325134704
57 # mdisk_r_mb:32:362:140325134754
58 # mdisk_r_io:1452:2825:140325134754
59 # mdisk_r_ms:4:7:140325134649
60 # mdisk_w_mb:189:291:140325134749
61 # mdisk_w_io:3542:4465:140325134714
62 # mdisk_w_ms:0:2:140325134819
63 # drive_r_mb:0:0:140325134929
64 # drive_r_io:0:0:140325134929
65 # drive_r_ms:0:0:140325134929
66 # drive_w_mb:0:0:140325134929
67 # drive_w_io:0:0:140325134929
68 # drive_w_ms:0:0:140325134929
70 # parses agent output into a structure like:
71 # {'Drives': {'r_mb': 0, 'w_mb': 0, 'r_io': 0, 'w_io': 0, 'r_ms': 0, 'w_ms': 0},
72 # 'MDisks': {'r_mb': 32, 'w_mb': 189, 'r_io': 1452, 'w_io': 3542, 'r_ms': 4, 'w_ms': 0},
73 # 'VDisks': {'r_mb': 113, 'w_mb': 93, 'r_io': 2470, 'w_io': 2359, 'r_ms': 1, 'w_ms': 0}}
76 def ibm_svc_systemstats_parse(info
):
78 for stat_name
, stat_current
, _stat_peak
, _stat_peak_time
in info
:
79 if stat_name
in ("vdisk_r_mb", "vdisk_w_mb", "vdisk_r_io", "vdisk_w_io", "vdisk_r_ms",
81 if "VDisks" not in parsed
.keys():
83 stat_name
= stat_name
.replace("vdisk_", "")
84 parsed
["VDisks"][stat_name
] = int(stat_current
)
85 if stat_name
in ("mdisk_r_mb", "mdisk_w_mb", "mdisk_r_io", "mdisk_w_io", "mdisk_r_ms",
87 if "MDisks" not in parsed
.keys():
89 stat_name
= stat_name
.replace("mdisk_", "")
90 parsed
["MDisks"][stat_name
] = int(stat_current
)
91 if stat_name
in ("drive_r_mb", "drive_w_mb", "drive_r_io", "drive_w_io", "drive_r_ms",
93 if "Drives" not in parsed
.keys():
95 stat_name
= stat_name
.replace("drive_", "")
96 parsed
["Drives"][stat_name
] = int(stat_current
)
100 # .--disk IO-------------------------------------------------------------.
102 # | __| (_)___| | __ |_ _/ _ \ |
103 # | / _` | / __| |/ / | | | | | |
104 # | | (_| | \__ \ < | | |_| | |
105 # | \__,_|_|___/_|\_\ |___\___/ |
107 # '----------------------------------------------------------------------'
110 def inventory_ibm_svc_systemstats_diskio(info
):
111 return [(key
, None) for key
in ibm_svc_systemstats_parse(info
)]
114 def check_ibm_svc_systemstats_diskio(item
, _no_params
, info
):
115 parsed
= ibm_svc_systemstats_parse(info
)
117 if item
not in parsed
.keys():
118 return 3, "%s not found in agent output" % item
120 read_bytes
= parsed
[item
]['r_mb'] * 1024 * 1024
121 write_bytes
= parsed
[item
]['w_mb'] * 1024 * 1024
122 perfdata
= [("read", read_bytes
), ("write", write_bytes
)]
124 return 0, "%s/s read, %s/s write" % \
125 (get_bytes_human_readable(read_bytes
), get_bytes_human_readable(write_bytes
)), \
129 check_info
["ibm_svc_systemstats.diskio"] = {
130 "check_function": check_ibm_svc_systemstats_diskio
,
131 "inventory_function": inventory_ibm_svc_systemstats_diskio
,
132 "service_description": "Throughput %s Total",
133 "has_perfdata": True,
137 # .--iops----------------------------------------------------------------.
139 # | (_) ___ _ __ ___ |
140 # | | |/ _ \| '_ \/ __| |
141 # | | | (_) | |_) \__ \ |
142 # | |_|\___/| .__/|___/ |
144 # '----------------------------------------------------------------------'
147 def inventory_ibm_svc_systemstats_iops(info
):
148 return [(key
, None) for key
in ibm_svc_systemstats_parse(info
)]
151 def check_ibm_svc_systemstats_iops(item
, _no_params
, info
):
152 parsed
= ibm_svc_systemstats_parse(info
)
154 if item
not in parsed
.keys():
155 return 3, "%s not found in agent output" % item
157 read_iops
= parsed
[item
]['r_io']
158 write_iops
= parsed
[item
]['w_io']
159 perfdata
= [("read", read_iops
), ("write", write_iops
)]
161 return 0, "%s IO/s read, %s IO/s write" % (read_iops
, write_iops
), perfdata
164 check_info
["ibm_svc_systemstats.iops"] = {
165 "check_function": check_ibm_svc_systemstats_iops
,
166 "inventory_function": inventory_ibm_svc_systemstats_iops
,
167 "service_description": "IOPS %s Total",
168 "has_perfdata": True,
172 # .--disk latency--------------------------------------------------------.
174 # | __| (_)___| | __ | | __ _| |_ ___ _ __ ___ _ _ |
175 # | / _` | / __| |/ / | |/ _` | __/ _ \ '_ \ / __| | | | |
176 # | | (_| | \__ \ < | | (_| | || __/ | | | (__| |_| | |
177 # | \__,_|_|___/_|\_\ |_|\__,_|\__\___|_| |_|\___|\__, | |
179 # '----------------------------------------------------------------------'
182 def inventory_ibm_svc_systemstats_disk_latency(info
):
183 return [(key
, {}) for key
in ibm_svc_systemstats_parse(info
)]
186 def check_ibm_svc_systemstats_disk_latency(item
, params
, info
):
187 parsed
= ibm_svc_systemstats_parse(info
)
189 if item
not in parsed
.keys():
190 yield 3, "%s not found in agent output" % item
194 params
= {} # Convert from previous None
196 for what
, latency
in [('read', parsed
[item
]['r_ms']), ('write', parsed
[item
]['w_ms'])]:
199 latency
, what
+ "_latency", params
.get(what
), unit
="ms", infoname
="%s latency" % what
)
202 check_info
["ibm_svc_systemstats.disk_latency"] = {
203 "check_function": check_ibm_svc_systemstats_disk_latency
,
204 "inventory_function": inventory_ibm_svc_systemstats_disk_latency
,
205 "service_description": "Latency %s Total",
206 "has_perfdata": True,
207 "group": "ibm_svc_total_latency",
211 # .--cpu-----------------------------------------------------------------.
214 # | / __| '_ \| | | | |
215 # | | (__| |_) | |_| | |
216 # | \___| .__/ \__,_| |
219 # '----------------------------------------------------------------------'
221 ibm_svc_cpu_default_levels
= (90.0, 95.0)
224 def inventory_ibm_svc_systemstats_cpu(info
):
226 for stat_name
, _stat_current
, _stat_peak
, _stat_peak_time
in info
:
227 if stat_name
== "cpu_pc":
228 inventory
.append((None, "ibm_svc_cpu_default_levels"))
232 def check_ibm_svc_systemstats_cpu(item
, params
, info
):
233 for stat_name
, stat_current
, _stat_peak
, _stat_peak_time
in info
:
234 if stat_name
== "cpu_pc":
235 return check_cpu_util(int(stat_current
), params
)
237 return 3, "value cpu_pc not found in agent output for node %s" % item
240 check_info
["ibm_svc_systemstats.cpu_util"] = {
241 "check_function": check_ibm_svc_systemstats_cpu
,
242 "inventory_function": inventory_ibm_svc_systemstats_cpu
,
243 "service_description": "CPU utilization Total",
244 "has_perfdata": True,
245 "group": "cpu_utilization",
246 "includes": ["cpu_util.include"],
250 # .--cache---------------------------------------------------------------.
252 # | ___ __ _ ___| |__ ___ |
253 # | / __/ _` |/ __| '_ \ / _ \ |
254 # | | (_| (_| | (__| | | | __/ |
255 # | \___\__,_|\___|_| |_|\___| |
257 # '----------------------------------------------------------------------'
260 def inventory_ibm_svc_systemstats_cache(info
):
262 for stat_name
, _stat_current
, _stat_peak
, _stat_peak_time
in info
:
263 if stat_name
== "total_cache_pc":
264 inventory
.append((None, None))
268 def check_ibm_svc_systemstats_cache(item
, _no_params
, info
):
269 write_cache_pc
= None
270 total_cache_pc
= None
272 for stat_name
, stat_current
, _stat_peak
, _stat_peak_time
in info
:
273 if stat_name
== "total_cache_pc":
274 total_cache_pc
= int(stat_current
)
275 if stat_name
== "write_cache_pc":
276 write_cache_pc
= int(stat_current
)
278 if total_cache_pc
is None:
279 return 3, "value total_cache_pc not found in agent output"
280 if write_cache_pc
is None:
281 return 3, "value write_cache_pc not found in agent output"
283 perfdata
= [("write_cache_pc", write_cache_pc
, None, None, 0, 100),
284 ("total_cache_pc", total_cache_pc
, None, None, 0, 100)]
286 return 0, "Write cache usage is %d %%, total cache usage is %d %%" % \
287 (write_cache_pc
, total_cache_pc
), perfdata
290 check_info
["ibm_svc_systemstats.cache"] = {
291 "check_function": check_ibm_svc_systemstats_cache
,
292 "inventory_function": inventory_ibm_svc_systemstats_cache
,
293 "service_description": "Cache Total",
294 "has_perfdata": True,