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