Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / infoblox_temp
blob75705c8c9412decc40814a5a37f6c68b314a1b6c
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 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.2.39 1 --> IB-PLATFORMONE-MIB::ibNodeServiceStatus.cpu1-temp
28 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.2.40 5 --> IB-PLATFORMONE-MIB::ibNodeServiceStatus.cpu2-temp
29 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.2.41 1 --> IB-PLATFORMONE-MIB::ibNodeServiceStatus.sys-temp
30 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.3.39 CPU_TEMP: +36.00 C --> IB-PLATFORMONE-MIB::ibNodeServiceDesc.cpu1-temp
31 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.3.40 No temperature information available. --> IB-PLATFORMONE-MIB::ibNodeServiceDesc.cpu2-temp
32 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.3.41 SYS_TEMP: +34.00 C --> IB-PLATFORMONE-MIB::ibNodeServiceDesc.sys-temp
34 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.2.39 5 --> IB-PLATFORMONE-MIB::ibNodeServiceStatus.cpu1-temp
35 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.2.40 5 --> IB-PLATFORMONE-MIB::ibNodeServiceStatus.cpu2-temp
36 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.2.41 5 --> IB-PLATFORMONE-MIB::ibNodeServiceStatus.sys-temp
37 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.3.39 --> IB-PLATFORMONE-MIB::ibNodeServiceDesc.cpu1-temp
38 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.3.40 --> IB-PLATFORMONE-MIB::ibNodeServiceDesc.cpu2-temp
39 # .1.3.6.1.4.1.7779.3.1.1.2.1.10.1.3.41 --> IB-PLATFORMONE-MIB::ibNodeServiceDesc.sys-temp
41 # Suggested by customer
42 factory_settings['infoblox_temp_default_levels'] = {
43 "levels": (40, 50),
47 def parse_infoblox_temp(info):
48 map_states = {
49 "1": (0, "working"),
50 "2": (1, "warning"),
51 "3": (2, "failed"),
52 "4": (1, "inactive"),
53 "5": (3, "unknown"),
56 parsed = {}
57 # Just for a better handling
58 for index, state, descr in \
59 zip(["", "1", "2", ""], info[0], info[1])[1:]:
60 if ":" in descr:
61 name, val_str = descr.split(":", 1)
62 val, unit = val_str.split()
63 val = float(val)
65 else:
66 name = descr
67 val = None
68 unit = None
70 what_name = "%s %s" % (name, index)
71 parsed.setdefault(what_name.strip(), {
72 "state": map_states[state],
73 "reading": val,
74 "unit": unit,
77 return parsed
80 def inventory_infoblox_temp(parsed):
81 for name, infos in parsed.items():
82 if infos["reading"] is not None and infos["unit"] is not None:
83 yield name, {}
86 def check_infoblox_temp(item, params, parsed):
87 if item in parsed:
88 reading = parsed[item]["reading"]
89 devunit = parsed[item]["unit"].lower()
90 devstate, devstatename = parsed[item]["state"]
91 return check_temperature(
92 reading,
93 params,
94 "infoblox_cpu_temp_%s" % item,
95 dev_status=devstate,
96 dev_status_name=devstatename,
97 dev_unit=devunit)
100 check_info['infoblox_temp'] = {
101 'parse_function': parse_infoblox_temp,
102 'inventory_function': inventory_infoblox_temp,
103 'check_function': check_infoblox_temp,
104 'service_description': 'Temperature %s',
105 'has_perfdata': True,
106 'snmp_info': (
107 ".1.3.6.1.4.1.7779.3.1.1.2.1.10.1",
108 ["2", "3"],
110 OID_END,
111 "39", # IB-PLATFORMONE-MIB::ibNodeService[Desc/Status].cpu1-temp
112 "40", # IB-PLATFORMONE-MIB::ibNodeService[Desc/Status].cpu2-temp
113 "41", # IB-PLATFORMONE-MIB::ibNodeService[Desc/Status].sys-temp
115 'snmp_scan_function': scan_infoblox,
116 'group': 'temperature',
117 'default_levels_variable': 'infoblox_temp_default_levels',
118 'includes': ["infoblox.include", "temperature.include"],