Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / checks / dell_om_disks
blob16011863b65c43a4901ad851ae53f77f9d778a92
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.
28 def inventory_dell_om_disks(info):
29 return [("%s:%s:%s" % (x[3], x[4], x[5]), None) for x in info]
32 def check_dell_om_disks(item, _no_params, info):
33 #State definitions. Found in check_openmange from Trond H. Amundsen
34 spare_state = {
35 1: 'VD member', # disk is a member of a virtual disk
36 2: 'DG member', # disk is a member of a disk group
37 3: 'Global HS', # disk is a global hot spare
38 4: 'Dedicated HS', # disk is a dedicated hot spare
39 5: 'no', # not a spare
42 media_type = {
43 1: 'unknown',
44 2: 'HDD',
45 3: 'SSD',
48 bus_type = {
49 1: 'SCSI',
50 2: 'IDE',
51 3: 'Fibre Channel',
52 4: 'SSA',
53 6: 'USB',
54 7: 'SATA',
55 8: 'SAS',
58 pdisk_state = {
59 0: 'Unknown',
60 1: 'Ready',
61 2: 'Failed',
62 3: 'Online',
63 4: 'Offline',
64 6: 'Degraded',
65 7: 'Recovering',
66 11: 'Removed',
67 13: 'non-raid',
68 15: 'Resynching',
69 22: 'Replacing', # FIXME: this one is not defined in the OMSA MIBs
70 24: 'Rebuilding',
71 25: 'No Media',
72 26: 'Formatting',
73 28: 'Diagnostics',
74 34: 'Predictive failure',
75 35: 'Initializing',
76 41: 'Unsupported',
77 53: 'Incompatible',
78 39: 'Foreign',
79 40: 'Clear',
82 for name, dstate, pid, eid, cid, tid, sizeMB, btype, sstate, smart, mt in info:
83 ditem = "%s:%s:%s" % (eid, cid, tid)
84 if ditem == item:
85 state = 0
86 dstate = saveint(dstate)
87 btype = saveint(btype)
88 sstate = saveint(sstate)
89 smart = saveint(smart)
90 mt = saveint(mt)
91 size = saveint(sizeMB) * 1024 * 1024
92 msg = ["%s (%s, %s)" % (name, pid, get_bytes_human_readable(size))]
93 label = ""
94 if smart == 2:
95 dstate = 34
96 if dstate in [40, 35, 34, 26, 7, 4]:
97 state = 1
98 label = "(!)"
99 elif dstate not in [3, 1, 13]:
100 state = 2
101 label = "(!!)"
103 # handle hot spares as OK
104 if sstate in [3, 4] and dstate == 1:
105 state = 0
106 label = ""
108 msg.append("state %s%s" % (pdisk_state.get(dstate, 'ukn (%s)' % dstate), label))
109 msg.append("Bus Type: %s" % bus_type.get(btype, 'unk (%s)' % btype))
111 if sstate != 5:
112 msg.append("Spare State: %s" % spare_state.get(sstate, 'ukn (%s)' % sstate))
113 if mt != 0:
114 msg.append("Media Type: %s" % media_type.get(mt, 'ukn (%s)' % mt))
116 return state, ", ".join(msg)
117 return 3, "Device not found in SNMP tree"
120 check_info["dell_om_disks"] = {
121 "check_function": check_dell_om_disks,
122 "inventory_function": inventory_dell_om_disks,
123 "service_description": "Physical Disk %s",
124 # There is no other way to find out that openmanage is present.
125 "snmp_scan_function": scan_dell_om,
126 "snmp_info": (
127 ".1.3.6.1.4.1.674.10893.1.20.130.4.1",
129 2, # arrayDiskName
130 4, # arrayDiskState
131 6, # arrayDiskProductID
132 9, # arrayDiskEnclosureID
133 10, # arrayDiskChannel
134 15, # arrayDiskTargetID
135 11, # arrayDiskLengthInMB
136 21, # arrayDiskBusType
137 22, # arrayDiskSpareState
138 #24, #arrayDiskComponentStatus
139 31, #arrayDiskSmartAlertIndication
140 35, # arrayDiskMediaType
142 "includes": ["dell_om.include"],