Module: check_mk
Branch: master
Commit: ab1a59cadb9f6a15334f1bc0546e3fe4939ae27b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ab1a59cadb9f6a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Mar 18 12:54:08 2013 +0100
Finalize ESX host system memory check
---
checkman/check_mk-esx_vsphere_hostsystem.mem_usage | 36 ++++++++++++++
checks/esx_vsphere_hostsystem | 17 ++++---
.../check_mk-esx_vsphere_hostsystem.mem_usage.php | 49 ++++++++++++++++++++
web/plugins/perfometer/check_mk.py | 2 +-
web/plugins/wato/check_parameters.py | 16 ++++++-
5 files changed, 109 insertions(+), 11 deletions(-)
diff --git a/checkman/check_mk-esx_vsphere_hostsystem.mem_usage
b/checkman/check_mk-esx_vsphere_hostsystem.mem_usage
new file mode 100644
index 0000000..9285297
--- /dev/null
+++ b/checkman/check_mk-esx_vsphere_hostsystem.mem_usage
@@ -0,0 +1,36 @@
+title: Check usage of physical RAM on ESX host system
+agents: vsphere
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ This check measures the current usage of physical RAM by
+ an ESX host system.
+
+inventory:
+ One check per ESX host system is being created.
+
+
+perfdata:
+ One value: the current usage in bytes.
+
+[parameters]
+warning (int or float): the percentage of virtual memory used
+ by processes at which WARNING state is triggered. If the
+ level is defined as an integer value then it is interpreted
+ as an absolute value in megabytes.
+critical (int or float): the percentage or absolute value
+ at which CRITICAL state is triggered
+
+
+[configuration]
+memused_default_levels (float, float): Levels used by
+ all checks that are created by inventory.
+
+mem_extended_perfdata (boolean): If this variable is set
+ to {True}, then the checks outputs additional performance
+ data, if the agent provides that information. On Linux
+ the amount of mapped and committed memory is output
+ (see {Mapped} and {Committed_AS} in {/proc/meminfo}) and
+ also the size used for page tables {Pagetables}.
+
diff --git a/checks/esx_vsphere_hostsystem b/checks/esx_vsphere_hostsystem
index fb7ea53..36170ae 100644
--- a/checks/esx_vsphere_hostsystem
+++ b/checks/esx_vsphere_hostsystem
@@ -93,39 +93,40 @@ check_info['esx_vsphere_hostsystem.cpu_usage'] = {
-esx_host_mem_default = ( 80.0, 90.0 )
+esx_host_mem_default_levels = ( 80.0, 90.0 )
def inventory_esx_vsphere_hostsystem_mem(info):
data = esx_vsphere_hostsystem_convert(info).keys()
if 'summary.quickStats.overallMemoryUsage' in data and
'hardware.memorySize' in data:
- return [(None, esx_host_mem_default)]
+ return [(None, 'esx_host_mem_default_levels')]
def check_esx_vsphere_hostsystem_mem(item, params, info):
data = esx_vsphere_hostsystem_convert(info)
memory_usage = savefloat(data['summary.quickStats.overallMemoryUsage'][0]) *
1024 * 1024
memory_size = savefloat(data['hardware.memorySize'][0])
level = memory_usage / memory_size * 100
+
warn, crit = params
state = 0
label = ''
if level > crit:
state = 2
- label = "(!!) (Levels at %d%%/%d%%)" % (warn, crit)
+ label = " (Levels at %d%%/%d%%)" % (warn, crit)
elif level > warn:
state = 1
- label = "(!) (Levels at %d%%/%d%%)" % (warn, crit)
+ label = " (Levels at %d%%/%d%%)" % (warn, crit)
- message = "Memory usage: %d%%%s %s/%s" % \
+ message = "%d%%%s used - %s/%s" % \
(level, label, get_bytes_human_readable(memory_usage),
get_bytes_human_readable(memory_size))
- perf = [("usage", memory_usage, warn, crit, 0, memory_size)]
+ perf = [("usage", memory_usage, warn * memory_size / 100, crit *
memory_size / 100, 0, memory_size)]
return(state, message, perf)
check_info['esx_vsphere_hostsystem.mem_usage'] = {
"inventory_function" : inventory_esx_vsphere_hostsystem_mem,
"check_function" : check_esx_vsphere_hostsystem_mem,
- "service_description" : "ESX Memory usage",
- "group" : "memory",
+ "service_description" : "Memory used",
+ "group" : "esx_host_memory",
"has_perfdata" : True
}
diff --git a/pnp-templates/check_mk-esx_vsphere_hostsystem.mem_usage.php
b/pnp-templates/check_mk-esx_vsphere_hostsystem.mem_usage.php
new file mode 100644
index 0000000..2cd3095
--- /dev/null
+++ b/pnp-templates/check_mk-esx_vsphere_hostsystem.mem_usage.php
@@ -0,0 +1,49 @@
+<?php
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+$opt[1] = "--vertical-label 'Memory (Bytes)' --upper-limit " . $MAX[1]
. " -l0 --title \"Memory usage of $hostname\" ";
+
+$total_gb = $MAX[1] / 1073741824.0;
+$total_text = sprintf("%.2fGB", $total_gb);
+
+$def[1] = "DEF:used=$RRDFILE[1]:$DS[1]:MAX "
+ . "CDEF:usedgb=used,1073741824,/ "
+ . "HRULE:$MAX[1]#000080:\"Total memory\: $total_text\" ";
+if ($WARN[1]) {
+ $def[1] .= "HRULE:$WARN[1]#FFFF00:\"Warning (used)\" "
+ . "HRULE:$CRIT[1]#FF0000:\"Critical (used)\" ";
+}
+
+$def[1] .= "'COMMENT:\\n' "
+ . "AREA:used#20cf80:\"Used main memory \" "
+ . "GPRINT:usedgb:LAST:\"%6.2lf GB last\" "
+ . "GPRINT:usedgb:AVERAGE:\"%6.2lf GB avg\" "
+ . "GPRINT:usedgb:MAX:\"%6.2lf GB max\\n\" "
+ ;
+
+
+$def[1] .= "LINE:used#00af60:\"\" " ;
+
+?>
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index b09e758..a39f7a8 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -637,7 +637,7 @@ def perfometer_simple_mem_usage(row, command, perf):
maxw = float(perf[0][6])
used_level = float(perf[0][1])
used_perc = (100.0 / maxw) * used_level
- return "%d%% used" % used_perc , perfometer_linear(used_perc,
"#0000FF")
+ return "%d%%" % used_perc , perfometer_linear(used_perc,
"#20cf80")
perfometers['check_mk-db2_mem'] = perfometer_simple_mem_usage
perfometers['check_mk-esx_vsphere_hostsystem.mem_usage'] =
perfometer_simple_mem_usage
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index bc04a4a..05fc956 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1466,8 +1466,8 @@ register_check_parameters(
Tuple(
title = _("Specify levels in percentage of total RAM"),
elements = [
- Percentage(title = _("Warning at a usage of"), label =
_("% of RAM"), max_value = None),
- Percentage(title = _("Critical at a usage of"), label =
_("% of RAM"), max_value = None)]),
+ Percentage(title = _("Warning at a memory usage of"),
default_value = 80.0),
+ Percentage(title = _("Critical at a memory usage of"),
default_value = 90.0)]),
Tuple(
title = _("Specify levels in absolute usage values"),
elements = [
@@ -1478,6 +1478,18 @@ register_check_parameters(
)
register_check_parameters(
+ subgroup_os,
+ "esx_host_memory",
+ _("Main memory usage of ESX host system"),
+ Tuple(
+ title = _("Specify levels in percentage of total RAM"),
+ elements = [
+ Percentage(title = _("Warning at a RAM usage of"), default_value =
80.0),
+ Percentage(title = _("Critical at a RAM usage of"), default_value =
90.0)]),
+ None, None
+)
+
+register_check_parameters(
subgroup_printing,
"printer_supply",
_("Printer cardridge levels"),