Module: check_mk
Branch: master
Commit: b4a8bcb0c60c4d23a93cba9c9a82ccbb853021d1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b4a8bcb0c60c4d…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Mar 8 16:52:46 2016 +0100
3004 agent_vsphere: now able to configure used piggyback name for virtualmachines
In the ESX datasource program you can now set if used piggyback name is
taken from the ESX management view (most of the time an alias) or if the
actual hostname of the system should be used (if available).
The alias option is set as default.
---
.werks/3004 | 13 +++++++++++++
ChangeLog | 1 +
agents/special/agent_vsphere | 21 ++++++++++++++++-----
checks/agent_vsphere | 3 +++
web/plugins/wato/datasource_programs.py | 12 +++++++++++-
5 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/.werks/3004 b/.werks/3004
new file mode 100644
index 0000000..501d2a7
--- /dev/null
+++ b/.werks/3004
@@ -0,0 +1,13 @@
+Title: agent_vsphere: now able to configure used piggyback name for virtualmachines
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1457452277
+Class: feature
+
+In the ESX datasource program you can now set if used piggyback name is
+taken from the ESX management view (most of the time an alias) or if the
+actual hostname of the system should be used (if available).
+
+The alias option is set as default.
diff --git a/ChangeLog b/ChangeLog
index ad78576..ca94751 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,7 @@
* 3001 fileinfo: now able to configure the checks status if the file is missing
* 3088 rstcli, rstcli.pdisks: new checks to monitor Intel RST raids
* 3093 isc_dhcpd: now interprets include statements when parsing the configuration
file
+ * 3004 agent_vsphere: now able to configure used piggyback name for
virtualmachines...
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index d0372a3..f441bbb 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -268,6 +268,7 @@ telegram_list = {
'<ns1:pathSet>guest.toolsVersion</ns1:pathSet>'\
'<ns1:pathSet>guestHeartbeatStatus</ns1:pathSet>'\
'<ns1:pathSet>name</ns1:pathSet>'\
+ '<ns1:pathSet>summary.guest.hostName</ns1:pathSet>'\
'<ns1:pathSet>summary.quickStats.compressedMemory</ns1:pathSet>'\
'<ns1:pathSet>summary.quickStats.swappedMemory</ns1:pathSet>'\
'<ns1:pathSet>summary.quickStats.guestMemoryUsage</ns1:pathSet>'\
@@ -817,6 +818,9 @@ OPTIONS:
after the first space, "underscore": replace
with
underscores. Default is "underscore".
+ --vm_piggyname hostname|alias Here you can specify whether the virtual machines
HOSTNAME or the ESX
+ system ALIAS name for this machine should be used on
creating piggyback data
+
--vm_pwr_display WHERE Specifies where the virtual machines power state should
be shown
Default (no option) is on the queried vCenter or
ESX-Host
Possible WHERE options: * esxhost : show on ESX host
@@ -828,10 +832,11 @@ OPTIONS:
""")
-short_options = 'hi:u:s:Dat:H:Pp:S:'
+short_options = "hi:u:s:Dat:H:Pp:S:"
long_options = [
- 'help', 'user=', 'secret=', 'direct',
'agent', 'debug', 'modules=', 'timeout=',
'no-cert-check',
- 'hostname=', 'tracefile=', "pysphere", "port=",
"spaces=", "host_pwr_display=", "vm_pwr_display="
+ "help", "user=", "secret=", "direct",
"agent", "debug", "modules=", "timeout=",
"no-cert-check",
+ "hostname=", "tracefile=", "pysphere",
"port=", "spaces=", "host_pwr_display=",
"vm_pwr_display=",
+ "vm_piggyname="
]
opt_debug = False
@@ -845,6 +850,7 @@ opt_pysphere = False
opt_tracefile = None
opt_host_pwr_display = None
opt_vm_pwr_display = None
+opt_vm_piggyname = "alias"
opt_spaces = "underscore"
opt_no_cert = False
@@ -890,6 +896,8 @@ for o,a in opts:
opt_timeout = int(a)
elif o in [ '-H', '--hostname' ]:
opt_hostname = a
+ elif o in [ '--vm_piggyname' ]:
+ opt_vm_piggyname = a
elif o in [ '--vm_pwr_display' ]:
opt_vm_pwr_display = a
elif o in [ '--host_pwr_display' ]:
@@ -1550,13 +1558,16 @@ if not error:
if key in vm_data:
vm_data[key] = transform(vm_data[key])
- vms[vm_data.get("name")] = vm_data
+ if opt_vm_piggyname == "hostname" and
vm_data.get("summary.guest.hostName"):
+ vms[vm_data.get("summary.guest.hostName")] = vm_data
+ else:
+ vms[vm_data.get("name")] = vm_data
for key in sorted(vms.keys()):
data = vms[key]
if data.get("name"):
- output("<<<<%s>>>>" %
convert_hostname(data.get("name")))
+ output("<<<<%s>>>>" %
convert_hostname(key))
output("<<<esx_vsphere_vm>>>")
entries = list(data.items())
entries.sort()
diff --git a/checks/agent_vsphere b/checks/agent_vsphere
index cf1f0ad..8ac5141 100644
--- a/checks/agent_vsphere
+++ b/checks/agent_vsphere
@@ -62,6 +62,9 @@ def agent_vsphere_arguments(params, hostname, ipaddress):
if params.get("vm_pwr_display"):
args += ' --vm_pwr_display %s' % params.get("vm_pwr_display")
+ if params.get("vm_piggyname"):
+ args += ' --vm_piggyname %s' % params.get("vm_piggyname")
+
if params.get("host_pwr_display"):
args += ' --host_pwr_display %s' %
params.get("host_pwr_display")
diff --git a/web/plugins/wato/datasource_programs.py
b/web/plugins/wato/datasource_programs.py
index a67d8cb..6868be3 100644
--- a/web/plugins/wato/datasource_programs.py
+++ b/web/plugins/wato/datasource_programs.py
@@ -122,6 +122,16 @@ register_rule(group,
default = None,
)
),
+ ( "vm_piggyname",
+ DropdownChoice(
+ title = _("Piggyback name of virtual machines"),
+ choices = [
+ ( "alias", _("Use the name specified in the
ESX system") ),
+ ( "hostname", _("Use the VMs hostname if set,
otherwise fall back to ESX name") ),
+ ],
+ default = "alias",
+ )
+ ),
( "vm_pwr_display",
DropdownChoice(
title = _("Display VM power state on"),
@@ -178,7 +188,7 @@ register_rule(group,
)
),
],
- optional_keys = [ "tcp_port", "timeout",
"vm_pwr_display", "host_pwr_display" ],
+ optional_keys = [ "tcp_port", "timeout",
"vm_pwr_display", "host_pwr_display", "vm_piggyname" ],
),
title = _("Check state of VMWare ESX via vSphere"),
help = _("This rule selects the vSphere agent instead of the normal Check_MK
Agent "