Module: check_mk
Branch: master
Commit: c2f2870aa31f3dccd99ddd14bf2f440d7605f941
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c2f2870aa31f3d…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Dec 12 14:22:00 2016 +0100
4159 FIX mem.win: fixed KeyError
Change-Id: Ic4850f8329504a0958f4b0e944bf61998ecc8a33
---
.werks/4159 | 10 ++++++++++
ChangeLog | 1 +
checks/mem | 12 ++++++++++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/.werks/4159 b/.werks/4159
new file mode 100644
index 0000000..f51190c
--- /dev/null
+++ b/.werks/4159
@@ -0,0 +1,10 @@
+Title: mem.win: fixed KeyError
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i3
+Date: 1481548894
+
+
diff --git a/ChangeLog b/ChangeLog
index ee85fa3..ccd1503 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -58,6 +58,7 @@
* 4138 FIX: statgrab: Fixed issue in FreeBSD agent when statgrab is not installed
* 4158 FIX: fileinfo: fixed file handling containing spaces
* 4101 FIX: citrix_sessions: Output error message in case of missing session
information....
+ * 4159 FIX: mem.win: fixed KeyError
Multisite:
* 4070 Added a painter for the service check period
diff --git a/checks/mem b/checks/mem
index 246990a..6c473fd 100644
--- a/checks/mem
+++ b/checks/mem
@@ -422,11 +422,13 @@ factory_settings["memory_win_default_levels"] = {
"pagefile" : ( 80.0, 90.0 ),
}
+
def inventory_mem_win(info):
meminfo = parse_proc_meminfo(info)
if "MemTotal" in meminfo and "PageTotal" in meminfo:
return [(None, {})]
+
def check_mem_windows(item, params, info):
meminfo = parse_proc_meminfo(info)
MB = 1024.0 * 1024
@@ -435,8 +437,14 @@ def check_mem_windows(item, params, info):
for title, what, paramname in [
("Memory usage", "Mem", "memory"),
("Commit Charge", "Page", "pagefile")]:
- total_kb = meminfo[what + "Total"]
- free_kb = meminfo[what + "Free"]
+
+ key_total = what + "Total"
+ key_free = what + "Free"
+ if not ( key_total in meminfo and key_free in meminfo ):
+ continue
+
+ total_kb = meminfo[key_total]
+ free_kb = meminfo[key_free]
used_kb = total_kb - free_kb
used_mb = used_kb / 1024.0
free_mb = free_kb / 1024.0