2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 # OIDs for name and type of the sensors (type 8 = temperature sensor)
28 # SNMPv2-SMI::mib-2.47.1.1.1.1.2.21594 = STRING: "module-1 Crossbar(s5)"
29 # SNMPv2-SMI::mib-2.47.1.1.1.1.2.21601 = STRING: "module-1 QEng1Sn1(s12)"
30 # SNMPv2-SMI::mib-2.47.1.1.1.1.2.21602 = STRING: "module-1 QEng1Sn2(s13)"
31 # SNMPv2-SMI::mib-2.47.1.1.1.1.2.21603 = STRING: "module-1 QEng1Sn3(s14)"
32 # SNMPv2-SMI::mib-2.47.1.1.1.1.2.21604 = STRING: "module-1 QEng1Sn4(s15)"
33 # SNMPv2-SMI::mib-2.47.1.1.1.1.2.21605 = STRING: "module-1 QEng2Sn1(s16)"
34 # SNMPv2-SMI::mib-2.47.1.1.1.1.2.21606 = STRING: "module-1 QEng2Sn2(s17)"
37 # other(1): a measure other than those listed below
38 # unknown(2): unknown measurement, or arbitrary, relative numbers
39 # voltsAC(3): electric potential
40 # voltsDC(4): electric potential
41 # amperes(5): electric current
44 # celsius(8): temperature
45 # percentRH(9): percent relative humidity
46 # rpm(10): shaft revolutions per minute
47 # cmm(11),: cubic meters per minute (airflow)
48 # truthvalue(12): value takes { true(1), false(2) }
49 # specialEnum(13): value takes user defined enumerated values
50 # dBm(14): dB relative to 1mW of power
51 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.1.21594 = INTEGER: 8
52 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.1.21601 = INTEGER: 8
53 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.1.21602 = INTEGER: 8
54 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.1.21603 = INTEGER: 8
55 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.1.21604 = INTEGER: 8
56 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.1.21605 = INTEGER: 8
57 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.1.21606 = INTEGER: 8
60 # Current value of the sensor
61 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.4.21594 = INTEGER: 62
62 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.4.21601 = INTEGER: 102
63 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.4.21602 = INTEGER: 99
64 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.4.21603 = INTEGER: 98
65 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.4.21604 = INTEGER: 99
66 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.4.21605 = INTEGER: 101
67 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.4.21606 = INTEGER: 99
70 # State of the sensor itself
71 # ok(1) means the agent can read the sensor
74 # unavailable(2) means that the agent presently
75 # can not report the sensor value.
77 # nonoperational(3) means that the agent believes
78 # the sensor is broken. The sensor could have a
79 # hard failure (disconnected wire), or a soft failure
80 # such as out-of-range, jittery, or wildly fluctuating
82 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.5.21594 = INTEGER: 1
83 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.5.21601 = INTEGER: 1
84 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.5.21602 = INTEGER: 1
85 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.5.21603 = INTEGER: 1
86 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.5.21604 = INTEGER: 1
87 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.5.21605 = INTEGER: 1
88 # SNMPv2-SMI::enterprises.9.9.91.1.1.1.1.5.21606 = INTEGER: 1
91 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21594.9 = INTEGER: 95
92 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21594.10 = INTEGER: 105
93 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21601.23 = INTEGER: 110
94 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21601.24 = INTEGER: 115
95 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21602.25 = INTEGER: 110
96 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21602.26 = INTEGER: 115
97 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21603.27 = INTEGER: 110
98 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21603.28 = INTEGER: 115
99 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21604.29 = INTEGER: 110
100 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21604.30 = INTEGER: 115
101 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21605.31 = INTEGER: 110
102 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21605.32 = INTEGER: 115
103 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21606.33 = INTEGER: 110
104 # SNMPv2-SMI::enterprises.9.9.91.1.2.1.1.4.21606.34 = INTEGER: 115
107 # Create a dictionary with the information about each
108 # sensor. The key into the dict is the end OID of the
110 def parse_cisco_temp_sensor(info
):
111 description_info
, state_info
, levels_info
= info
113 # Create dict of sensor descriptions
114 descriptions
= dict(description_info
)
116 # Create dict with thresholds
118 for id_
, sensortype
, scale
, precision
, value
, sensorstate
in state_info
:
119 thresholds
.setdefault(id_
, [])
121 for endoid
, level
in levels_info
:
122 # endoid is e.g. 21549.9 or 21459.10
123 id_
, _subid
= endoid
.split('.')
124 thresholds
.setdefault(id_
, []).append(float(level
))
126 # Create main dictionary (only of temperature sensors)
128 for id_
, sensortype
, scale
, precision
, value
, sensorstate
in state_info
:
129 value
= float(value
) / (10**int(precision
))
130 threshold
= thresholds
[id_
] / (10**int(precision
))
132 sensors
.append((id_
, descriptions
.get(id_
), sensortype
, scale
, value
, sensorstate
,
137 def inventory_cisco_temp_sensor(info
):
138 # sensors = parse_cisco_temp_sensor(info)
140 # for id, descr, sensortype, scale, value, sensorstate, levels in sensors:
141 # # Use all temperature sensors with a non-empty description and valid threshold
142 # if descr is not None and sensortype == '8' and len(levels) in [ 2, 4 ]:
143 # warn, crit = saveint(levels[0]), saveint(levels[1])
144 # inventory.append(( descr, (warn, crit) ))
148 def check_cisco_temp_sensor(item
, params
, info
):
149 sensors
= parse_cisco_temp_sensor(info
)
150 for _id
, descr
, _sensortype
, _scale
, _temp
, _sensorstate
, _levels
in sensors
:
152 # # Use built in levels if no levels are configured
154 # warn, crit = params
156 # warn, crit = levels[0:2]
157 # # convert threshold milli values to native unit
162 # # convert milli temperature to native unit
166 # if sensorstate == "2":
167 # return (3, "Data from sensor currently not available")
168 # elif sensorstate == "3":
169 # return (3, "Sensor is broken")
171 # return check_temperature(temp, (warn, crit))
172 return 3, "This check is obsolete, please re-inventorize this host"
175 check_info
['cisco_temp_sensor'] = {
176 "check_function" : check_cisco_temp_sensor
,
177 "inventory_function" : inventory_cisco_temp_sensor
,
178 "service_description": "Temperature %s",
179 "has_perfdata" : True,
180 "snmp_scan_function" : lambda oid
: "cisco" in oid(".1.3.6.1.2.1.1.1.0").lower() and \
181 oid(".1.3.6.1.4.1.9.9.91.1.1.1.1.*") is not None,
183 ( ".1.3.6.1.2.1.47.1.1.1.1", [
185 2, # Description of the sensor
188 # Type and current state
189 ( ".1.3.6.1.4.1.9.9.91.1.1.1.1", [
191 1, # Type (see above), 8 = Celsius, 12 = truth value
192 2, # Scale, 8 == milli
194 4, # Most recent measurement
195 5, # Status of the sensor 1 == ok, 2 == cannot report, 3 == broken
199 ( ".1.3.6.1.4.1.9.9.91.1.2.1.1", [
204 "includes" : [ "temperature.include" ]