Module: check_mk
Branch: master
Commit: c505863948d2e2df9e93d94c1c91b17f773c0516
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c505863948d2e2…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 21 21:26:03 2012 +0100
FIX: hr_mem: handle rare case where more than one entry is present
---
ChangeLog | 2 ++
checks/hr_mem | 9 +++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 08d36ea..399296a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -45,6 +45,8 @@
* FIX: fix inventory of f5_bigip_temp
* mk_oracle (lnx+win): Fixed TEMP tablespace size calculations
* ps: output node process is running on (only for clusters)
+ * hr_mem: handle rare case where more than one entry is present
+ (this prevents an exception of pfSense)
Multisite:
* Added several missing localization stringsw
diff --git a/checks/hr_mem b/checks/hr_mem
index d3efa88..4f334eb 100644
--- a/checks/hr_mem
+++ b/checks/hr_mem
@@ -44,8 +44,12 @@ def check_hr_mem(item, params, info):
".1.3.6.1.2.1.25.2.1.3" ]:
size = saveint(hrsize) * saveint(hrunits) / 1048576.0
used = saveint(hrused) * saveint(hrunits) / 1048576.0
- usage[hrtype] = (size, used)
-
+ # We use only the first entry of each type. We have
+ # seen devices (pfSense), that have lots of additional
+ # entries that are not useful.
+ if hrtype not in usage:
+ usage[hrtype] = (size, used)
+
# Account for cached memory (this works at least for systems using
# the UCD snmpd (such as Linux based applicances)
cached_mb = 0
@@ -57,6 +61,7 @@ def check_hr_mem(item, params, info):
ramused_mb -= cached_mb
totalvirt_mb, virtused_mb = usage.get(".1.3.6.1.2.1.25.2.1.3", (0,0))
totalmem_mb, totalused_mb = totalram_mb + totalvirt_mb, ramused_mb + virtused_mb
+
if totalmem_mb > 0:
totalused_perc = 100 * totalused_mb / totalram_mb