Module: check_mk
Branch: master
Commit: 77c0fa00213cc1fd1af5b4f1fe2014a65a76e5de
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=77c0fa00213cc1…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 17 13:34:42 2013 +0100
FIX solaris_mem: Is now compatible to more systems
Depending on the system, the agent might provide memory information
of slightly different format:
SunOS hosta 5.10 Generic_142900-03 sun4u sparc SUNW,UltraAX-i2
Memory: 512M phys mem, 353M free mem, 2000M total swap, 2000M free swap
SunOS hostb 5.10 Generic_142900-03 sun4u sparc SUNW,Sun-Fire-480R
Memory: 10G phys mem, 1905M free mem, 8002M total swap, 8002M free swap
SunOS hostc 5.6 Generic_105181-21 sun4u sparc SUNW,Ultra-1
Memory: 640M real, 10M free, 293M swap in use, 349M swap free
SunOS hostd 5.8 Generic_108528-09 sun4u sparc SUNW,Ultra-60
Memory: 2048M real, 913M free, 723M swap in use, 2863M swap free
The check is now compatible to all of them.
---
.werks/383 | 25 +++++++++++++++++++++++++
ChangeLog | 1 +
checks/solaris_mem | 44 +++++++++++++++++++++++++++-----------------
3 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/.werks/383 b/.werks/383
new file mode 100644
index 0000000..a6e4bee
--- /dev/null
+++ b/.werks/383
@@ -0,0 +1,25 @@
+Title: solaris_mem: Is now compatible to more systems
+Level: 1
+Component: checks
+Class: fix
+State: unknown
+Version: 1.2.5i1
+Date: 1387283624
+Targetversion: future
+
+Depending on the system, the agent might provide memory information
+of slightly different format:
+
+SunOS hosta 5.10 Generic_142900-03 sun4u sparc SUNW,UltraAX-i2
+Memory: 512M phys mem, 353M free mem, 2000M total swap, 2000M free swap
+
+SunOS hostb 5.10 Generic_142900-03 sun4u sparc SUNW,Sun-Fire-480R
+Memory: 10G phys mem, 1905M free mem, 8002M total swap, 8002M free swap
+
+SunOS hostc 5.6 Generic_105181-21 sun4u sparc SUNW,Ultra-1
+Memory: 640M real, 10M free, 293M swap in use, 349M swap free
+
+SunOS hostd 5.8 Generic_108528-09 sun4u sparc SUNW,Ultra-60
+Memory: 2048M real, 913M free, 723M swap in use, 2863M swap free
+
+The check is now compatible to all of them.
diff --git a/ChangeLog b/ChangeLog
index c05775e..17fa00e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,6 +51,7 @@
* 0380 FIX: jolokia_metrics.mem: PNP-Template now handles non existant max values...
* 0381 FIX: win_printers: Fixed creation of duplicate services...
* 0347 FIX: smart.stats: Remove duplicate disks...
+ * 0383 FIX: solaris_mem: Is now compatible to more systems...
Multisite:
* 0371 Added log class filter to hostsvcevents view
diff --git a/checks/solaris_mem b/checks/solaris_mem
index be9c3f1..94864ed 100644
--- a/checks/solaris_mem
+++ b/checks/solaris_mem
@@ -27,27 +27,37 @@
#<<<solaris_mem>>>
#Memory: 256G real, 54G free, 257G swap in use, 86G swap free
+#<<<solaris_mem>>>
+#Memory: 512M phys mem, 353M free mem, 2000M total swap, 2000M free swap
+
+#<<<solaris_mem>>>
+#Memory: 10G phys mem, 1905M free mem, 8002M total swap, 8002M free swap
+
+#<<<solaris_mem>>>
+#Memory: 640M real, 10M free, 293M swap in use, 349M swap free
+
+#<<<solaris_mem>>>
+#Memory: 2048M real, 913M free, 723M swap in use, 2863M swap free
+
+def solaris_mem_to_kbytes(s):
+ if s[-1] == 'G':
+ return saveint(s[:-1]) * 1024 * 1024
+ elif s[-1] == 'M':
+ return saveint(s[:-1]) * 1024
+
def inventory_solaris_mem_used(info):
return [(None, "memused_default_levels")]
def check_solaris_mem_used(_no_item, params, info):
- values = ['MemTotal', 'MemFree', 'SwapTotal',
'SwapFree']
- data = {}
- data['MemTotal'] = info[0][1]
- data['MemFree'] = info[0][3]
- data['SwapTotal'] = info[0][5] #swap in use
- data['SwapFree'] = info[0][9]
-
- for value in values:
- if data[value][-1] == 'G':
- data[value] = saveint(data[value][:-1]) * 1024 * 1024
- elif data[value][-1] == 'M':
- data[value] = saveint(data[value][:-1]) * 1024
-
- #SwapTotal is Swap in use, so we have to add SwapFree
- data['SwapTotal'] = data['SwapTotal'] + data['SwapFree']
-
- return check_memory(params, data)
+ keys = ['MemTotal', 'MemFree', 'SwapTotal',
'SwapFree']
+ values = [ solaris_mem_to_kbytes(v) for v in info[0] if v[0] in '01234567890'
]
+ if len(values) != 4:
+ return 3, "Got unexpected information from agent"
+
+ # convert swap-in-use to swap-total, as expected by check_memory()
+ values[2] = values[2] + values[3]
+
+ return check_memory(params, dict(zip(keys, values)))
check_info['solaris_mem'] = {
"check_function" : check_solaris_mem_used,