Module: check_mk
Branch: master
Commit: 434d78bbd4dce5a026c7c6bf6a8bde79fda6adf9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=434d78bbd4dce5…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Sep 17 10:02:18 2015 +0200
fortigate_cpu, fortigate_cpu_base used same code -> fortigate_cpu.include
---
checks/fortigate_cpu | 25 ++++-------------------
checks/fortigate_cpu.include | 46 ++++++++++++++++++++++++++++++++++++++++++
checks/fortigate_cpu_base | 27 +++++--------------------
3 files changed, 55 insertions(+), 43 deletions(-)
diff --git a/checks/fortigate_cpu b/checks/fortigate_cpu
index 2dde69a..cfbdb21 100644
--- a/checks/fortigate_cpu
+++ b/checks/fortigate_cpu
@@ -24,37 +24,20 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-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
- for line in info:
- util += int(line[0])
- num_cpus += 1
- if num_cpus == 0:
- return
- util = float(util) / num_cpus
-
- state, infotext, perfdata = check_cpu_util(util, params).next()
- infotext += " at %d CPUs" % num_cpus
+fortigate_cpu_default_levels = (80.0, 90.0)
- return state, infotext, perfdata
check_info["fortigate_cpu"] = {
- "inventory_function" : inventory_fortigate_cpu,
+ "inventory_function" : lambda info: inventory_fortigate_cpu(info,
"fortigate_cpu_default_levels"),
"check_function" : check_fortigate_cpu,
"service_description" : "CPU utilization",
"has_perfdata" : True,
"group" : "cpu_utilization",
# 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\
+ "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" ],
+ "includes" : [ "cpu_util.include",
"fortigate_cpu.include" ],
}
diff --git a/checks/fortigate_cpu.include b/checks/fortigate_cpu.include
new file mode 100644
index 0000000..a224468
--- /dev/null
+++ b/checks/fortigate_cpu.include
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+def inventory_fortigate_cpu(info, default_levels):
+ return [(None, default_levels)]
+
+
+def check_fortigate_cpu(item, params, info):
+ num_cpus = 0
+ util = 0
+ for line in info:
+ util += int(line[0])
+ num_cpus += 1
+ if num_cpus == 0:
+ return
+
+ util = float(util) / num_cpus
+
+ state, infotext, perfdata = check_cpu_util(util, params).next()
+ infotext += " at %d CPUs" % num_cpus
+
+ return state, infotext, perfdata
diff --git a/checks/fortigate_cpu_base b/checks/fortigate_cpu_base
index 8f0c35b..535de7b 100644
--- a/checks/fortigate_cpu_base
+++ b/checks/fortigate_cpu_base
@@ -24,37 +24,20 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-fortigate_cpu_base_default_levels = (80.0, 90.0)
-
-def inventory_fortigate_cpu_base(info):
- return [(None, "fortigate_cpu_base_default_levels")]
-
-def check_fortigate_cpu_base(item, params, info):
- num_cpus = 0
- util = 0
- for line in info:
- util += int(line[0])
- num_cpus += 1
- if num_cpus == 0:
- return
- util = float(util) / num_cpus
-
- state, infotext, perfdata = check_cpu_util(util, params).next()
- infotext += " at %d CPUs" % num_cpus
+fortigate_cpu_base_default_levels = (80.0, 90.0)
- return state, infotext, perfdata
check_info["fortigate_cpu_base"] = {
- "inventory_function" : inventory_fortigate_cpu_base,
- "check_function" : check_fortigate_cpu_base,
+ "inventory_function" : lambda info: (inventory_fortigate_cpu,
"fortigate_cpu_base_default_levels"),
+ "check_function" : check_fortigate_cpu,
"service_description" : "CPU utilization",
"has_perfdata" : True,
"group" : "cpu_utilization",
# uses mib FORTINET-FORTIGATE-MIB
- "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\
+ "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.101.4.1.3.0"),
"snmp_info" : ( ".1.3.6.1.4.1.12356.101.4.1", [ 3 ]),
- "includes" : [ "cpu_util.include" ],
+ "includes" : [ "cpu_util.include",
"fortigate_cpu.include" ],
}