GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / storcli_pdisks
blobff812c698bbfa9c6b519d5ed7cffa56b11ec421f
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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 factory_settings["storcli_pdisks_default_levels"] = {
28 "Dedicated Hot Spare": 0,
29 "Global Hot Spare": 0,
30 "Unconfigured Good": 0,
31 "Unconfigured Bad": 1,
32 "Online": 0,
33 "Offline": 2,
37 def parse_storcli_pdisks(info):
39 statenames = {
40 "DHS": "Dedicated Hot Spare",
41 "GHS": "Global Hot Spare",
42 "UGood": "Unconfigured Good",
43 "Ubad": "Unconfigured Bad",
44 "Onln": "Online",
45 "Offln": "Offline",
48 parsed = {}
50 separator_count = 0
51 for line in info:
52 if line[0].startswith("-----"):
53 separator_count += 1
54 elif separator_count == 2:
55 eid_and_slot, device, state, _drivegroup, size, size_unit = line[:6]
56 parsed[eid_and_slot + "-" + device] = {
57 "state": statenames.get(state, state),
58 "size": (float(size), size_unit)
60 if separator_count == 3:
61 break
63 return parsed
66 def inventory_storcli_pdisks(parsed):
67 for item in parsed:
68 yield (item, {})
71 def check_storcli_pdisks(item, params, parsed):
73 infotext = "Size: %f %s" % parsed[item]["size"]
75 diskstate = parsed[item]["state"]
76 infotext += ", Disk State: %s" % diskstate
78 status = params.get(diskstate, 3)
80 return status, infotext
83 check_info["storcli_pdisks"] = {
84 "default_levels_variable": "storcli_pdisks_default_levels",
85 "parse_function": parse_storcli_pdisks,
86 "inventory_function": inventory_storcli_pdisks,
87 "check_function": check_storcli_pdisks,
88 "service_description": "RAID PDisk EID:Slot-Device %s",
89 "group": "storcli_pdisks",