Module: check_mk
Branch: master
Commit: 18ad6d09362265b45594c44410ae1fc5acfcdae6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=18ad6d09362265…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Wed Dec 5 12:40:55 2018 +0100
refactor alcatel_temp check
CMK-1188
Change-Id: Ie6e6e5e0dc3783b3a566ea57015bb6a530ead88f
---
checks/alcatel.include | 32 ++++++++++++++++++++++++++++++++
checks/alcatel_temp | 43 +++++--------------------------------------
2 files changed, 37 insertions(+), 38 deletions(-)
diff --git a/checks/alcatel.include b/checks/alcatel.include
index d000cda..fdf4d2c 100644
--- a/checks/alcatel.include
+++ b/checks/alcatel.include
@@ -24,6 +24,10 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+factory_settings['alcatel_temp'] = {
+ "levels": (45, 50),
+}
+
def alcatel_networking_products_scan_function(oid):
sys_object_id = ".1.3.6.1.2.1.1.2.0" # MIB object "sysObjectID"
@@ -52,3 +56,31 @@ def check_alcatel_power(item, _no_params, info):
return 2, "Supply in error condition (%s)" % status
return 0, "Supply status OK"
return 3, "Supply not found"
+
+
+def inventory_alcatel_temp(info):
+ with_slot = len(info) != 1
+ for index, row in enumerate(info):
+ for oid, name in enumerate(["Board", "CPU"]):
+ if row[oid] != '0':
+ if with_slot:
+ yield "Slot %s %s" % (index + 1, name), {}
+ else:
+ yield name, {}
+
+
+def check_alcatel_temp(item, params, info):
+ if len(info) == 1:
+ slot_index = 0
+ else:
+ slot = int(item.split()[1])
+ slot_index = slot - 1
+ sensor = item.split()[-1]
+ items = {"Board": 0, "CPU": 1}
+ try:
+ # If multiple switches are staked and one of them are
+ # not reachable, prevent a exception
+ temp_celsius = int(info[slot_index][items[sensor]])
+ except:
+ return 3, "Sensor not found"
+ return check_temperature(temp_celsius, params, "alcatel_temp_%s" % item)
diff --git a/checks/alcatel_temp b/checks/alcatel_temp
index 87cf2ed..ed12630 100644
--- a/checks/alcatel_temp
+++ b/checks/alcatel_temp
@@ -24,39 +24,6 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-factory_settings['alcatel_temp'] = {
- "levels": (45, 50),
-}
-
-
-def inventory_alcatel_temp(info):
- with_slot = len(info) != 1
- for index, row in enumerate(info):
- for oid, name in enumerate(["Board", "CPU"]):
- if row[oid] != '0':
- if with_slot:
- yield "Slot %s %s" % (index + 1, name), {}
- else:
- yield name, {}
-
-
-def check_alcatel_temp(item, params, info):
- if len(info) == 1:
- slot_index = 0
- else:
- slot = int(item.split()[1])
- slot_index = slot - 1
- sensor = item.split()[-1]
- items = {"Board": 0, "CPU": 1}
- try:
- # If multiple switches are staked and one of them are
- # not reachable, prevent a exception
- temp_celsius = int(info[slot_index][items[sensor]])
- except:
- return 3, "Sensor not found"
- return check_temperature(temp_celsius, params, "alcatel_temp_%s" % item)
-
-
check_info["alcatel_temp"] = {
"check_function": check_alcatel_temp,
"inventory_function": inventory_alcatel_temp,
@@ -64,12 +31,12 @@ check_info["alcatel_temp"] = {
"group": "temperature",
"default_levels_variable": "alcatel_temp",
"has_perfdata": True,
- "snmp_scan_function": lambda oid:
oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.6486.800"),
+ "snmp_scan_function": alcatel_networking_products_scan_function,
"snmp_info": (
- ".1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1",
+ ".1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1", # MIB object
"alaChasEntPhysFanTable"
[
- 4, # chasHardwareBoardTemp
- 5, # chasHardwareCpuTemp
+ 4, # MIB object "chasHardwareBoardTemp"
+ 5, # MIB object "chasHardwareCpuTemp"
]),
- "includes": ["temperature.include"],
+ "includes": ["alcatel.include",
"temperature.include"],
}