Module: check_mk
Branch: master
Commit: db6e85626701ca9631de7d7bfa0c141d29cc9e0f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=db6e85626701ca…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Sep 20 10:20:37 2016 +0200
further update for WK3796
---
agents/special/agent_vsphere | 42 ++++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index 0552951..0999fee 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -854,7 +854,7 @@ opt_vm_piggyname = "alias"
opt_spaces = "underscore"
opt_no_cert = False
-win_agent_output = None
+win_agent_output = ""
error = None
error_exit = 1
@@ -940,6 +940,18 @@ vsphere_output = []
def output(line):
vsphere_output.append(line)
+# This function is used to modify the vsphere output, just before it is written to
stdout
+def check_winperf_processor(line):
+ if "<<<winperf_processor>>>" in win_agent_output:
+ try:
+ vsphere_output.remove(line)
+ except ValueError:
+ pass
+# A list of tuples: (line, function_pointer)
+# A certain line can register a function pointer
+# The function pointer is called later on with the line as argument
+postprocess_functions = []
+
socket.setdefaulttimeout(opt_timeout)
def get_agent_info_tcp(hostname):
response = ""
@@ -976,10 +988,6 @@ def get_agent_info_tcp(hostname):
return response
-if opt_agent:
- win_agent_output = get_agent_info_tcp(host_address)
- error_exit = 0
-
# Globals of ESX System. These settings are available after the first
"systeminfo" query
systemfields = [
("apiVersion", float),
@@ -1475,14 +1483,13 @@ if not error:
output("<<<<%s>>>>" %
convert_hostname(properties["name"][0]))
output("<<<esx_vsphere_hostsystem>>>")
- # Special handling. If the windows agent reports winperf_processor
skip
- # summary.quickStats.overallCpuUsage in output. This would lead to a
- # duplicate "CPU utlization" service
- skip_cpu_util = opt_agent and
"<<<winperf_processor>>>" in win_agent_output
-
for key in sorted(properties.keys()):
- if skip_cpu_util and key ==
"summary.quickStats.overallCpuUsage":
- continue
+ # Special handling. If the windows may report winperf_processor
in the following call
+ # remove summary.quickStats.overallCpuUsage from the output. This
would lead to a
+ # duplicate "CPU utlization" service
+ if opt_agent and key ==
"summary.quickStats.overallCpuUsage":
+ postprocess_functions.append(("%s %s" % (key,
" ".join(properties[key])), check_winperf_processor))
+
output("%s %s" % (key, "
".join(properties[key])))
output("<<<esx_vsphere_sensors:sep(59)>>>")
@@ -1695,11 +1702,18 @@ def make_utf8(line):
else:
return line
-print "\n".join(map(make_utf8, vsphere_output))
-
if opt_agent:
+ win_agent_output = get_agent_info_tcp(host_address)
sys.stdout.write(win_agent_output)
sys.stdout.flush()
+ error_exit = 0
+
+# May filter some data from the vsphere_output variable
+# Currently only used by winperf_processor special handling
+for line, function in postprocess_functions:
+ function(line)
+
+print "\n".join(map(make_utf8, vsphere_output))
if tracefile:
tracefile.close()