Module: check_mk
Branch: master
Commit: f84d1ecacd0d6c4a8a1942c793bc6bce88c9b59e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f84d1ecacd0d6c…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon May 4 11:06:12 2015 +0200
fortigate checks: code reformatted
---
checks/fortigate_cpu | 29 ++++++++++++++++-------------
checks/fortigate_sessions | 11 ++++++++---
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/checks/fortigate_cpu b/checks/fortigate_cpu
index 7b51888..3265a93 100644
--- a/checks/fortigate_cpu
+++ b/checks/fortigate_cpu
@@ -26,6 +26,9 @@
fortigate_cpu_default_levels = (80.0, 90.0)
+def inventory_fortigate_cpu(info):
+ return [(None, "fortigate_cpu_default_levels")]
+
def check_fortigate_cpu(item, params, info):
num_cpus = 0
util = 0
@@ -33,25 +36,25 @@ def check_fortigate_cpu(item, params, info):
util += int(line[0])
num_cpus += 1
if num_cpus == 0:
- return (3, "no data found in SNMP output")
+ return
+
util = float(util) / num_cpus
- infotext = "%2.1f%% utilization at %d CPUs" % (util, num_cpus)
- warn, crit = params
- perfdata = [("util", util, warn, crit, 0, 100)]
- if util >= crit:
- return (2, infotext + " (critical at %d%%)" % crit, perfdata)
- elif util >= warn:
- return (1, infotext + " (warning at %d%%)" % warn, perfdata)
- else:
- return (0, infotext, perfdata)
+
+ state, infotext, perfdata = check_cpu_util(util, params)
+ infotext += " at %d CPUs" % num_cpus
+
+ return state, infotext, perfdata
check_info["fortigate_cpu"] = {
+ "inventory_function" : inventory_fortigate_cpu,
"check_function" : check_fortigate_cpu,
- "inventory_function" : lambda info: [(None,
"fortigate_cpu_default_levels")],
"service_description" : "CPU utilization",
"has_perfdata" : True,
"group" : "cpu_utilization",
- "snmp_scan_function" : lambda oid:
oid(".1.3.6.1.4.1.12356.1.8.0"),
- "snmp_info" : ( ".1.3.6.1.4.1.12356.1", [ 8 ]),
+ # uses mib FORTINET-MIB-280
+ "snmp_scan_function" : lambda oid: ".1.3.6.1.4.1.12356.101.1"
in oid(".1.3.6.1.2.1.1.2.0") and\
+ oid(".1.3.6.1.4.1.12356.1.8.0"),
+ "snmp_info" : ( ".1.3.6.1.4.1.12356.1", [ 8 ]),
+ "include" : [ "cpu_util.include" ],
}
diff --git a/checks/fortigate_sessions b/checks/fortigate_sessions
index 2bcdee6..f84025e 100644
--- a/checks/fortigate_sessions
+++ b/checks/fortigate_sessions
@@ -26,6 +26,9 @@
fortigate_sessions_default_levels = (100000, 150000)
+def inventory_fortigate_sessions(info):
+ return [(None, "fortigate_sessions_default_levels")]
+
def check_fortigate_sessions(item, params, info):
warn, crit = params
current = saveint(info[0][0])
@@ -39,14 +42,16 @@ def check_fortigate_sessions(item, params, info):
icon = "(!!)"
perf = [("session", current, warn, crit)]
- return(state, "%d Session%s (levels at %d/%d)" % (current, icon, warn,
crit), perf)
+ return state, "%d Session%s (levels at %d/%d)" % (current, icon, warn,
crit), perf
check_info["fortigate_sessions"] = {
+ "inventory_function" : inventory_fortigate_sessions,
"check_function" : check_fortigate_sessions,
- "inventory_function" : lambda info: [(None,
"fortigate_sessions_default_levels")],
"service_description" : "Sessions",
"has_perfdata" : True,
- "snmp_scan_function" : lambda oid:
oid(".1.3.6.1.4.1.12356.1.10.0"),
+ # uses mib FORTINET-MIB-280
+ "snmp_scan_function" : lambda oid: ".1.3.6.1.4.1.12356.101.1"
in oid(".1.3.6.1.2.1.1.2.0") and\
+ oid(".1.3.6.1.4.1.12356.1.10.0"),
"snmp_info" : ( ".1.3.6.1.4.1.12356.1", [ 10 ]),
}