2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 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.
28 def parse_ddn_s2a_stats(info
):
29 parsed
= parse_ddn_s2a_api_response(info
)
32 if key
.startswith(u
"All_ports"):
33 parsed
[key
] = parsed
[key
][0]
38 # .--Read hits-----------------------------------------------------------.
40 # | | _ \ ___ __ _ __| | | |__ (_) |_ ___ |
41 # | | |_) / _ \/ _` |/ _` | | '_ \| | __/ __| |
42 # | | _ < __/ (_| | (_| | | | | | | |_\__ \ |
43 # | |_| \_\___|\__,_|\__,_| |_| |_|_|\__|___/ |
45 # '----------------------------------------------------------------------'
47 ddn_s2a_readhits_default_levels
= (85.0, 70.0)
50 def inventory_ddn_s2a_stats_readhits(parsed
):
51 if u
"All_ports_Read_Hits" in parsed
:
52 yield "Total", "ddn_s2a_readhits_default_levels"
53 for nr
, _
in enumerate(parsed
.get(u
"Read_Hits", [])):
54 yield "%d" % (nr
+ 1), "ddn_s2a_readhits_default_levels"
57 def check_ddn_s2a_stats_readhits(item
, params
, parsed
):
60 read_hits
= float(parsed
[u
"All_ports_Read_Hits"])
62 read_hits
= float(parsed
[u
"Read_Hits"][int(item
) - 1])
64 infotext
= "%.1f%%" % read_hits
66 perfdata
= [("read_hits", read_hits
)] # TODO: Define metric
70 levelstext
= " (warn/crit below %.1f/%.1f%%)" % params
71 perfdata
= [("read_hits", read_hits
, warn
, crit
)]
74 infotext
+= levelstext
75 elif read_hits
< warn
:
77 infotext
+= levelstext
81 return status
, infotext
, perfdata
84 check_info
["ddn_s2a_stats.readhits"] = {
85 "inventory_function": inventory_ddn_s2a_stats_readhits
,
86 "check_function": check_ddn_s2a_stats_readhits
,
87 "service_description": "DDN S2A Read Hits %s",
93 # .--I/O transactions----------------------------------------------------.
101 # | | |_ _ __ __ _ _ __ ___ __ _ ___| |_(_) ___ _ __ ___ |
102 # | | __| '__/ _` | '_ \/ __|/ _` |/ __| __| |/ _ \| '_ \/ __| |
103 # | | |_| | | (_| | | | \__ \ (_| | (__| |_| | (_) | | | \__ \ |
104 # | \__|_| \__,_|_| |_|___/\__,_|\___|\__|_|\___/|_| |_|___/ |
106 # '----------------------------------------------------------------------'
108 factory_settings
["ddn_s2a_stats_io_default_levels"] = {
109 "total": (28000, 33000),
113 def inventory_ddn_s2a_stats_io(parsed
):
114 if u
"All_ports_Read_IOs" in parsed
:
116 for nr
, _
in enumerate(parsed
.get(u
"Read_IOs", [])):
117 yield "%d" % (nr
+ 1), {}
120 def check_ddn_s2a_stats_io(item
, params
, parsed
):
121 def check_io_levels(value
, levels
, infotext_formatstring
, perfname
=None):
122 infotext
= infotext_formatstring
% value
124 perfdata
= [(perfname
, value
)]
128 perfdata
= [(perfname
, value
, warn
, crit
)]
129 levelstext
= " (warn/crit at %.2f/%.2f 1/s)" % (warn
, crit
)
132 infotext
+= levelstext
135 infotext
+= levelstext
140 return status
, infotext
141 return status
, infotext
, perfdata
144 read_ios_s
= float(parsed
[u
"All_ports_Read_IOs"])
145 write_ios_s
= float(parsed
[u
"All_ports_Write_IOs"])
147 read_ios_s
= float(parsed
[u
"Read_IOs"][int(item
) - 1])
148 write_ios_s
= float(parsed
[u
"Write_IOs"][int(item
) - 1])
149 total_ios_s
= read_ios_s
+ write_ios_s
151 yield check_io_levels(read_ios_s
, params
.get("read"), "Read: %.2f 1/s", "disk_read_ios")
152 yield check_io_levels(write_ios_s
, params
.get("write"), "Write: %.2f 1/s", "disk_write_ios")
153 yield check_io_levels(total_ios_s
, params
.get("total"), "Total: %.2f 1/s")
156 check_info
["ddn_s2a_stats.io"] = {
157 "default_levels_variable": "ddn_s2a_stats_io_default_levels",
158 "inventory_function": inventory_ddn_s2a_stats_io
,
159 "check_function": check_ddn_s2a_stats_io
,
160 "service_description": "DDN S2A IO %s",
161 "has_perfdata": True,
162 "group": "storage_iops",
166 # .--Data rate-----------------------------------------------------------.
168 # | | _ \ __ _| |_ __ _ _ __ __ _| |_ ___ |
169 # | | | | |/ _` | __/ _` | | '__/ _` | __/ _ \ |
170 # | | |_| | (_| | || (_| | | | | (_| | || __/ |
171 # | |____/ \__,_|\__\__,_| |_| \__,_|\__\___| |
173 # '----------------------------------------------------------------------'
175 factory_settings
["ddn_s2a_stats_default_levels"] = {
176 "total": (4800 * 1024 * 1024, 5500 * 1024 * 1024),
180 def inventory_ddn_s2a_stats(parsed
):
181 if u
"All_ports_Read_MBs" in parsed
:
183 for nr
, _value
in enumerate(parsed
.get(u
"Read_MBs", [])):
184 yield "%d" % (nr
+ 1), {}
187 def check_ddn_s2a_stats(item
, params
, parsed
):
188 def check_datarate_levels(value
, value_mb
, levels
, infotext_formatstring
, perfname
=None):
189 infotext
= infotext_formatstring
% value_mb
191 perfdata
= [(perfname
, value
)]
195 warn_mb
, crit_mb
= [x
/ (1024 * 1024.0) for x
in levels
]
196 perfdata
= [(perfname
, value
, warn
, crit
)]
197 levelstext
= " (warn/crit at %.2f/%.2f MB/s)" % (warn_mb
, crit_mb
)
200 infotext
+= levelstext
203 infotext
+= levelstext
208 return status
, infotext
209 return status
, infotext
, perfdata
212 read_mb_s
= float(parsed
[u
"All_ports_Read_MBs"])
213 write_mb_s
= float(parsed
[u
"All_ports_Write_MBs"])
215 read_mb_s
= float(parsed
[u
"Read_MBs"][int(item
) - 1])
216 write_mb_s
= float(parsed
[u
"Write_MBs"][int(item
) - 1])
217 total_mb_s
= read_mb_s
+ write_mb_s
218 read
= read_mb_s
* 1024 * 1024
219 write
= write_mb_s
* 1024 * 1024
220 total
= total_mb_s
* 1024 * 1024
222 yield check_datarate_levels(read
, read_mb_s
, params
.get("read"), "Read: %.2f MB/s",
223 "disk_read_throughput")
224 yield check_datarate_levels(write
, write_mb_s
, params
.get("write"), "Write: %.2f MB/s",
225 "disk_write_throughput")
226 yield check_datarate_levels(total
, total_mb_s
, params
.get("total"), "Total: %.2f MB/s")
229 check_info
["ddn_s2a_stats"] = {
230 "default_levels_variable": "ddn_s2a_stats_default_levels",
231 "parse_function": parse_ddn_s2a_stats
,
232 "inventory_function": inventory_ddn_s2a_stats
,
233 "check_function": check_ddn_s2a_stats
,
234 "service_description": "DDN S2A Data Rate %s",
235 "includes": ["ddn_s2a.include"],
236 "group": "storage_throughput",
237 "has_perfdata": True,