Module: check_mk
Branch: master
Commit: 6681b27bf15b413ba9018bc34c6e5ff728d41b71
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6681b27bf15b41…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Apr 16 15:12:00 2013 +0200
Several fixes in ESX VM checks
---
checks/esx_vsphere_virtualmachine | 67 +++++++++++++++++++++++++++---------
web/plugins/perfometer/check_mk.py | 7 +++-
2 files changed, 57 insertions(+), 17 deletions(-)
diff --git a/checks/esx_vsphere_virtualmachine b/checks/esx_vsphere_virtualmachine
index f9c127f..3b3bf95 100644
--- a/checks/esx_vsphere_virtualmachine
+++ b/checks/esx_vsphere_virtualmachine
@@ -30,35 +30,44 @@ def esx_vsphere_virtualmachine_convert(info):
data[line[0]] = line[1:]
return data
-esx_machine_mem_default = {}
+# .--Memory--------------------------------------------------------------.
+# | __ __ |
+# | | \/ | ___ _ __ ___ ___ _ __ _ _ |
+# | | |\/| |/ _ \ '_ ` _ \ / _ \| '__| | | | |
+# | | | | | __/ | | | | | (_) | | | |_| | |
+# | |_| |_|\___|_| |_| |_|\___/|_| \__, | |
+# | |___/ |
+# '----------------------------------------------------------------------'
+
def inventory_esx_vsphere_virtualmachine_mem(info):
data = esx_vsphere_virtualmachine_convert(info).keys()
if 'summary.quickStats.guestMemoryUsage' in data:
- return [(None, esx_machine_mem_default)]
+ return [(None, {})]
def check_esx_vsphere_virtualmachine_mem(item, params, info):
data = esx_vsphere_virtualmachine_convert(info)
- #active guest memory
- guest_memory_usage =
savefloat(data["summary.quickStats.guestMemoryUsage"][0]) * 1024 * 1024
#consumed host memory
host_memory_usage =
savefloat(data["summary.quickStats.hostMemoryUsage"][0]) * 1024 * 1024
+ #active guest memory
+ guest_memory_usage =
savefloat(data["summary.quickStats.guestMemoryUsage"][0]) * 1024 * 1024
#size of the balloon driver in the VM
ballooned_memory =
savefloat(data["summary.quickStats.balloonedMemory"][0]) * 1024 * 1024
#The portion of memory, in MB, that is granted to this VM from non-shared host
memor(musst not be set)
- private_memory =
savefloat(data.get("summary.quickStats.privateMemory",[0])[0]) * 1024 * 1024
- #The portion of memory, in MB, that is granted to this VM from host memory that is
shared between VMs.
shared_memory = savefloat(data["summary.quickStats.sharedMemory"][0])
* 1024 * 1024
+ #The portion of memory, in MB, that is granted to this VM from host memory that is
shared between VMs.
+ private_memory =
savefloat(data.get("summary.quickStats.privateMemory",[0])[0]) * 1024 * 1024
perf = [
- ("host_memory_usage", host_memory_usage ),
- ("guest_memory_usage", guest_memory_usage ),
- ("ballooned_memory", ballooned_memory ),
- ("shared_memory", shared_memory ),
+ ("host", host_memory_usage ),
+ ("guest", guest_memory_usage ),
+ ("ballooned", ballooned_memory ),
+ ("shared", shared_memory ),
+ ("private", private_memory ),
]
- message = "Consumed: %s, Active: %s, " \
+ message = "Host: %s, Guest: %s, " \
"Ballooned: %s, Private: %s, Shared: %s" % \
(get_bytes_human_readable(host_memory_usage), \
get_bytes_human_readable(guest_memory_usage),
get_bytes_human_readable(ballooned_memory), \
@@ -73,11 +82,20 @@ check_info['esx_vsphere_virtualmachine.mem_usage'] = {
"has_perfdata" : True
}
+#.
+# .--Name----------------------------------------------------------------.
+# | _ _ |
+# | | \ | | __ _ _ __ ___ ___ |
+# | | \| |/ _` | '_ ` _ \ / _ \ |
+# | | |\ | (_| | | | | | | __/ |
+# | |_| \_|\__,_|_| |_| |_|\___| |
+# | |
+# '----------------------------------------------------------------------'
def inventory_esx_vsphere_virtualmachine_name(info):
data = esx_vsphere_virtualmachine_convert(info).keys()
- if 'summary.quickStats.guestMemoryUsage' in data and
'config.hardware.memoryMB' in data:
- return [(None, esx_machine_mem_default)]
+ if 'name' in data:
+ return [(None, None)]
def check_esx_vsphere_virtualmachine_name(item, params, info):
data = esx_vsphere_virtualmachine_convert(info)
@@ -90,9 +108,26 @@ check_info['esx_vsphere_virtualmachine.name'] = {
"service_description" : "ESX Name",
}
+#.
+# .--Heartbeat-----------------------------------------------------------.
+# | _ _ _ _ _ |
+# | | | | | ___ __ _ _ __| |_| |__ ___ __ _| |_ |
+# | | |_| |/ _ \/ _` | '__| __| '_ \ / _ \/ _` | __| |
+# | | _ | __/ (_| | | | |_| |_) | __/ (_| | |_ |
+# | |_| |_|\___|\__,_|_| \__|_.__/ \___|\__,_|\__| |
+# | |
+# '----------------------------------------------------------------------'
+
+# Possible values (this list is taken from the official documentation)
+# gray - VMware Tools are not installed or not running.
+# red - No heartbeat. Guest operating system may have stopped responding.
+# yellow - Intermittent heartbeat. May be due to guest load.
+# green - Guest operating system is responding normally.
+#
def inventory_esx_vsphere_virtualmachine_hb_status(info):
- data = esx_vsphere_virtualmachine_convert(info).keys()
- if 'guestHeartbeatStatus' in data:
+ data = esx_vsphere_virtualmachine_convert(info)
+ status = data.get('guestHeartbeatStatus')
+ if status and status[0] != "gray":
return [(None, None)]
def check_esx_vsphere_virtualmachine_hb_status(item, params, info):
@@ -114,6 +149,6 @@ def check_esx_vsphere_virtualmachine_hb_status(item, params, info):
check_info['esx_vsphere_virtualmachine.heartbeat'] = {
"inventory_function" : inventory_esx_vsphere_virtualmachine_hb_status,
"check_function" : check_esx_vsphere_virtualmachine_hb_status,
- "service_description" : "ESX Heartbeat Status",
+ "service_description" : "ESX Heartbeat",
}
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index 560e654..4d203d9 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -649,7 +649,12 @@ def perfometer_simple_mem_usage(row, command, perf):
perfometers['check_mk-db2_mem'] = perfometer_simple_mem_usage
perfometers['check_mk-esx_vsphere_hostsystem.mem_usage'] =
perfometer_simple_mem_usage
-perfometers['check_mk-esx_vsphere_virtualmachine.mem_usage'] =
perfometer_simple_mem_usage
+
+def perfometer_vmguest_mem_usage(row, command, perf):
+ used = float(perf[0][1])
+ return number_human_readable(used), perfometer_logarithmic(used, 1024*1024*2000, 2,
"#20cf80")
+
+perfometers['check_mk-esx_vsphere_virtualmachine.mem_usage'] =
perfometer_vmguest_mem_usage
def perfometer_esx_vsphere_hostsystem_cpu(row, command, perf):
used_perc = float(perf[0][1])