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.
28 def parse_casa_info_temp(info
):
29 entity_names
= {int(k
): v
for k
, v
in (x
for x
in info
[0])}
30 temp_value
= {int(k
): v
for k
, v
in (x
for x
in info
[1])}
31 temp_status
= {int(k
): v
for k
, v
in (x
for x
in info
[2])}
32 temp_unit
= {int(k
): v
for k
, v
in (x
for x
in info
[3])}
35 entry_nr
= int(entry
[0])
37 def beautify_module_text(text
):
38 text
= text
.replace("temperature sensor", "")
39 if text
.startswith("Module "):
40 text
= text
.rsplit(None, 1)[0] # Drop trailing " CPU"
43 data
[beautify_module_text(entity_names
[entry_nr
])] = {
44 "temp_value": temp_value
.get(entry_nr
),
45 "temp_status": temp_status
.get(entry_nr
),
46 "temp_unit": temp_unit
.get(entry_nr
),
51 def inventory_casa_cpu_temp(parsed
):
52 for key
, value
in parsed
.items():
53 if value
.get("temp_value"):
57 def check_casa_cpu_temp(item
, params
, parsed
):
59 if parsed
[item
]["temp_status"] == "1":
60 value
= float(parsed
[item
]["temp_value"]) / 10
61 return check_temperature(value
, params
, "case_cpu_temp_%s" % item
)
62 return (2, "Sensor failure!", [])
65 check_info
["casa_cpu_temp"] = {
66 "check_function": check_casa_cpu_temp
,
67 "inventory_function": inventory_casa_cpu_temp
,
68 "parse_function": parse_casa_info_temp
,
69 "service_description": "Temperature CPU %s",
70 "group": "temperature",
72 "snmp_scan_function": lambda oid
: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.20858.2."),
74 (".1.3.6.1.2.1.47.1.1.1.1.2", [OID_END
, '']), # Entity descriptions, quite long...
75 (".1.3.6.1.2.1.99.1.1.1.4", [OID_END
, '']), # Temperatures, Value
76 (".1.3.6.1.2.1.99.1.1.1.5", [OID_END
, '']), # Temperatures, Status
77 (".1.3.6.1.2.1.99.1.1.1.6", [OID_END
, '']), # Temperatures, Unit
79 "includes": ["temperature.include"]