Module: check_mk
Branch: master
Commit: ffe92bd943a13fdb18af290a841844e0231a6840
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ffe92bd943a13f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Mar 30 17:37:48 2011 +0200
Agent simulator: also work in simulation mode
---
modules/check_mk_base.py | 38 ++++++++++++++++++--------------------
1 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 9667140..31c0aba 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -358,9 +358,6 @@ def get_realhost_info(hostname, ipaddress, checkname, max_cache_age):
elif len(output) < 16:
raise MKAgentError("Too short output from agent: '%s'" %
output)
- if agent_simulator:
- output = agent_simulator_process(output)
-
lines = [ l.strip() for l in output.split('\n') ]
info = parse_info(lines)
store_cached_hostinfo(hostname, info)
@@ -414,25 +411,26 @@ def write_cache_file(relpath, output):
# In that case it will be looked up if needed. Also caching will
# be handled here
def get_agent_info(hostname, ipaddress, max_cache_age):
- result = read_cache_file(hostname, max_cache_age)
- if result:
- return result
-
- # Try to contact every host only once
- if hostname in g_broken_agent_hosts:
- raise MKAgentError("")
+ output = read_cache_file(hostname, max_cache_age)
+ if not output:
+ # Try to contact every host only once
+ if hostname in g_broken_agent_hosts:
+ raise MKAgentError("")
+
+ # If the host ist listed in datasource_programs the data from
+ # that host is retrieved by calling an external program (such
+ # as ssh or rsy) instead of a TCP connect.
+ commandline = get_datasource_program(hostname, ipaddress)
+ if commandline:
+ output = get_agent_info_program(commandline)
+ else:
+ output = get_agent_info_tcp(hostname, ipaddress)
- # If the host ist listed in datasource_programs the data from
- # that host is retrieved by calling an external program (such
- # as ssh or rsy) instead of a TCP connect.
- commandline = get_datasource_program(hostname, ipaddress)
- if commandline:
- output = get_agent_info_program(commandline)
- else:
- output = get_agent_info_tcp(hostname, ipaddress)
+ # Got new data? Write to cache file
+ write_cache_file(hostname, output)
- # Got new data? Write to cache file
- write_cache_file(hostname, output)
+ if agent_simulator:
+ output = agent_simulator_process(output)
return output