Module: check_mk
Branch: master
Commit: 95371d9d607a5a31ed6f919088ccc27f6765b69e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=95371d9d607a5a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 5 10:02:12 2018 +0200
Fixed wrong apxs2-prefork paths for SLES
Change-Id: I68648237929709adf68e10bece10cf724e8156b8
---
omd/packages/mod_wsgi/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/omd/packages/mod_wsgi/Makefile b/omd/packages/mod_wsgi/Makefile
index 9f2c247..5dfc070 100644
--- a/omd/packages/mod_wsgi/Makefile
+++ b/omd/packages/mod_wsgi/Makefile
@@ -17,8 +17,8 @@ endif
# Special case to make compilation work with SLES11. It has apxs2 but we need
# to use the MPM specific apxs2-prefork binary to make compilation find the
# correct mpm.h.
-ifneq ("$(wildcard /usr/bin/apxs2-prefork)","")
- APXS=/usr/bin/apxs2-prefork
+ifneq ("$(wildcard /usr/sbin/apxs2-prefork)","")
+ APXS=/usr/sbin/apxs2-prefork
endif
Module: check_mk
Branch: master
Commit: 34c8f35c931a511a5c7d6161334c7ad9b0d75403
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=34c8f35c931a51…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Jul 5 08:50:19 2018 +0200
hr_mem got parse function
Change-Id: Iff809958a519597e1960f48a3087f9c3342bea1d
---
checks/hr_mem | 86 ++++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 55 insertions(+), 31 deletions(-)
diff --git a/checks/hr_mem b/checks/hr_mem
index 772ede4..2025fdf 100644
--- a/checks/hr_mem
+++ b/checks/hr_mem
@@ -24,51 +24,73 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+
+def parse_hr_mem(info):
+ map_types = {
+ '.1.3.6.1.2.1.25.2.1.1' : 'other',
+ '.1.3.6.1.2.1.25.2.1.2' : 'RAM',
+ '.1.3.6.1.2.1.25.2.1.3' : 'virtual memory',
+ '.1.3.6.1.2.1.25.2.1.4' : 'fixed disk',
+ '.1.3.6.1.2.1.25.2.1.5' : 'removeable disk',
+ '.1.3.6.1.2.1.25.2.1.6' : 'floppy disk',
+ '.1.3.6.1.2.1.25.2.1.7' : 'compact disk',
+ '.1.3.6.1.2.1.25.2.1.8' : 'RAM disk',
+ '.1.3.6.1.2.1.25.2.1.9' : 'flash memory',
+ '.1.3.6.1.2.1.25.2.1.10': 'network disk',
+ }
+
+ parsed = {}
+ for hrtype, hrdescr, hrunits, hrsize, hrused in info:
+ try:
+ size = int(hrsize) * int(hrunits) / 1048576.0
+ used = int(hrused) * int(hrunits) / 1048576.0
+ parsed.setdefault(map_types[hrtype], []).append((hrdescr.lower(), size, used))
+ except ValueError, KeyError:
+ pass
+
+ return parsed
+
+
memused_default_levels = (150.0, 200.0)
+
# Memory information is - together with filesystems - in
# hrStorage. We need the entries of the types hrStorageVirtualMemory
# and hrStorageRam
-def inventory_hr_mem(info):
+def inventory_hr_mem(parsed):
# Do we find at least one entry concerning memory?
- for hrtype, hrdescr, hrunits, hrsize, hrused in info:
- if hrtype in [ ".1.3.6.1.2.1.25.2.1.2",
- ".1.3.6.1.2.1.25.2.1.3" ]:
- if saveint(hrsize) > 1: # some device have zero (broken) values
- return [(None, "memused_default_levels")]
+ for _, size, __ in parsed.get('RAM', []) + parsed.get('virtual memory', []):
+ if size > 1:
+ # some device have zero (broken) values
+ return [(None, "memused_default_levels")]
+
-def check_hr_mem(_no_item, params, info):
+def check_hr_mem(_no_item, params, parsed):
# This check does not yet support averaging. We need to
# convert it to mem.include
if type(params) == dict:
params = params["levels"]
usage = {}
- for hrtype, hrdescr, hrunits, hrsize, hrused in info:
- if hrtype in [ ".1.3.6.1.2.1.25.2.1.2",
- ".1.3.6.1.2.1.25.2.1.3" ]:
- size = saveint(hrsize) * saveint(hrunits) / 1048576.0
- used = saveint(hrused) * saveint(hrunits) / 1048576.0
- # 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 and hrdescr != "Virtual memory":
- 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
- for hrtype, hrdescr, hrunits, hrsize, hrused in info:
- if hrdescr in [ "Cached memory", "Memory buffers" ]:
- hr_mem = saveint(hrused)
- if hr_mem < 0: # some devices report negative used cache values...
- hr_mem = saveint(hrsize)
- cached_mb += hr_mem * saveint(hrunits) / 1048576.0
+ for type_readable, entries in parsed.iteritems():
+ for descr, size, used in entries:
+ if type_readable in ['RAM', 'virtual memory'] and descr != "virtual memory":
+ # We use only the first entry of each type. We have
+ # seen devices (pfSense), that have lots of additional
+ # entries that are not useful.
+ usage.setdefault(type_readable, (size, used))
+
+ if descr in [ "cached memory", "memory buffers" ] and used > 0:
+ # Account for cached memory (this works at least for systems using
+ # the UCD snmpd (such as Linux based applicances)
+ # some devices report negative used cache values...
+ cached_mb += used
- totalram_mb, ramused_mb = usage.get(".1.3.6.1.2.1.25.2.1.2", (0,0))
+ totalram_mb, ramused_mb = usage.get("RAM", (0, 0))
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
+ totalvirt_mb, virtused_mb = usage.get("virtual memory", (0, 0))
+ totalmem_mb, totalused_mb = totalram_mb + totalvirt_mb, ramused_mb + virtused_mb
if totalmem_mb > 0 and totalram_mb > 0:
totalused_perc = 100 * totalused_mb / totalram_mb
@@ -99,9 +121,11 @@ def check_hr_mem(_no_item, params, info):
else:
return (0, '%s' % infotext, perfdata)
- return (3, "Invalid information. Total memory is empty.")
+ return 3, "Invalid information. Total memory is empty."
+
check_info["hr_mem"] = {
+ 'parse_function' : parse_hr_mem,
'inventory_function' : inventory_hr_mem,
'check_function' : check_hr_mem,
'service_description' : 'Memory used',
@@ -112,7 +136,7 @@ check_info["hr_mem"] = {
4, # hrStorageAllocationUnits
5, # hrStorageSize
6, # hrStorageUsed
- ]),
+ ]),
# Some devices are reporting wrong data on
# HOST-RESOURCES-MIB. Use UCD-MIB in these
# cases instead