GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / hp_msa_volume
blob485a89958db1cec69455e86ea72169cf06872da8
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 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 # <<<hp_msa_volume>>>
28 # volumes 1 durable-id V0
29 # volumes 1 virtual-disk-name IMSAKO2B1_U1_B01-04
30 # volumes 1 storage-pool-name IMSAKO2B1_U1_B01-04
31 # volumes 1 volume-name IMSAKO2B1_U1_B01-04_v0001
32 # volumes 1 size 1198.9GB
33 # volumes 1 size-numeric 2341789696
34 # volumes 1 total-size 1198.9GB
35 # volumes 1 total-size-numeric 2341789696
36 # volumes 1 allocated-size 1198.9GB
37 # volumes 1 allocated-size-numeric 2341789696
38 # volumes 1 storage-type Linear
39 # volumes 1 storage-type-numeric 0
40 # volumes 1 preferred-owner A
41 # volumes 1 preferred-owner-numeric 1
42 # volumes 1 owner A
43 # volumes 1 owner-numeric 1
44 # volumes 1 serial-number 00c0ff1ec44a00008425415501000000
45 # volumes 1 write-policy write-back
46 # volumes 1 write-policy-numeric 1
47 # volumes 1 cache-optimization standard
48 # volumes 1 cache-optimization-numeric 0
49 # volumes 1 read-ahead-size Adaptive
50 # volumes 1 read-ahead-size-numeric -1
51 # volumes 1 volume-type standard
52 # volumes 1 volume-type-numeric 0
53 # volumes 1 volume-class standard
54 # volumes 1 volume-class-numeric 0
55 # volumes 1 profile-preference Standard
56 # volumes 1 profile-preference-numeric 0
57 # volumes 1 snapshot No
58 # volumes 1 volume-qualifier N/A
59 # volumes 1 volume-qualifier-numeric 0
60 # volumes 1 blocks 2341789696
61 # volumes 1 capabilities dmscer
62 # volumes 1 volume-parent
63 # volumes 1 snap-pool
64 # volumes 1 replication-set
65 # volumes 1 attributes
66 # volumes 1 virtual-disk-serial 00c0ff1ec44a00001e23415500000000
67 # volumes 1 volume-description
68 # volumes 1 wwn 600C0FF0001EC44A8425415501000000
69 # volumes 1 progress 0%
70 # volumes 1 progress-numeric 0
71 # volumes 1 container-name IMSAKO2B1_U1_B01-04
72 # volumes 1 container-serial 00c0ff1ec44a00001e23415500000000
73 # volumes 1 allowed-storage-tiers N/A
74 # volumes 1 allowed-storage-tiers-numeric 0
75 # volumes 1 threshold-percent-of-pool 0
76 # volumes 1 reserved-size-in-pages 0
77 # volumes 1 allocate-reserved-pages-first Disabled
78 # volumes 1 allocate-reserved-pages-first-numeric 0
79 # volumes 1 zero-init-page-on-allocation Disabled
80 # volumes 1 zero-init-page-on-allocation-numeric 0
81 # volumes 1 raidtype RAID10
82 # volumes 1 raidtype-numeric 10
83 # volumes 1 pi-format T0
84 # volumes 1 pi-format-numeric 0
85 # volumes 1 health OK
86 # volumes 1 health-numeric 0
87 # volumes 1 health-reason
88 # volumes 1 health-recommendation
89 # volumes 1 volume-group UNGROUPEDVOLUMES
90 # volumes 1 group-key VGU
91 # volume-statistics 1 volume-name IMSAKO2B1_U1_B01-04_v0001
92 # volume-statistics 1 serial-number 00c0ff1ec44a00008425415501000000
93 # volume-statistics 1 bytes-per-second 2724.3KB
94 # volume-statistics 1 bytes-per-second-numeric 2724352
95 # volume-statistics 1 iops 66
96 # volume-statistics 1 number-of-reads 11965055
97 # volume-statistics 1 number-of-writes 80032996
98 # volume-statistics 1 data-read 1241.3GB
99 # volume-statistics 1 data-read-numeric 1241361379840
100 # volume-statistics 1 data-written 6462.6GB
101 # volume-statistics 1 data-written-numeric 6462660316672
102 # volume-statistics 1 allocated-pages 0
103 # volume-statistics 1 percent-tier-ssd 0
104 # volume-statistics 1 percent-tier-sas 0
105 # volume-statistics 1 percent-tier-sata 0
106 # volume-statistics 1 percent-allocated-rfc 0
107 # volume-statistics 1 pages-alloc-per-minute 0
108 # volume-statistics 1 pages-dealloc-per-minute 0
109 # volume-statistics 1 shared-pages 0
110 # volume-statistics 1 write-cache-hits 93581599
111 # volume-statistics 1 write-cache-misses 345571865
112 # volume-statistics 1 read-cache-hits 29276023
113 # volume-statistics 1 read-cache-misses 54728207
114 # volume-statistics 1 small-destages 36593447
115 # volume-statistics 1 full-stripe-write-destages 4663277
116 # volume-statistics 1 read-ahead-operations 4804068203594569116
117 # volume-statistics 1 write-cache-space 74
118 # volume-statistics 1 write-cache-percent 8
119 # volume-statistics 1 reset-time 2015-05-22 13:54:36
120 # volume-statistics 1 reset-time-numeric 1432302876
121 # volume-statistics 1 start-sample-time 2015-08-21 11:51:17
122 # volume-statistics 1 start-sample-time-numeric 1440157877
123 # volume-statistics 1 stop-sample-time 2015-08-21 11:51:48
124 # volume-statistics 1 stop-sample-time-numeric 1440157908
126 # .--health--------------------------------------------------------------.
127 # | _ _ _ _ |
128 # | | |__ ___ __ _| | |_| |__ |
129 # | | '_ \ / _ \/ _` | | __| '_ \ |
130 # | | | | | __/ (_| | | |_| | | | |
131 # | |_| |_|\___|\__,_|_|\__|_| |_| |
132 # | |
133 # +----------------------------------------------------------------------+
134 # | main check |
135 # '----------------------------------------------------------------------'
138 def _get_item_data(item, parsed):
139 # ensure backward compatibility: get data in case either item is
140 # "durable-id" (old) or item is "volume-name" (new)
141 for k, v in parsed.iteritems():
142 if item in [k, v["durable-id"]]:
143 return {item: v}
144 return {}
147 def check_hp_msa_volume_health(item, params, parsed):
148 parsed = _get_item_data(item, parsed)
149 return check_hp_msa_health(item, params, parsed)
152 def parse_hp_msa_volume(info):
153 # use numerical id (2nd row from left) as uid for items,
154 # in case of several values the values are whitespace separated as usual
155 item_type_idx = 0
156 numerical_id_idx = 1
157 key_idx = 2
158 value_idx = 3
159 min_list_elements_cnt_with_values = 4
160 pre_parsed = {}
162 for line in info:
163 if len(line) < min_list_elements_cnt_with_values:
164 # make parsing robust against too short lists
165 continue
166 item_type = line[item_type_idx]
167 numerical_id = line[numerical_id_idx]
168 key = line[key_idx]
169 values = " ".join(line[value_idx:])
170 pre_parsed.setdefault(numerical_id, {}).setdefault(key, values)
171 # set item type for lists with "volumes" in first element only
172 # which is the case in case the 3rd element is "durable-id"
173 if key == "durable-id":
174 pre_parsed.setdefault(numerical_id, {}).setdefault("item_type", item_type)
176 # replace numerical id with volume-name as uid for items, convert data
177 parsed = {}
178 for v in pre_parsed.itervalues():
179 parsed.setdefault(v['volume-name'], v)
181 return parsed
184 check_info['hp_msa_volume'] = {
185 'parse_function': parse_hp_msa_volume,
186 'inventory_function': inventory_hp_msa_health,
187 'check_function': check_hp_msa_volume_health,
188 'service_description': 'Volume Health %s',
189 'includes': ["hp_msa.include"],
193 # .--volume df-----------------------------------------------------------.
194 # | _ _ __ |
195 # | __ _____ | |_ _ _ __ ___ ___ __| |/ _| |
196 # | \ \ / / _ \| | | | | '_ ` _ \ / _ \ / _` | |_ |
197 # | \ V / (_) | | |_| | | | | | | __/ | (_| | _| |
198 # | \_/ \___/|_|\__,_|_| |_| |_|\___| \__,_|_| |
199 # | |
200 # +----------------------------------------------------------------------+
203 def inventory_hp_msa_volume_df(parsed):
204 for key in parsed.keys():
205 yield key, {}
208 def check_hp_msa_volume_df(item, params, parsed):
209 parsed = _get_item_data(item, parsed)
210 if item in parsed:
211 yield 0, "%s (%s)" % (parsed[item]["virtual-disk-name"], parsed[item]["raidtype"])
213 size_mb = (int(parsed[item]["total-size-numeric"]) * 512) / 1024**2
214 alloc_mb = (int(parsed[item]["allocated-size-numeric"]) * 512) / 1024**2
215 avail_mb = size_mb - alloc_mb
217 yield df_check_filesystem_single(item, size_mb, avail_mb, 0, None, None, params)
220 check_info['hp_msa_volume.df'] = {
221 'inventory_function': inventory_hp_msa_volume_df,
222 'check_function': check_hp_msa_volume_df,
223 'service_description': 'Filesystem %s',
224 'has_perfdata': True,
225 "group": "filesystem",
226 'default_levels_variable': "filesystem_default_levels",
227 'includes': ["hp_msa.include", "size_trend.include", "df.include"],
231 # .--volume IO-----------------------------------------------------------.
232 # | _ ___ ___ |
233 # | __ _____ | |_ _ _ __ ___ ___ |_ _/ _ \ |
234 # | \ \ / / _ \| | | | | '_ ` _ \ / _ \ | | | | | |
235 # | \ V / (_) | | |_| | | | | | | __/ | | |_| | |
236 # | \_/ \___/|_|\__,_|_| |_| |_|\___| |___\___/ |
237 # | |
238 # '----------------------------------------------------------------------'
241 def check_hp_msa_volume_io(item, params, parsed):
242 disks = {}
243 for key, values in parsed.items():
244 now = time.time()
245 read_numeric = values["data-read-numeric"]
246 written_numeric = values["data-written-numeric"]
247 disks[key] = {
248 "read_throughput": get_rate("%s_read" % key, now, int(read_numeric)),
249 "write_throughput": get_rate("%s_writte" % key, now, int(written_numeric)),
252 if item != "SUMMARY":
253 yield 0, "%s (%s)" % (parsed[item]["virtual-disk-name"], parsed[item]["raidtype"])
255 subresults = list(check_diskstat_dict(item, params, disks))
256 for entry in subresults:
257 yield entry
260 check_info['hp_msa_volume.io'] = {
261 'inventory_function': inventory_hp_msa_io,
262 'check_function': check_hp_msa_volume_io,
263 'service_description': 'Volume IO %s',
264 'has_perfdata': True,
265 'group': 'diskstat',
266 'includes': ["hp_msa.include", "diskstat.include"],