Module: check_mk
Branch: master
Commit: 06097a430383ffa10039194d0e1da91c6ff53e52
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=06097a430383ff…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 14 11:34:54 2013 +0100
mem.include: Linux memory check now includes size of page tables.
---
ChangeLog | 2 +
checks/mem.include | 37 +++++++-----
pnp-templates/check_mk-mem.used.php | 110 +++++++++++++++++++++-------------
3 files changed, 92 insertions(+), 57 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 163230d..bb510cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,8 @@
when processing of current lines needs more time than max execution time
* mounts: ignore multiple occurrances of the same device
* Linux agent: allow cached local/plugins checks (see docu)
+ * mem.include: Linux memory check now includes size of page tables. This
+ can be important e.g. on ORACLE systems with a lot of memory
Livestatus:
* Table statehist: Improved detection of vanished hosts and services.
diff --git a/checks/mem.include b/checks/mem.include
index f260a0a..ca361b7 100644
--- a/checks/mem.include
+++ b/checks/mem.include
@@ -28,13 +28,15 @@ memused_default_levels = (150.0, 200.0)
mem_extended_perfdata = False
def check_memory(params, meminfo):
- try:
- swapused = meminfo['SwapTotal'] - meminfo['SwapFree']
- memused = meminfo['MemTotal'] - meminfo['MemFree']
- # Buffers and Cached are optional (not supported on Windows yet)
- caches = meminfo.get('Buffers', 0) + meminfo.get('Cached', 0)
- except:
- return (3, "invalid output from plugin")
+ swapused = meminfo['SwapTotal'] - meminfo['SwapFree']
+ memused = meminfo['MemTotal'] - meminfo['MemFree']
+ # Buffers and Cached are optional (not supported on Windows yet)
+ caches = meminfo.get('Buffers', 0) + meminfo.get('Cached', 0)
+ # Size of Pagetable on Linux can be relevant e.g. on ORACLE
+ # servers with much memory, that do not use HugeTables. We account
+ # that for used
+ pagetables = meminfo.get('PageTables', 0)
+ pagetables_mb = pagetables / 1024.0
# Add extended memory performance data, if this is
# enabled and the agent provides that information.
@@ -50,18 +52,19 @@ def check_memory(params, meminfo):
else:
committed_as = 0
extended_perf = [
- ('mapped', str(mapped_mb) + 'MB', '',
'', 0, ''),
- ('committed_as', str(committed_as_mb) + 'MB', '',
'', 0, ''),
+ ('mapped', str(mapped_mb) + 'MB'),
+ ('committed_as', str(committed_as_mb) + 'MB'),
+ ('pagetables', str(pagetables_mb) + 'MB'),
]
extrainfo = ", %.1f GB mapped, %.1f GB committed" % \
(mapped_mb / 1024.0, committed_as_mb / 1024.0)
- totalused_kb = (swapused + memused - caches)
- totalused_mb = totalused_kb / 1024
+ totalused_kb = (swapused + memused - caches + pagetables)
+ totalused_mb = totalused_kb / 1024.0
totalmem_kb = meminfo['MemTotal']
- totalmem_mb = totalmem_kb / 1024
+ totalmem_mb = totalmem_kb / 1024.0
totalused_perc = 100 * (float(totalused_kb) / float(totalmem_kb))
- totalvirt_mb = (meminfo['SwapTotal'] + meminfo['MemTotal']) / 1024
+ totalvirt_mb = (meminfo['SwapTotal'] + meminfo['MemTotal']) / 1024.0
warn, crit = params
perfdata = [
@@ -70,9 +73,13 @@ def check_memory(params, meminfo):
# levels may be given either in int -> MB or in float -> percentages
- infotext = ("%.2f GB used (%.2f GB RAM + %.2f GB SWAP, this is %.1f%% of %.2f GB
RAM)" % \
+ if pagetables > 0:
+ pgtext = " + %.2f GB Pagetables" % (pagetables_mb / 1024.0)
+ else:
+ pgtext = ""
+ infotext = ("%.2f GB used (%.2f GB RAM + %.2f GB SWAP%s, this is %.1f%% of %.2f
GB RAM)" % \
(totalused_mb / 1024.0, (memused-caches) / 1024.0 / 1024, swapused /
1024.0 / 1024,
- totalused_perc, totalmem_mb / 1024.0)) \
+ pgtext, totalused_perc, totalmem_mb / 1024.0)) \
+ extrainfo
if type(warn) == float:
diff --git a/pnp-templates/check_mk-mem.used.php b/pnp-templates/check_mk-mem.used.php
index 4a28ba5..5432603 100644
--- a/pnp-templates/check_mk-mem.used.php
+++ b/pnp-templates/check_mk-mem.used.php
@@ -27,52 +27,78 @@ $opt[1] = "--vertical-label 'MEMORY(MB)' -X0
--upper-limit " . ($MAX[1] * 120 /
$maxgb = sprintf("%.1f", $MAX[1] / 1024.0);
-$def[1] = "DEF:ram=$RRDFILE[1]:$DS[1]:MAX " ;
-$def[1] .= "DEF:swap=$RRDFILE[2]:$DS[2]:MAX " ;
-$def[1] .= "DEF:virt=$RRDFILE[3]:$DS[3]:MAX " ;
-$def[1] .= "HRULE:$MAX[3]#000080:\"RAM+SWAP installed\" ";
-$def[1] .= "HRULE:$MAX[1]#2040d0:\"$maxgb GB RAM installed\" ";
-$def[1] .= "HRULE:$WARN[3]#FFFF00:\"Warning\" ";
-$def[1] .= "HRULE:$CRIT[3]#FF0000:\"Critical\" ";
+# For the rest of the data we rather work with names instead
+# of numbers
+$RRD = array();
+foreach ($NAME as $i => $n) {
+ $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
+ $WARN[$n] = $WARN[$i];
+ $CRIT[$n] = $CRIT[$i];
+ $MIN[$n] = $MIN[$i];
+ $MAX[$n] = $MAX[$i];
+}
-$def[1] .= "'COMMENT:\\n' ";
-$def[1] .= "AREA:ram#80ff40:\"RAM used \" " ;
-$def[1] .= "GPRINT:ram:LAST:\"%6.0lf MB last\" " ;
-$def[1] .= "GPRINT:ram:AVERAGE:\"%6.0lf MB avg\" " ;
-$def[1] .= "GPRINT:ram:MAX:\"%6.0lf MB max\\n\" ";
+$def[1] = "DEF:virt=$RRDFILE[3]:$DS[3]:MAX "
+ . "DEF:ramx=$RRD[ramused] "
+ . "DEF:swap=$RRDFILE[2]:$DS[2]:MAX "
+ . "CDEF:ram=virt,swap,- "
+ ;
-$def[1] .= "AREA:swap#008030:\"SWAP used \":STACK " ;
-$def[1] .= "GPRINT:swap:LAST:\"%6.0lf MB last\" " ;
-$def[1] .= "GPRINT:swap:AVERAGE:\"%6.0lf MB avg\" " ;
-$def[1] .= "GPRINT:swap:MAX:\"%6.0lf MB max\\n\" " ;
-$def[1] .= "LINE:virt#000000:\"RAM+SWAP used\" " ;
-$def[1] .= "GPRINT:virt:LAST:\"%6.0lf MB last\" " ;
-$def[1] .= "GPRINT:virt:AVERAGE:\"%6.0lf MB avg\" " ;
-$def[1] .= "GPRINT:virt:MAX:\"%6.0lf MB max\\n\" " ;
+$def[1] .= ""
+ . "HRULE:$MAX[3]#000080:\"RAM+SWAP installed\" "
+ . "HRULE:$MAX[1]#2040d0:\"$maxgb GB RAM installed\" "
+ . "HRULE:$WARN[3]#FFFF00:\"Warning\" "
+ . "HRULE:$CRIT[3]#FF0000:\"Critical\" "
+
+ . "'COMMENT:\\n' "
+ . "AREA:ram#80ff40:\"RAM used \" "
+ . "GPRINT:ram:LAST:\"%6.0lf MB last\" "
+ . "GPRINT:ram:AVERAGE:\"%6.0lf MB avg\" "
+ . "GPRINT:ram:MAX:\"%6.0lf MB max\\n\" "
+
+ . "AREA:swap#008030:\"SWAP used \":STACK "
+ . "GPRINT:swap:LAST:\"%6.0lf MB last\" "
+ . "GPRINT:swap:AVERAGE:\"%6.0lf MB avg\" "
+ . "GPRINT:swap:MAX:\"%6.0lf MB max\\n\" "
+ ;
+
-/* HACK: Avoid error if RRD does not contain two data
- sources which .XML file *does*. F..ck. This does not
- work with multiple RRDs... */
-$retval = -1;
-system("rrdtool info $RRDFILE[1] | fgrep -q 'ds[5]'", $retval);
-if ($retval == 0)
-{
- if (count($NAME) >= 4 and $NAME[4] == "mapped") {
- $def[1] .= "DEF:mapped=$RRDFILE[4]:$DS[4]:MAX " ;
- $def[1] .= "LINE2:mapped#8822ff:\"Memory mapped\" " ;
- $def[1] .= "GPRINT:mapped:LAST:\"%6.0lf MB last\" " ;
- $def[1] .= "GPRINT:mapped:AVERAGE:\"%6.0lf MB avg\" " ;
- $def[1] .= "GPRINT:mapped:MAX:\"%6.0lf MB max\\n\" " ;
- }
+if (isset($RRD['pagetables'])) {
+ $def[1] .= "DEF:pagetables=$RRD[pagetables] "
+ . "AREA:pagetables#ff8800:\"Page tables \":STACK "
+ . "GPRINT:pagetables:LAST:\"%6.0lf MB last\" "
+ . "GPRINT:pagetables:AVERAGE:\"%6.0lf MB avg\" "
+ . "GPRINT:pagetables:MAX:\"%6.0lf MB max\\n\" "
+ . "LINE:virt#000000:\"RAM+SWAP+PT used\" "
+ . "GPRINT:virt:LAST:\"%6.0lf MB last\" "
+ . "GPRINT:virt:AVERAGE:\"%6.0lf MB avg\" "
+ . "GPRINT:virt:MAX:\"%6.0lf MB max\\n\" "
+ ;
+}
- if (count($NAME) >= 5 and $NAME[5] == "committed_as") {
- $def[1] .= "DEF:committed=$RRDFILE[5]:$DS[5]:MAX " ;
- $def[1] .= "LINE2:committed#cc00dd:\"Committed \" " ;
- $def[1] .= "GPRINT:committed:LAST:\"%6.0lf MB last\" " ;
- $def[1] .= "GPRINT:committed:AVERAGE:\"%6.0lf MB avg\" " ;
- $def[1] .= "GPRINT:committed:MAX:\"%6.0lf MB max\\n\" " ;
- }
- }
+else {
+ $def[1] .= "LINE:virt#000000:\"RAM+SWAP used \" "
+ . "GPRINT:virt:LAST:\"%6.0lf MB last\" "
+ . "GPRINT:virt:AVERAGE:\"%6.0lf MB avg\" "
+ . "GPRINT:virt:MAX:\"%6.0lf MB max\\n\" "
+ ;
+}
+
+if (isset($RRD['mapped'])) {
+ $def[1] .= "DEF:mapped=$RRD[mapped] "
+ . "LINE2:mapped#8822ff:\"Memory mapped \" "
+ . "GPRINT:mapped:LAST:\"%6.0lf MB last\" "
+ . "GPRINT:mapped:AVERAGE:\"%6.0lf MB avg\" "
+ . "GPRINT:mapped:MAX:\"%6.0lf MB max\\n\" " ;
+}
+
+if (isset($RRD['committed_as'])) {
+ $def[1] .= "DEF:committed=$RRD[committed_as] "
+ . "LINE2:committed#cc00dd:\"Committed \" "
+ . "GPRINT:committed:LAST:\"%6.0lf MB last\" "
+ . "GPRINT:committed:AVERAGE:\"%6.0lf MB avg\" "
+ . "GPRINT:committed:MAX:\"%6.0lf MB max\\n\" " ;
+}
?>