Module: check_mk
Branch: master
Commit: 2fd015505e104efc53da7117583245aa98532af9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2fd015505e104e…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Wed Dec 5 12:40:55 2018 +0100
refactor alcatel_cpu check
CMK-1188
Change-Id: Ib2911c1f30f06edc4da1c79a6e75f4a8fdbaa7d0
---
checks/alcatel.include | 21 +++++++++++++++++++++
checks/alcatel_cpu | 30 ++++++------------------------
2 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/checks/alcatel.include b/checks/alcatel.include
index fdf4d2c..ded1309 100644
--- a/checks/alcatel.include
+++ b/checks/alcatel.include
@@ -24,6 +24,8 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+alcatel_cpu_default_levels = (90.0, 95.0)
+
factory_settings['alcatel_temp'] = {
"levels": (45, 50),
}
@@ -35,6 +37,25 @@ def alcatel_networking_products_scan_function(oid):
return oid(sys_object_id).startswith(alcatel_ind_1_base_mib)
+def inventory_alcatel_cpu(info):
+ return [(None, "alcatel_cpu_default_levels")]
+
+
+def check_alcatel_cpu(_no_item, params, info):
+ cpu_perc = int(info[0][0])
+ warn, crit = params
+ status = 0
+ levelstext = ""
+ if cpu_perc >= crit:
+ status = 2
+ elif cpu_perc >= warn:
+ status = 1
+ if status:
+ levelstext = " (warn/crit at %.1f%%/%.1f%%)" % (warn, crit)
+ perfdata = [("util", cpu_perc, warn, crit, 0, 100)]
+ return status, "total: %.1f%%" % cpu_perc + levelstext, perfdata
+
+
def inventory_alcatel_power(info):
for line in info:
oid_end, _, device_type, power_type = line
diff --git a/checks/alcatel_cpu b/checks/alcatel_cpu
index 6d5a357..aa1833d 100644
--- a/checks/alcatel_cpu
+++ b/checks/alcatel_cpu
@@ -24,33 +24,15 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-alcatel_cpu_default_levels = (90.0, 95.0)
-
-
-def inventory_alcatel_cpu(info):
- return [(None, "alcatel_cpu_default_levels")]
-
-
-def check_alcatel_cpu(_no_item, params, info):
- cpu_perc = int(info[0][0])
- warn, crit = params
- state = 0
- levelstext = ""
- if cpu_perc >= crit:
- state = 2
- elif cpu_perc >= warn:
- state = 1
- if state:
- levelstext = " (warn/crit at %.1f%%/%.1f%%)" % (warn, crit)
- perfdata = [("util", cpu_perc, warn, crit, 0, 100)]
- return state, "total: %.1f%%" % cpu_perc + levelstext, perfdata
-
-
check_info["alcatel_cpu"] = {
"check_function": check_alcatel_cpu,
"inventory_function": inventory_alcatel_cpu,
"service_description": "CPU utilization",
"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_info": (".1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1", [13]),
+ "snmp_scan_function": alcatel_networking_products_scan_function,
+ "snmp_info": ( # MIB module "ALCATEL-IND1-HEALTH-MIB"
+ ".1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1", # MIB object
"healthDeviceInfo"
+ [13] # MIB object "healthDeviceCpuLatest"
+ ),
+ "includes": ["alcatel.include"],
}