Module: check_mk
Branch: master
Commit: a7dabcc20f6b2145d12ff9aacac00d9e7ecd0068
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a7dabcc20f6b21…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jan 19 18:19:38 2015 +0100
mem.linux: prevent crash for older kernels (e.g. SLES9
... where CommitLimit is missing
---
checks/mem | 37 ++++++++++++++++++++++++++++++++----
web/plugins/perfometer/check_mk.py | 8 +++++++-
2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/checks/mem b/checks/mem
index cf888bd..eb6fb7c 100644
--- a/checks/mem
+++ b/checks/mem
@@ -118,6 +118,34 @@
# HugePages_Rsvd: 0
# Hugepagesize: 2048 kB
+# Yet earlier kernel (SLES 9):
+# <<<mem>>>
+# MemTotal: 6224268 kB
+# MemFree: 2913660 kB
+# Buffers: 84712 kB
+# Cached: 1779052 kB
+# SwapCached: 0 kB
+# Active: 1931528 kB
+# Inactive: 1276156 kB
+# HighTotal: 5373824 kB
+# HighFree: 2233984 kB
+# LowTotal: 850444 kB
+# LowFree: 679676 kB
+# SwapTotal: 1052280 kB
+# SwapFree: 1052280 kB
+# Dirty: 55680 kB
+# Writeback: 0 kB
+# Mapped: 1469268 kB
+# Slab: 71724 kB
+# Committed_AS: 2758332 kB
+# PageTables: 7672 kB
+# VmallocTotal: 112632 kB
+# VmallocUsed: 9324 kB
+# VmallocChunk: 103180 kB
+# HugePages_Total: 0
+# HugePages_Free: 0
+# Hugepagesize: 2048 kB
+
factory_settings["mem_linux_default_levels"] = {
"levels_virtual": ("perc_used", ( 80.0, 90.0)),
@@ -292,10 +320,11 @@ def check_mem_linux(_no_item, params, info):
yield r # only display if non-OK
# Commit limit
- r = check_mem_levels("Commit Limit", meminfo["TotalTotal"] -
meminfo["CommitLimit"],
- meminfo["TotalTotal"], params.get("levels_commitlimit"),
of_what = "RAM + Swap")
- if r[0]:
- yield r # only display if non-OK
+ if "CommitLimit" in meminfo:
+ r = check_mem_levels("Commit Limit", meminfo["TotalTotal"] -
meminfo["CommitLimit"],
+ meminfo["TotalTotal"],
params.get("levels_commitlimit"), of_what = "RAM + Swap")
+ if r[0]:
+ yield r # only display if non-OK
# VMalloc
r = check_mem_levels("Largest Free VMalloc Chunk",
meminfo["VmallocTotal"] - meminfo["VmallocChunk"],
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index 2040fab..38ffb11 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -180,7 +180,8 @@ perfometers["check_mk-ucd_cpu_util"] =
perfometer_check_mk_kernel_util
perfometers["check_mk-lparstat_aix.cpu_util"] =
perfometer_check_mk_kernel_util
def perfometer_check_mk_mem_used(row, check_command, perf_data):
- h = '<table><tr>'
+ ram_used = None
+
for entry in perf_data:
# Get total and used RAM
if entry[0] == "ramused":
@@ -200,11 +201,16 @@ def perfometer_check_mk_mem_used(row, check_command, perf_data):
elif entry[0] == "swap_total":
swap_total = float(entry[1]) # mem.linux
+ if not ram_used:
+ return
+
virt_total = ram_total + swap_total
virt_used = ram_used + swap_used
# paint used ram and swap
ram_color, swap_color = "#80ff40", "#008030"
+
+ h = '<table><tr>'
h += perfometer_td(100 * ram_used / virt_total, ram_color)
h += perfometer_td(100 * swap_used / virt_total, swap_color)