Module: check_mk
Branch: master
Commit: 439f38b98c5f96c6ef6a0b89a70cf3f3a6873c79
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=439f38b98c5f96…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Mon Mar 6 15:00:47 2017 +0100
refactoring ucd and hr checks
avoiding processing the scan in several places especially for mem check.
Additionally made name of the regular scan function more descriptive
Change-Id: I0d90527253a575168a141422fa8945f9cb2cd569
---
checks/hr_mem | 21 +++++++++++----------
checks/ucd.include | 16 +++++++++++++++-
checks/ucd_cpu_util | 16 ++++++++--------
checks/ucd_disk | 8 ++++----
checks/ucd_mem | 11 ++++++-----
checks/ucd_processes | 2 +-
6 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/checks/hr_mem b/checks/hr_mem
index 0a78ecc..8bc2c3a 100644
--- a/checks/hr_mem
+++ b/checks/hr_mem
@@ -102,20 +102,21 @@ def check_hr_mem(_no_item, params, info):
return (3, "Invalid information. Total memory is empty.")
check_info["hr_mem"] = {
- 'check_function': check_hr_mem,
- 'inventory_function': inventory_hr_mem,
- 'service_description': 'Memory used',
- 'has_perfdata': True,
- 'snmp_info': ('.1.3.6.1.2.1.25.2.3.1', [
+ 'inventory_function' : inventory_hr_mem,
+ 'check_function' : check_hr_mem,
+ 'service_description' : 'Memory used',
+ 'has_perfdata' : True,
+ 'snmp_info' : ('.1.3.6.1.2.1.25.2.3.1', [
2, # hrStorageType
3, # hrStorageDescr
4, # hrStorageAllocationUnits
5, # hrStorageSize
6, # hrStorageUsed
]),
- # HOST-RESOURCES-MIB::hrSystemUptime.0
- 'snmp_scan_function': lambda oid: \
- not not oid('.1.3.6.1.2.1.25.1.1.0') and
- "pfsense" not in oid(".1.3.6.1.2.1.1.1.0").lower(),
- 'group': 'memory',
+ # Some devices are reporting wrong data on
+ # HOST-RESOURCES-MIB. Use UCD-MIB in these
+ # cases instead
+ 'snmp_scan_function' : hr_mem_scan_function,
+ 'group' : 'memory',
+ 'includes' : [ "ucd.include" ]
}
diff --git a/checks/ucd.include b/checks/ucd.include
index 3c7eb6f..7ec70db 100644
--- a/checks/ucd.include
+++ b/checks/ucd.include
@@ -37,6 +37,7 @@ def ucd_scan_function(oid):
"HP Onboard Administrator" in oid(".1.3.6.1.2.1.1.1.0")
or \
# for barracuda spam firewall appliance
"barracuda" in oid(".1.3.6.1.2.1.1.1.0").lower() or \
+ "pfsense" in oid(".1.3.6.1.2.1.1.1.0").lower() or \
"genugate" in oid(".1.3.6.1.2.1.1.1.0") or \
# for artec email archiv appliance
( oid('.1.3.6.1.2.1.1.2.0') == '.1.3.6.1.4.1.8072.3.2.10' and
\
@@ -44,9 +45,22 @@ def ucd_scan_function(oid):
"serial" in oid('.1.3.6.1.2.1.1.1.0').lower() ))
-def prefer_hr_scan_function(oid):
+def avoid_ucd_scan_function(oid):
# We prefer HOST-RESOURCES-MIB implementation but not in case
# of check 'ucd_cpu_load' because the HR-MIB has not data
# about cpu load
return ucd_scan_function(oid) and \
not oid(".1.3.6.1.2.1.25.1.1.0")
+
+def hr_mem_scan_function(oid):
+ # We prefer HOST-RESOURCES-MIB implementation but not in case
+ # of devices, which are known to report incorrect information
+ # about mem usage
+ return not "pfsense" in oid(".1.3.6.1.2.1.1.1.0").lower() or \
+ (oid(".1.3.6.1.2.1.25.1.1.0") and \
+ not ucd_scan_function(oid))
+
+def ucd_mem_scan_function(oid):
+ # Avoid inverting output of a function in a check plugin and be
+ # descriptive about what a function is actually doing
+ return not hr_mem_scan_function(oid)
diff --git a/checks/ucd_cpu_util b/checks/ucd_cpu_util
index 591c553..a94e0cf 100644
--- a/checks/ucd_cpu_util
+++ b/checks/ucd_cpu_util
@@ -83,12 +83,12 @@ def check_ucd_cpu_util(item, params, info):
check_info["ucd_cpu_util"] = {
- 'check_function': check_ucd_cpu_util,
- 'inventory_function': inventory_ucd_cpu_util,
- 'service_description': 'CPU utilization',
- 'has_perfdata': True,
- 'snmp_info': ('.1.3.6.1.4.1.2021.11', [50, 51, 52, 53,
54, 55, 56]),
- 'snmp_scan_function': prefer_hr_scan_function,
- 'includes': [ "ucd.include" ],
- 'group': 'cpu_iowait',
+ 'inventory_function' : inventory_ucd_cpu_util,
+ 'check_function' : check_ucd_cpu_util,
+ 'service_description' : 'CPU utilization',
+ 'has_perfdata' : True,
+ 'snmp_info' : ('.1.3.6.1.4.1.2021.11', [50, 51, 52, 53,
54, 55, 56]),
+ 'snmp_scan_function' : avoid_ucd_scan_function,
+ 'includes' : [ "ucd.include" ],
+ 'group' : 'cpu_iowait',
}
diff --git a/checks/ucd_disk b/checks/ucd_disk
index b97ed6d..e47f7be 100644
--- a/checks/ucd_disk
+++ b/checks/ucd_disk
@@ -47,11 +47,11 @@ check_info['ucd_disk'] = {
'service_description' : 'Filesystem %s',
'has_perfdata' : True,
'snmp_info' : (".1.3.6.1.4.1.2021.9.1", [
- "2", # dskPath -> where the disk
is mounted.
- "6", # dskTotal -> in kBytes
- "7", # dskAvail -> in kBytes
+ "2", # dskPath -> where the disk is
mounted.
+ "6", # dskTotal -> in kBytes
+ "7", # dskAvail -> in kBytes
]),
- 'snmp_scan_function' : prefer_hr_scan_function,
+ 'snmp_scan_function' : avoid_ucd_scan_function,
"group" : "filesystem",
'default_levels_variable' : "filesystem_default_levels",
'includes' : [ "ucd.include",
"df.include" ],
diff --git a/checks/ucd_mem b/checks/ucd_mem
index 4cca376..3246ab2 100644
--- a/checks/ucd_mem
+++ b/checks/ucd_mem
@@ -55,12 +55,13 @@ check_info['ucd_mem'] = {
'service_description' : 'Memory',
'has_perfdata' : True,
'snmp_info' : (".1.3.6.1.4.1.2021.4", [
- "5", # memTotal -> kB
- "6", # memAvailable -> kB
+ "5", # memTotal -> kB
+ "6", # memAvailable -> kB
]),
- 'snmp_scan_function' : lambda oid: \
- "pfsense" in
oid(".1.3.6.1.2.1.1.1.0").lower() or \
- prefer_hr_scan_function(oid),
+ # Some devices are reporting wrong data on
+ # HOST-RESOURCES-MIB. Use UCD-MIB in these
+ # cases instead
+ 'snmp_scan_function' : ucd_mem_scan_function,
'default_levels_variable' : 'ucd_mem_default_levels',
'group' : 'memory_simple',
'includes' : [ "ucd.include",
"memory.include" ],
diff --git a/checks/ucd_processes b/checks/ucd_processes
index 63ca9e8..68da7bd 100644
--- a/checks/ucd_processes
+++ b/checks/ucd_processes
@@ -83,6 +83,6 @@ check_info['ucd_processes'] = {
"100", # prErrFlag
"101", # prErrMessage
]),
- 'snmp_scan_function' : prefer_hr_scan_function,
+ 'snmp_scan_function' : avoid_ucd_scan_function,
'includes' : [ "ucd.include" ],
}