Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / hitachi_hus.include
blob11bcdafc13d391e9cb1957d57e3a9c239dcfcac7
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 # For Hitachi Unified Storage (HUS) devices which support the USPMIB
28 # This devices has two units: Disk Controller (DKC) and Disk Unit (DKC)
30 # Example output from DKC:
31 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.1 470849
32 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.2 1
33 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.3 1
34 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.4 1
35 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.5 1
36 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.6 5
37 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.7 1
38 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.8 1
39 #.1.3.6.1.4.1.116.5.11.4.1.1.6.1.9 1
41 # Example output from DKU:
42 #.1.3.6.1.4.1.116.5.11.4.1.1.7.1.1 470849
43 #.1.3.6.1.4.1.116.5.11.4.1.1.7.1.2 1
44 #.1.3.6.1.4.1.116.5.11.4.1.1.7.1.3 4
45 #.1.3.6.1.4.1.116.5.11.4.1.1.7.1.4 3
46 #.1.3.6.1.4.1.116.5.11.4.1.1.7.1.5 1
49 def scan_hitachi_hus(oid):
50 return "hm700" in oid(".1.3.6.1.2.1.1.1.0").lower() or \
51 "hm800" in oid(".1.3.6.1.2.1.1.1.0").lower()
54 def inventory_hitachi_hus(info):
55 for line in info:
56 # set dkuRaidListIndexSerialNumber as item
57 yield line[0], None
60 def check_hitachi_hus(item, _no_params, info):
61 # Maps for hitachi hus components
62 hus_map_states = {
63 "0": (3, "unknown"),
64 "1": (0, "no error"),
65 "2": (2, "acute"),
66 "3": (2, "serious"),
67 "4": (1, "moderate"),
68 "5": (1, "service"),
71 ok_states = []
72 warn_states = []
73 crit_states = []
74 unknown_states = []
76 # We need to take care that the right map type is checked
77 if len(info[0]) == 5:
78 component = [
79 "Processor",
80 "Fan",
81 "Environment",
82 "Drive",
84 else:
85 component = [
86 "Processor",
87 "Internal Bus",
88 "Cache",
89 "Shared Memory",
90 "Power Supply",
91 "Battery",
92 "Fan",
93 "Environment",
96 # Check the state of the components and add the output to the state lists
97 for line in info:
98 if line[0] != item:
99 continue
101 for what, device_state in zip(component, line[1:]):
102 state, state_readable = hus_map_states[device_state]
103 if state == 0:
104 ok_states.append("%s: %s" % (what, state_readable))
105 if state == 1:
106 warn_states.append("%s: %s" % (what, state_readable))
107 if state == 2:
108 crit_states.append("%s: %s" % (what, state_readable))
109 if state == 3:
110 unknown_states.append("%s: %s" % (what, state_readable))
112 for state, states, text in [
113 (0, ok_states, "OK"),
114 (3, unknown_states, "UNKNOWN"),
115 (1, warn_states, "WARN"),
116 (2, crit_states, "CRIT"),
118 if states:
119 yield state, "%s: %s" % (text, ", ".join(states))