Module: check_mk
Branch: master
Commit: 051de2a8a65176e1d1a390c38fe14419f1c5254e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=051de2a8a65176…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Mar 27 13:55:21 2013 +0100
Added Manpage for esx_vsphere_objects
---
checkman/esx_vsphere_objects | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/checkman/esx_vsphere_objects b/checkman/esx_vsphere_objects
new file mode 100644
index 0000000..46db1d8
--- /dev/null
+++ b/checkman/esx_vsphere_objects
@@ -0,0 +1,20 @@
+title: Check completeness of output of ESX special agent
+agents: vsphere
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ This check makes sure that items sent by the ESX special agent (hostsystems
+ and VMs) are stil present later on. The information about this data can also
+ be used for determining the architecture of a VMWare farm out of the monitoring
+ data.
+
+ The check will get critical if a host system or virtual machine, that was once
+ present, is now missing.
+
+inventory:
+ One service per hostsystem and per VM will be created.
+
+item:
+ The text {HostSystem} or {VM} followed by a space followed by the name of the host system
+ or VM.
Module: check_mk
Branch: master
Commit: aa90bd0f534b149b8d698ac9313250efd1578338
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aa90bd0f534b14…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Mar 27 13:50:32 2013 +0100
ESX: Try to fix problem where no VM is present
---
agents/special/agent_vsphere | 26 ++++++++--------
checks/esx_vsphere_objects | 67 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 13 deletions(-)
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index 5713cbd..a9a80ba 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -65,8 +65,7 @@ except:
host = VIServer()
-object_collection = {}
-
+object_collection = []
try:
host.connect(params['HOST'], params['user'], params['secret'])
except:
@@ -112,7 +111,11 @@ def output_mors(what, properties, direct=False):
count = 0
sections = []
- for mor in host._retrieve_properties_traversal(property_names=properties.keys(), obj_type=obj_type):
+ mors = host._retrieve_properties_traversal(property_names=properties.keys(), obj_type=obj_type)
+ if not mors:
+ return
+
+ for mor in mors:
count += 1
# Parse result into a dictionary. Key is the property name,
# value is the value (some custom Python classes)
@@ -121,13 +124,10 @@ def output_mors(what, properties, direct=False):
# Convert property value using specified conversion function
data[p.Name] = properties[p.Name](p.Val)
- # Get the name of this Host/VirtualMachine
- # May there a comments in the field, so split at whitespace
- try:
- name = data["name"].split()[0]
- object_collection[name] = (what, data['name'])
- except:
- pass
+ # Remember the total list of output objects. We will put this into
+ # a special section
+ object_collection.append((what, data["name"]))
+ name = data["name"].split()[0] # get rid of comment
# Output multiplexed Check_MK Agent output (new in version 1.2.3i1)
if direct:
@@ -277,7 +277,7 @@ if "virtualmachine" in mortypes:
print "<<<<>>>>"
-print "<<<local>>>"
-for name, data in object_collection.items():
- print "0 %s-%s - OK: collecting piggyback data for %s" % (data[0], name, data[1])
+print "<<<esx_vsphere_objects:sep(9)>>>"
+for what, name in object_collection:
+ print "%s\t%s" % (what, name)
host.disconnect()
diff --git a/checks/esx_vsphere_objects b/checks/esx_vsphere_objects
new file mode 100644
index 0000000..61d8db5
--- /dev/null
+++ b/checks/esx_vsphere_objects
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | 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.
+
+# Example output from agent:
+# <<<esx_vsphere_objects:sep(9)>>>
+# hostsystem esx.wacker.corp
+# virtualmachine LinuxI
+# virtualmachine OpenSUSE_II
+# virtualmachine OpenSUSE_III
+# virtualmachine OpenSUSE_IV
+# virtualmachine OpenSUSE_V
+# virtualmachine WindowsXP I
+# virtualmachine LinuxII
+# virtualmachine LinuxIII
+# virtualmachine LinuxIV
+# virtualmachine LinuxV
+# virtualmachine OpenSUSE_I
+
+vsphere_object_names = {
+ "hostsystem" : "HostSystem",
+ "virtualmachine" : "VM",
+}
+
+def inventory_esx_vsphere_objects(info):
+ return [ (vsphere_object_names[line[0]] + " " + line[1], None) for line in info ]
+
+def check_esx_vsphere_objects(item, _no_params, info):
+ for line in info:
+ if vsphere_object_names[line[0]] + " " + line[1] == item:
+ return 0, "information about this object present"
+
+ what = item.split()[0]
+ name = item.split()[1]
+ if what == "VM":
+ return 3, "Virtual machine %s is missing" % name
+ else:
+ return 3, "No data about host system %s" % name
+
+
+check_info['esx_vsphere_objects'] = {
+ "inventory_function" : inventory_esx_vsphere_objects,
+ "check_function" : check_esx_vsphere_objects,
+ "service_description" : "%s",
+}