Cleanup config.nodes_of
[check_mk.git] / checks / hp_hh3c_ext
blobbae4bc3fb265abb0f33a76d36a683ec6d1c5a3de
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2018 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 parse_hp_hh3c_ext(info):
29 entity_info = dict(info[1])
30 parsed = {}
31 for index, admin_state, oper_state, cpu, \
32 mem_usage, temperature, mem_size in info[0]:
33 name = entity_info.get(index, (None, None))
35 # mem_size measured in 'bytes' (hh3cEntityExtMemSize)
36 # check_memory_multiitem needs values in bytes, not percent
37 mem_total = int(mem_size)
38 mem_used = 0.01 * int(mem_usage) * mem_total
40 parsed.setdefault(
41 "%s %s" % (name, index), {
42 'temp': int(temperature),
43 'cpu': int(cpu),
44 'mem_total': mem_total,
45 'mem_used': mem_used,
46 'admin': admin_state,
47 'oper': oper_state,
49 return parsed
52 # .--temperature---------------------------------------------------------.
53 # | _ _ |
54 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
55 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
56 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
57 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
58 # | |_| |
59 # '----------------------------------------------------------------------'
62 def inventory_hp_hh3c_ext(parsed):
63 for k, v in parsed.iteritems():
64 # The invalid value is 65535.
65 # We assume: If mem_total <= 0, this module is not installed or
66 # does not provide reasonable data or is not a real sensor.
67 if v["temp"] != 65535 and v['mem_total'] > 0:
68 yield k, {}
71 def check_hp_hh3c_ext(item, params, parsed):
72 if item not in parsed:
73 return
74 return check_temperature(parsed[item]['temp'], params, "hp_hh3c_ext.%s" % item)
77 check_info['hp_hh3c_ext'] = {
78 'parse_function': parse_hp_hh3c_ext,
79 'inventory_function': inventory_hp_hh3c_ext,
80 'check_function': check_hp_hh3c_ext,
81 'service_description': 'Temperature %s',
82 'snmp_info': [
84 '.1.3.6.1.4.1.25506.2.6.1.1.1.1',
85 [ # HH3C-ENTITY-EXT-MIB
86 OID_END,
87 '2', # hh3cEntityExtAdminStatus
88 '3', # hh3cEntityExtOperStatus
89 '6', # hh3cEntityExtCpuUsage
90 '8', # hh3cEntityExtMemUsage
91 '12', # hh3cEntityExtTemperature
92 '10', # hh3cEntityExtMemSize
93 ]),
95 '.1.3.6.1.2.1.47.1.1.1.1',
97 OID_END,
98 CACHED_OID(2), # entPhysicalDescr
101 'snmp_scan_function': lambda oid: oid('.1.3.6.1.2.1.1.2.0').startswith(
102 '.1.3.6.1.4.1.25506.11.1.239'),
103 'includes': ['temperature.include'],
104 'group': 'temperature',
105 'has_perfdata': True,
109 # .--states--------------------------------------------------------------.
110 # | _ _ |
111 # | ___| |_ __ _| |_ ___ ___ |
112 # | / __| __/ _` | __/ _ \/ __| |
113 # | \__ \ || (_| | || __/\__ \ |
114 # | |___/\__\__,_|\__\___||___/ |
115 # | |
116 # '----------------------------------------------------------------------'
119 def inventory_hp_hh3c_ext_states(parsed):
120 for k, v in parsed.iteritems():
121 if v["mem_total"] > 0:
122 # We assume: if mem_total > 0 then
123 # this module is installed and provides
124 # reasonable data.
125 yield k, {}
128 def check_hp_hh3c_ext_states(item, params, parsed):
129 if item not in parsed:
130 return
132 map_admin_states = {
133 '1': (1, 'not_supported', 'not supported'),
134 '2': (0, 'locked', 'locked'),
135 '3': (2, 'shutting_down', 'shutting down'),
136 '4': (2, 'unlocked', 'unlocked'),
138 map_oper_states = {
139 '1': (1, 'not_supported', 'not supported'),
140 '2': (2, 'disabled', 'disabled'),
141 '3': (0, 'enabled', 'enabled'),
142 '4': (2, 'dangerous', 'dangerous'),
145 attrs = parsed[item]
146 for state_type, title, mapping in [('admin', 'Administrative', map_admin_states),
147 ('oper', 'Operational', map_oper_states)]:
148 dev_state = attrs[state_type]
149 state, params_key, state_readable = mapping.get(dev_state, (3, 'unknown[%s]' % dev_state))
150 params_state_type = params.get(state_type, {})
151 if params_key in params_state_type:
152 state = params_state_type[params_key]
153 yield state, "%s: %s" % (title, state_readable)
156 check_info['hp_hh3c_ext.states'] = {
157 'inventory_function': inventory_hp_hh3c_ext_states,
158 'check_function': check_hp_hh3c_ext_states,
159 'service_description': 'Status %s',
160 'group': 'hp_hh3c_ext_states',
164 # .--CPU utilization-----------------------------------------------------.
165 # | ____ ____ _ _ _ _ _ _ _ _ |
166 # | / ___| _ \| | | | _ _| |_(_) (_)______ _| |_(_) ___ _ __ |
167 # | | | | |_) | | | | | | | | __| | | |_ / _` | __| |/ _ \| '_ \ |
168 # | | |___| __/| |_| | | |_| | |_| | | |/ / (_| | |_| | (_) | | | | |
169 # | \____|_| \___/ \__,_|\__|_|_|_/___\__,_|\__|_|\___/|_| |_| |
170 # | |
171 # '----------------------------------------------------------------------'
174 def inventory_hp_hh3c_ext_cpu(parsed):
175 for k, v in parsed.iteritems():
176 if v["mem_total"] > 0:
177 # We assume: if mem_total > 0 then
178 # this module is installed and provides
179 # reasonable data.
180 yield k, {}
183 def check_hp_hh3c_ext_cpu(item, params, parsed):
184 if item not in parsed:
185 return
186 return check_cpu_util(parsed[item]['cpu'], params)
189 check_info['hp_hh3c_ext.cpu'] = {
190 'inventory_function': inventory_hp_hh3c_ext_cpu,
191 'check_function': check_hp_hh3c_ext_cpu,
192 'service_description': 'CPU utilization %s',
193 'includes': ['cpu_util.include'],
194 'group': 'cpu_utilization_multiitem',
195 'has_perfdata': True,
199 # .--memory--------------------------------------------------------------.
200 # | |
201 # | _ __ ___ ___ _ __ ___ ___ _ __ _ _ |
202 # | | '_ ` _ \ / _ \ '_ ` _ \ / _ \| '__| | | | |
203 # | | | | | | | __/ | | | | | (_) | | | |_| | |
204 # | |_| |_| |_|\___|_| |_| |_|\___/|_| \__, | |
205 # | |___/ |
206 # '----------------------------------------------------------------------'
208 factory_settings['hp_hh3c_ext_mem_default_levels'] = {
209 "levels": (80.0, 90.0),
213 def inventory_hp_hh3c_ext_mem(parsed):
214 for name, attrs in parsed.iteritems():
215 if attrs["mem_total"] > 0:
216 # We assume: if mem_total > 0 then
217 # this module is installed and provides
218 # reasonable data.
219 yield name, {}
222 def check_hp_hh3c_ext_mem(item, params, parsed):
223 if item not in parsed:
224 return
225 return check_memory_multiitem(params, parsed[item])
228 check_info['hp_hh3c_ext.mem'] = {
229 'inventory_function': inventory_hp_hh3c_ext_mem,
230 'check_function': check_hp_hh3c_ext_mem,
231 'service_description': 'Memory %s',
232 'includes': ['memory.include'],
233 'group': 'memory_multiitem',
234 'has_perfdata': True,
235 'default_levels_variable': 'hp_hh3c_ext_mem_default_levels',