Cleanup config.nodes_of
[check_mk.git] / checks / agent_vsphere
blob84cfcf9c86e98a55e9ea69e9eded40a55a3803ee
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # {
28 # 'tcp_port': 443,
29 # 'secret': 'wef',
30 # 'infos': ['hostsystem', 'virtualmachine'],
31 # 'user': 'wefwef'
32 # }
35 def agent_vsphere_arguments(params, hostname, ipaddress):
36 args = ''
37 if "tcp_port" in params:
38 args += " -p %d" % params["tcp_port"]
40 args += " -u " + quote_shell_string(params["user"])
41 args += " -s " + quote_shell_string(params["secret"])
42 args += " -i " + ",".join(params["infos"])
44 # Available options. Don't ask...
45 # True, _("Queried host is a host system" ) ),
46 # "hostsystem_agent", _("Queried host is a host system with Check_MK Agent installed") ),
47 # False, _("Queried host is the vCenter") ),
48 # "agent", _("Queried host is the vCenter with Check_MK Agent installed") ),
49 direct = params.get("direct", False)
50 if direct == "agent":
51 args += ' --agent'
52 elif direct == "hostsystem_agent":
53 args += ' --agent --direct --hostname ' + quote_shell_string(hostname)
54 elif direct:
55 args += ' --direct --hostname ' + quote_shell_string(hostname)
57 if params.get("skip_placeholder_vms", True):
58 args += " -P"
60 if "spaces" in params:
61 args += ' --spaces %s' % params["spaces"]
63 if "timeout" in params:
64 args += ' --timeout %d' % params["timeout"]
66 if params.get("use_pysphere"):
67 args += ' --pysphere'
69 if params.get("vm_pwr_display"):
70 args += ' --vm_pwr_display %s' % params.get("vm_pwr_display")
72 if params.get("vm_piggyname"):
73 args += ' --vm_piggyname %s' % params.get("vm_piggyname")
75 if params.get("host_pwr_display"):
76 args += ' --host_pwr_display %s' % params.get("host_pwr_display")
78 if params.get("snapshot_display", False):
79 args += ' --snapshot_display %s' % params.get("snapshot_display")
81 if "ssl" in params:
82 if params["ssl"] is False:
83 args += ' --no-cert-check ' + quote_shell_string(ipaddress)
84 elif params["ssl"] is True:
85 args += " " + quote_shell_string(hostname)
86 else:
87 args += " " + quote_shell_string(params["ssl"])
88 else: # legacy mode
89 args += " " + quote_shell_string(ipaddress)
91 return args
94 special_agent_info['vsphere'] = agent_vsphere_arguments