GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / zpool
blobebc07d0aba0aeba01b30071a7132f8530d3bd403
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 # NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
28 # app02 39.8G 14.1G 25.6G 35% ONLINE -
29 # rpool 39.8G 32.9G 6.81G 82% ONLINE -
31 # Or also:
32 # NAME SIZE USED AVAIL CAP HEALTH ALTROOT
33 # sth_ds 278G 127G 151G 45% ONLINE -
36 def parse_zpool(info):
37 def canonize_header_entry(entry):
38 if entry == "used":
39 return "alloc"
40 elif entry == "avail":
41 return "free"
42 return entry
44 result = {}
45 if len(info) == 0:
46 return result
48 header = [canonize_header_entry(item.lower()) for item in info[0]]
49 for line in info[1:]:
50 result[line[0]] = dict(zip(header, line))
51 return result
54 def inventory_zpool(parsed):
55 return df_inventory(parsed.keys())
58 def check_zpool(item, params, parsed):
59 def mb(val):
60 idx = None
61 # split number from unit
62 for idx, ch in enumerate(val):
63 if ch not in "0123456789.-":
64 break
65 num = float(val[:idx])
66 unit = val[idx:].lstrip().lower()
67 unit = ["b", "k", "m", "g", "t"].index(unit)
69 return num * (1024**(unit - 2))
71 fslist = []
72 for pool, entry in parsed.iteritems():
73 if "patterns" in params or item == pool:
74 fslist.append((pool, mb(entry['size']), mb(entry['free']), 0))
76 return df_check_filesystem_list(item, params, fslist)
79 check_info['zpool'] = {
80 "check_function": check_zpool,
81 "inventory_function": inventory_zpool,
82 "parse_function": parse_zpool,
83 "service_description": "Storage Pool %s",
84 "has_perfdata": True,
85 "group": "filesystem",
86 "includes": ["size_trend.include", "df.include"],