Module: check_mk
Branch: master
Commit: 0dd9b4aca5d6e5e4dcb61eb546fdee0f0f0b7ce9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0dd9b4aca5d6e5…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Mar 20 15:19:33 2014 +0100
esx_vsphere_vm.running_on: shows the esx host of the VM
---
.werks/734 | 8 ++++++++
ChangeLog | 1 +
checkman/esx_vsphere_vm.running_on | 15 ++++++++++++++
checks/esx_vsphere_vm | 39 ++++++++++++++++++++++++++++++++++--
4 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/.werks/734 b/.werks/734
new file mode 100644
index 0000000..3f5af87
--- /dev/null
+++ b/.werks/734
@@ -0,0 +1,8 @@
+Title: esx_vsphere_vm.running_on: shows the esx host of the VM
+Level: 1
+Component: checks
+Version: 1.2.5i1
+Date: 1395325160
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 27b8ef6..99f6eb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -115,6 +115,7 @@
* 0716 Add Linux caching agent also to normal agent RPM...
* 0594 dell_poweredge_netdev: new check to monitor the status of network devices on
Dells Poweredge Servers
* 0733 mem, solaris_mem: now able to configure amount of free memory...
+ * 0734 esx_vsphere_vm.running_on: shows the esx host of the VM
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/checkman/esx_vsphere_vm.running_on b/checkman/esx_vsphere_vm.running_on
new file mode 100644
index 0000000..99a5c6e
--- /dev/null
+++ b/checkman/esx_vsphere_vm.running_on
@@ -0,0 +1,15 @@
+title: Virtual Machine under ESX: Hostsystem the VM is running on
+agents: vsphere
+catalog: os/misc
+license: GPL
+distribution: check_mk
+description:
+ This check provices information about the hostsystem where the VM is running on.
+
+ The check returns {OK}, unless the hostsystem is missing.
+ In this case it returns {UNKNOWN}.
+
+ See "Monitoring VMWare ESX with Check_MK" in the online documentation as
well.
+
+inventory:
+ On each VM one check is generated.
diff --git a/checks/esx_vsphere_vm b/checks/esx_vsphere_vm
index 1dee19b..219b12e 100644
--- a/checks/esx_vsphere_vm
+++ b/checks/esx_vsphere_vm
@@ -117,6 +117,41 @@ check_info['esx_vsphere_vm.name'] = {
"service_description" : "ESX Name",
}
+
+
+# .--Runtime Host--------------------------------------------------------.
+# | ____ _ _ _ _ _ |
+# | | _ \ _ _ _ __ | |_(_)_ __ ___ ___ | | | | ___ ___| |_ |
+# | | |_) | | | | '_ \| __| | '_ ` _ \ / _ \ | |_| |/ _ \/ __| __| |
+# | | _ <| |_| | | | | |_| | | | | | | __/ | _ | (_) \__ \ |_ |
+# | |_| \_\\__,_|_| |_|\__|_|_| |_| |_|\___| |_| |_|\___/|___/\__| |
+# | |
+# +----------------------------------------------------------------------+
+# | |
+# '----------------------------------------------------------------------'
+
+def inventory_esx_vsphere_vm_running_on(info):
+ data = esx_vsphere_vm_convert(info)
+ if 'runtime.host' in data:
+ return [(None, None)]
+ return []
+
+def check_esx_vsphere_vm_running_on(no_item, no_params, info):
+ data = esx_vsphere_vm_convert(info)
+
+ running_on = data.get("runtime.host")
+ if not running_on:
+ return 3, "Runtime host information is missing"
+
+ return 0, "Running on %s" % running_on[0]
+
+check_info['esx_vsphere_vm.running_on'] = {
+ "inventory_function" : inventory_esx_vsphere_vm_running_on,
+ "check_function" : check_esx_vsphere_vm_running_on,
+ "service_description" : "ESX Hostsystem",
+}
+
+
# .--VM Datastores--------------------------------------------------------.
# | __ ____ __ ____ _ _ |
# | \ \ / / \/ | | _ \ __ _| |_ __ _ ___| |_ ___ _ __ ___ |
@@ -133,7 +168,7 @@ def inventory_esx_vsphere_vm_datastores(info):
# Right now we only handle one datastore per vm
if 'config.datastoreUrl' in data:
return [(None, None)]
- return
+ return []
def check_esx_vsphere_vm_datastores(no_item, no_params, info):
data = esx_vsphere_vm_convert(info)
@@ -165,7 +200,7 @@ def check_esx_vsphere_vm_datastores(no_item, no_params, info):
else:
free_perc = 0.0
- output_store = "Running on %s (%s/%0.1f%% free)" %\
+ output_store = "Stored on %s (%s/%0.1f%% free)" %\
(datastore_dict.get("name"),
get_bytes_human_readable(capacity),
free_perc)