Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / intel_true_scale_sensors_temp
blob4bdd3155d329d922ab86d8251a30a4534fae0290
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.10222.2.1.2.9.1.1.1.1.1 1 --> ICS-CHASSIS-MIB::icsChassisSlotIndex.1.1.1
28 # .1.3.6.1.4.1.10222.2.1.2.9.1.1.1.2.1 2 --> ICS-CHASSIS-MIB::icsChassisSlotIndex.1.2.1
30 # .1.3.6.1.4.1.10222.2.1.9.8.1.2.1.1.1 2 --> ICS-CHASSIS-MIB::icsChassisSensorSlotType.1.1.1
31 # .1.3.6.1.4.1.10222.2.1.9.8.1.2.1.1.2 2 --> ICS-CHASSIS-MIB::icsChassisSensorSlotType.1.1.2
32 # .1.3.6.1.4.1.10222.2.1.9.8.1.2.1.2.1 2 --> ICS-CHASSIS-MIB::icsChassisSensorSlotType.1.2.1
33 # .1.3.6.1.4.1.10222.2.1.9.8.1.2.1.2.2 2 --> ICS-CHASSIS-MIB::icsChassisSensorSlotType.1.2.2
34 # .1.3.6.1.4.1.10222.2.1.9.8.1.3.1.1.1 4 --> ICS-CHASSIS-MIB::icsChassisSensorSlotOperStatus.1.1.1
35 # .1.3.6.1.4.1.10222.2.1.9.8.1.3.1.1.2 4 --> ICS-CHASSIS-MIB::icsChassisSensorSlotOperStatus.1.1.2
36 # .1.3.6.1.4.1.10222.2.1.9.8.1.3.1.2.1 4 --> ICS-CHASSIS-MIB::icsChassisSensorSlotOperStatus.1.2.1
37 # .1.3.6.1.4.1.10222.2.1.9.8.1.3.1.2.2 4 --> ICS-CHASSIS-MIB::icsChassisSensorSlotOperStatus.1.2.2
38 # .1.3.6.1.4.1.10222.2.1.9.8.1.7.1.1.1 FUSION -- baseboard temp --> ICS-CHASSIS-MIB::icsChassisSensorSlotDescription.1.1.1
39 # .1.3.6.1.4.1.10222.2.1.9.8.1.7.1.1.2 FUSION -- fusion temp --> ICS-CHASSIS-MIB::icsChassisSensorSlotDescription.1.1.2
40 # .1.3.6.1.4.1.10222.2.1.9.8.1.7.1.2.1 FUSION -- baseboard temp --> ICS-CHASSIS-MIB::icsChassisSensorSlotDescription.1.2.1
41 # .1.3.6.1.4.1.10222.2.1.9.8.1.7.1.2.2 FUSION -- fusion temp --> ICS-CHASSIS-MIB::icsChassisSensorSlotDescription.1.2.2
42 # .1.3.6.1.4.1.10222.2.1.9.8.1.8.1.1.1 41 --> ICS-CHASSIS-MIB::icsChassisSensorSlotValue.1.1.1
43 # .1.3.6.1.4.1.10222.2.1.9.8.1.8.1.1.2 32 --> ICS-CHASSIS-MIB::icsChassisSensorSlotValue.1.1.2
44 # .1.3.6.1.4.1.10222.2.1.9.8.1.8.1.2.1 49 --> ICS-CHASSIS-MIB::icsChassisSensorSlotValue.1.2.1
45 # .1.3.6.1.4.1.10222.2.1.9.8.1.8.1.2.2 31 --> ICS-CHASSIS-MIB::icsChassisSensorSlotValue.1.2.2
48 def parse_intel_true_scale_sensors(info):
49 map_slot_types = {
50 "0": "unspecified",
51 "1": "switch master",
52 "2": "switch slave",
53 "3": "eiou",
54 "4": "fciou",
55 "5": "other",
56 "6": "spine master",
57 "7": "spine slave",
58 "8": "spine",
59 "9": "leaf",
60 "10": "viofx",
61 "11": "vioex",
62 "12": "shuttle master",
63 "13": "shuttle slave",
64 "14": "xMM master",
65 "15": "xMM slave",
66 "16": "xspine",
67 "17": "xQleaf",
68 "18": "xDleaf",
69 "19": "xVioFx",
70 "20": "xVioEx"
73 map_sensor_types = {
74 "1": "other",
75 "2": "temp",
76 "3": "fan",
77 "4": "humid",
78 "5": "acpower",
79 "6": "dcpower",
80 "7": "slot",
81 "8": "fuse",
84 map_states = {
85 "0": (2, "invalid"),
86 "1": (3, "unknown"),
87 "2": (2, "bad"),
88 "3": (1, "warning"),
89 "4": (0, "good"),
90 "5": (3, "disabled"),
93 slots, sensors = info
94 parsed = {}
95 for slot_id, slot_ty in slots:
96 parsed.setdefault("slot %s" % slot_id, {"slot_type": map_slot_types[slot_ty]})
98 for oid_end, ty, status, descr, reading_str in sensors:
99 slot_id, sensor_id = oid_end.split(".")[1:]
100 slot_name = "slot %s" % slot_id
101 sensor_name = " ".join(descr.split(" ")[2:-1])
103 # We do not known for all sensors. Feel free to extend
104 if ty in ["5", "6"]:
105 factor = 0.001
106 else:
107 factor = 1
109 state, state_readable = map_states[status]
110 kwargs = {"dev_status": state, "dev_status_name": state_readable}
112 sensor_ty = map_sensor_types[ty]
113 parsed[slot_name].setdefault(sensor_ty, [])
114 parsed[slot_name][sensor_ty].append(("%s %s" % (sensor_id, sensor_name),
115 float(reading_str) * factor, kwargs))
117 return parsed
120 # .--temperature---------------------------------------------------------.
121 # | _ _ |
122 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
123 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
124 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
125 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
126 # | |_| |
127 # +----------------------------------------------------------------------+
128 # | main check |
129 # '----------------------------------------------------------------------'
132 def inventory_intel_true_scale_sensors_temp(parsed):
133 for slot_name, slot_info in parsed.items():
134 if slot_info.get("temp"):
135 yield slot_name, {}
138 def check_intel_true_scale_sensors_temp(item, params, parsed):
139 if item in parsed:
140 yield check_temperature_list(parsed[item]["temp"], params,
141 "intel_true_scale_sensors_temp_%s" % item)
144 check_info['intel_true_scale_sensors_temp'] = {
145 'parse_function': parse_intel_true_scale_sensors,
146 'inventory_function': inventory_intel_true_scale_sensors_temp,
147 'check_function': check_intel_true_scale_sensors_temp,
148 'service_description': 'Temperature sensors %s',
149 'has_perfdata': True,
150 'snmp_info': [
152 ".1.3.6.1.4.1.10222.2.1.2.9.1",
154 "1", # ICS-CHASSIS-MIB::icsChassisSlotIndex
155 "3", # ICS-CHASSIS-MIB::icsChassisSlotCardType
158 ".1.3.6.1.4.1.10222.2.1.9.8.1",
160 OID_END,
161 "2", # icsChassisSensorSlotType
162 "3", # icsChassisSensorSlotOperStatus
163 "7", # icsChassisSensorSlotDescription
164 "8", # icsChassisSensorSlotValue
167 'snmp_scan_function': scan_intel_true_scale,
168 'includes': ['temperature.include', 'intel_true_scale.include'],