Module: check_mk
Branch: master
Commit: c89680f74e7a4124ab8b6adc45454830ac67f9c4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c89680f74e7a41…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Aug 19 17:08:41 2014 +0200
#1097 FIX windows_agent: preventing missing agent sections on first query
The windows agent did not report all sections on the first request(s) after
its startup, if some plugins were configured to run asynchronous.
This has been fixed. During startup, the agent now always executes the ASYNC scripts
first
and waits for them to finish. After the scripts are finished, it starts listening to
the tcp port.
---
.werks/1097 | 14 ++++++++
ChangeLog | 2 ++
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 208896 -> 208896 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 208896 -> 208896 bytes
agents/windows/check_mk_agent.cc | 42 +++++++++++++++++-----
agents/windows/check_mk_agent.exe | Bin 177664 -> 178176 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 177664 -> 178176 bytes
agents/windows/install_agent-64.exe | Bin 159871 -> 159961 bytes
agents/windows/install_agent.exe | Bin 156806 -> 156821 bytes
10 files changed, 50 insertions(+), 10 deletions(-)
diff --git a/.werks/1097 b/.werks/1097
new file mode 100644
index 0000000..0dacafa
--- /dev/null
+++ b/.werks/1097
@@ -0,0 +1,14 @@
+Title: windows_agent: preventing missing agent sections on first query
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1408460515
+Class: fix
+
+The windows agent did not report all sections on the first request(s) after
+its startup, if some plugins were configured to run asynchronous.
+
+This has been fixed. During startup, the agent now always executes the ASYNC scripts
first
+and waits for them to finish. After the scripts are finished, it starts listening to
+the tcp port.
diff --git a/ChangeLog b/ChangeLog
index 40d3a00..211fb13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,6 +39,7 @@
* 0198 FIX: cisco_temp_sensor: Removed dicey detection for temperature value....
* 0645 FIX: brocade_fcport: since in newer firmware (7.*) swFCPortSpeed is
deprecated, we then calculate port speed from IF-MIB::ifHighSpeed
* 0647 FIX: printer_input, printer_output: multiple fixes to algorithm for state
determination and inventory function...
+ * 1097 FIX: windows_agent: preventing missing agent sections on first query...
Multisite:
* 1066 Implemented Dashboard Designer...
@@ -47,6 +48,7 @@
* 1154 FIX: Availability: Fixed unwanted redirect to edit annotation page after
editing availability options...
WATO:
+ * 1095 New WATO Web-API: Now able to manage hosts via web automation calls
* 1096 New WATO webservices: manage hosts via webinterface...
* 1064 FIX: Fixed rare issue with WATO communication in distributed setups (different
OS versions)...
* 1089 FIX: Snapshot restore: fixed exception during exception handling......
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 98d9bcb..e1617e8 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-17
+57
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index 38e5220..b1933ac 100755
Binary files a/agents/windows/check_mk_agent-64.exe and
b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index 00cc87f..349cabb 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and
b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index bd26684..e69808e 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -265,6 +265,8 @@ void crash_log(const char *format, ...);
void lowercase(char* value);
char* next_word(char** line);
int get_perf_counter_id(const char* counter_name);
+void collect_script_data(script_execution_mode mode);
+void find_scripts();
// .----------------------------------------------------------------------.
// | ____ _ _ _ |
@@ -4201,6 +4203,24 @@ void listen_tcp_loop()
// and receive a terminate when the agent ends
g_workers_job_object = CreateJobObject(NULL, "workers_job");
+ // Run all ASYNC scripts on startup, so that their data is available on
+ // the first query of a client. Obviously, this slows down the agent startup...
+ // This procedure is mandatory, since we want to prevent missing agent sections
+ find_scripts();
+ collect_script_data(ASYNC);
+ DWORD dwExitCode = 0;
+ while (true)
+ {
+ if (GetExitCodeThread(g_collection_thread, &dwExitCode))
+ {
+ if (dwExitCode != STILL_ACTIVE)
+ break;
+ Sleep(200);
+ }
+ else
+ break;
+ }
+
SOCKET connection;
// Loop for ever.
debug("Starting main loop.");
@@ -4485,6 +4505,18 @@ void do_adhoc()
listen_tcp_loop(); // runs for ever or until Ctrl-C
}
+void find_scripts()
+{
+ // Check if there are new scripts available
+ // Scripts in default paths
+ determine_available_scripts(g_plugins_dir, PLUGIN, NULL);
+ determine_available_scripts(g_local_dir, LOCAL, NULL);
+ // Scripts included with user permissions
+ for (script_include_t::iterator it_include = g_script_includes.begin();
+ it_include != g_script_includes.end(); it_include++)
+ determine_available_scripts((*it_include)->path, (*it_include)->type,
(*it_include)->user);
+}
+
void output_data(SOCKET &out)
{
// make sure, output of numbers is not localized
@@ -4495,15 +4527,7 @@ void output_data(SOCKET &out)
update_script_statistics();
-
- // Check if there are new scripts available
- // Scripts in default paths
- determine_available_scripts(g_plugins_dir, PLUGIN, NULL);
- determine_available_scripts(g_local_dir, LOCAL, NULL);
- // Scripts included with user permissions
- for (script_include_t::iterator it_include = g_script_includes.begin();
- it_include != g_script_includes.end(); it_include++)
- determine_available_scripts((*it_include)->path, (*it_include)->type,
(*it_include)->user);
+ find_scripts();
if (enabled_sections & SECTION_CHECK_MK)
section_check_mk(out);
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index a87a33b..e529788 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 9dc34b5..e622182 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and
b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index 86342aa..b002fa9 100755
Binary files a/agents/windows/install_agent-64.exe and
b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 53d1127..24c616e 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ