Module: check_mk
Branch: master
Commit: 28a8a979bf5dc53e89425c49740b0283012e7338
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=28a8a979bf5dc5…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Fri Feb 21 12:49:57 2014 +0100
FIX agent_vsphere: special agent now handles non-standard https port correctly
The special agent vsphere to monitor ESX-Servers and vcenters can be configured to use a
non-standard port for the vsphere https connection. This might be useful for firewall
traversals etc.
The configuration was possible before this fix in WATO, but it was never used, so that
the
default https port 443 was always used.
With this fix the port which is actually configured in WATO will be used for https.
If a vcenter is queried including the check_mk_agent, the check_mk_agent will still be
queried
on the standard check_mk_agent port 6556, whereas the https connection port will be the
one
configured in WATO.
---
.werks/584 | 19 +++++++++++++++++++
ChangeLog | 1 +
agents/special/agent_vsphere | 16 ++++++++++------
agents/special/agent_vsphere.pysphere | 18 ++++++++++++------
checks/agent_vsphere | 4 ++--
web/plugins/wato/datasource_programs.py | 4 ++--
6 files changed, 46 insertions(+), 16 deletions(-)
diff --git a/.werks/584 b/.werks/584
new file mode 100644
index 0000000..f825ce5
--- /dev/null
+++ b/.werks/584
@@ -0,0 +1,19 @@
+Title: agent_vsphere: special agent now handles non-standard https port correctly
+Level: 2
+Component: checks
+Version: 1.2.5i1
+Date: 1392982760
+Class: fix
+
+The special agent vsphere to monitor ESX-Servers and vcenters can be configured to use a
+non-standard port for the vsphere https connection. This might be useful for firewall
+traversals etc.
+
+The configuration was possible before this fix in WATO, but it was never used, so that
the
+default https port 443 was always used.
+
+With this fix the port which is actually configured in WATO will be used for https.
+
+If a vcenter is queried including the check_mk_agent, the check_mk_agent will still be
queried
+on the standard check_mk_agent port 6556, whereas the https connection port will be the
one
+configured in WATO.
diff --git a/ChangeLog b/ChangeLog
index cec9e42..fd5d37b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -182,6 +182,7 @@
* 0557 FIX: check_mk_agent.solaris: removed section statgrab mem...
* 0673 FIX: zfsget: Fixed broken check - was not compatible to current agent output
of "df"
* 0719 FIX: postfix_mailq: fix Linux agent in case of ssmtp being installed
+ * 0584 FIX: agent_vsphere: special agent now handles non-standard https port
correctly...
Multisite:
* 0371 Added log class filter to hostsvcevents view
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index b1ddcea..69f72ae 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -130,9 +130,10 @@ OPTIONS:
-D, --direct Assume a directly queried host system (no vCenter). In
This we expect data about only one HostSystem to be
found and do not create piggy host data for that host.
- -p Skip placeholder virtualmachines. These backup vms are
created
+ -P Skip placeholder virtualmachines. These backup vms are
created
by the Site Recovery Manager (SRM) and are identified by
not
having any assigned virtual disks.
+ -p, --port port Alternative port number (default is 443 for the https
connection)
--pysphere Fallback to old pysphere based special agent. It
supports
ESX 4.1 but is very slow.
-H, --hostname Specify a hostname. This is neccessary if this is
@@ -159,10 +160,10 @@ OPTIONS:
""")
-short_options = 'hi:u:s:Dat:H:cp'
+short_options = 'hi:u:s:Dat:H:cPp:'
long_options = [
'help', 'user=', 'secret=', 'direct',
'agent', 'debug', 'modules=', 'timeout=',
'hostname=',
- 'dump-counters', 'tracefile=', "pysphere",
+ 'dump-counters', 'tracefile=', "pysphere",
"port=",
]
opt_debug = False
@@ -170,6 +171,7 @@ opt_direct = False
opt_agent = False
opt_dump_counters = False
opt_timeout = 60
+opt_port = 443
opt_hostname = None
opt_skip_placeholder_vm = False
opt_pysphere = False
@@ -199,8 +201,10 @@ for o,a in opts:
opt_direct = True
elif o in [ '-a', '--agent' ]:
opt_agent = True
- elif o == '-p':
+ elif o == '-P':
opt_skip_placeholder_vm = True
+ elif o in [ '-p', '--port' ]:
+ opt_port = a
elif o == '--pysphere':
opt_pysphere = True
elif o in [ '-u', '--user' ]:
@@ -303,7 +307,7 @@ if tracefile:
try:
my_cookie = None
- netloc = host_address
+ netloc = host_address + ":" + str(opt_port)
request_uri = "/sdk"
transport = httplib.HTTPSConnection
transdict = {'timeout': opt_timeout}
@@ -311,7 +315,7 @@ try:
handle.connect()
if opt_debug:
- sys.stderr.write("Connecting to %s..." % host_address)
+ sys.stderr.write("Connecting to %s..." % netloc)
sys.stderr.flush()
def query_server(soapdata):
diff --git a/agents/special/agent_vsphere.pysphere
b/agents/special/agent_vsphere.pysphere
index ece7318..e2a4039 100755
--- a/agents/special/agent_vsphere.pysphere
+++ b/agents/special/agent_vsphere.pysphere
@@ -53,9 +53,10 @@ OPTIONS:
-D, --direct Assume a directly queried host system (no vCenter). In
This we expect data about only one HostSystem to be
Found and do not create piggy host data for that host.
- -p Skip placeholder virtualmachines. These backup vms are
created
+ -P Skip placeholder virtualmachines. These backup vms are
created
by the Site Recovery Manager (SRM) and are identified by
not
having any assigned virtual disks.
+ -p, --port port Alternative port number (default is 443 for the https
connection)
--pysphere Does nothing. For compatibility with new agent.
-H, --hostname Specify a hostname. This is neccessary if this is
different from HOST. It is being used in --direct
@@ -87,10 +88,10 @@ OPTIONS:
""")
-short_options = 'hi:u:s:Dat:H:cpS:'
+short_options = 'hi:u:s:Dat:H:cPp:S:'
long_options = [
'help', 'user=', 'secret=', 'direct',
'agent', 'debug', 'modules=', 'timeout=',
'hostname=',
- 'dump-counters', 'profile', 'pysphere', 'spaces='
+ 'dump-counters', 'profile', 'pysphere', 'spaces=',
'port='
]
try:
@@ -104,6 +105,7 @@ opt_direct = False
opt_agent = False
opt_dump_counters = False
opt_timeout = 60
+opt_port = 443
opt_hostname = None
opt_skip_placeholder_vm = False
opt_spaces = "cut"
@@ -127,8 +129,10 @@ for o,a in opts:
opt_direct = True
elif o in [ '-a', '--agent' ]:
opt_agent = True
- elif o in [ '-p' ]:
+ elif o in [ '-P' ]:
opt_skip_placeholder_vm = True
+ elif o in [ '-p', '--port' ]:
+ opt_port = a
elif o in [ '-u', '--user' ]:
user = a
elif o in [ '-s', '--secret' ]:
@@ -159,6 +163,8 @@ else:
sys.stderr.write("ERROR: Please specify exactly one host.\n")
sys.exit(1)
+port = ":" + str(opt_port)
+
socket.setdefaulttimeout(opt_timeout)
def get_agent_info_tcp(hostname):
@@ -215,9 +221,9 @@ try:
# server. Details can be found here:
#
http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim…)
if opt_debug:
- sys.stderr.write("Connecting to %s..." % host_address)
+ sys.stderr.write("Connecting to %s%s..." % (host_address, port))
sys.stderr.flush()
- host.connect(host_address, user, secret, sock_timeout=opt_timeout)
+ host.connect(host_address+port, user, secret, sock_timeout=opt_timeout)
if opt_debug:
sys.stderr.write("Connected.\n")
except socket.timeout:
diff --git a/checks/agent_vsphere b/checks/agent_vsphere
index e83c251..c917b39 100644
--- a/checks/agent_vsphere
+++ b/checks/agent_vsphere
@@ -25,7 +25,7 @@
# Boston, MA 02110-1301 USA.
# {
-# 'tcp_port': 4711,
+# 'tcp_port': 443,
# 'secret': 'wef',
# 'infos': ['hostsystem', 'virtualmachine'],
# 'user': 'wefwef'
@@ -48,7 +48,7 @@ def agent_vsphere_arguments(params, hostname, ipaddress):
args += ' --direct --hostname ' + quote_shell_string(hostname)
if params.get("skip_placeholder_vms", True):
- args += " -p"
+ args += " -P"
if "timeout" in params:
args += ' --timeout %d' % params["timeout"]
diff --git a/web/plugins/wato/datasource_programs.py
b/web/plugins/wato/datasource_programs.py
index 9989cbc..7b40e19 100644
--- a/web/plugins/wato/datasource_programs.py
+++ b/web/plugins/wato/datasource_programs.py
@@ -64,8 +64,8 @@ register_rule(group,
( "tcp_port",
Integer(
title = _("TCP Port number"),
- help = _("Port number for connecting to vSphere"),
- default_value = 4711,
+ help = _("Port number for https connection to
vSphere"),
+ default_value = 443,
minvalue = 1,
maxvalue = 65535,
)