Module: check_mk
Branch: master
Commit: bb9a6d46ba183d848917531b77a143d99c406304
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bb9a6d46ba183d…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Mon Aug 31 14:51:32 2015 +0200
fixes and improvements to the windows agent
fix: the commit c9b807a7 changed some string comparisons from case insensitive to
sensitive
fix: commit c9b807a7 dealt incorrectly with inability to create statefile
fix: commit c9b807a7 didn't include new binaries
agent now automatically creates all required files
---
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 302080 -> 307712 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 302080 -> 307712 bytes
agents/windows/check_mk_agent.cc | 33 ++++++++++++++++------
agents/windows/check_mk_agent.exe | Bin 183808 -> 190464 bytes
agents/windows/check_mk_agent.msi | Bin 734720 -> 747008 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 183808 -> 190464 bytes
agents/windows/install_agent-64.exe | Bin 179108 -> 181025 bytes
agents/windows/install_agent.exe | Bin 160059 -> 163071 bytes
9 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 7d645f5..9d683f8 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-208
+214
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index a89e9f1..c9c1214 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 854cef4..0c809f5 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 364a54e..8e07b0f 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -561,7 +561,17 @@ void debug_script_container( script_container* container )
crash_log("buffer_work: \n<<<<\n%s\n>>>>",
container->buffer_work);
}
+bool ci_compare_pred(unsigned char lhs, unsigned char rhs)
+{
+ return std::tolower(lhs) == std::tolower(rhs);
+}
+// case insensitive compare
+bool ci_equal(const std::string &lhs, const std::string &rhs)
+{
+ return std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end(), ci_compare_pred);
+}
template <typename FuncT> FuncT dynamic_func(LPCWSTR dllName, LPCSTR funcName) {
HMODULE mod = LoadLibraryW(dllName);
@@ -1807,13 +1817,9 @@ void save_logwatch_offsets()
{
FILE *file = fopen(g_logwatch_statefile, "w");
if (!file) {
- fprintf(stderr, "Cannot open %s for writing.\n",
g_logwatch_statefile);
- // what to do, what to do?
- // If we continue, the whole log will be delivered all the time and
- // this error message may go unnoticed which will feel like a bug.
- // Allow the agent to crash? Even more of a bug.
- // Try to fix the problem automatically? Won't work reliably anyway.
- exit(1);
+ crash_log("Cannot open %s for writing.\n", g_logwatch_statefile);
+ // not stopping the agent from crashing. This way the user at least
+ // notices something went wrong
}
for (logwatch_textfiles_t::iterator it_tf = g_logwatch_textfiles.begin();
it_tf != g_logwatch_textfiles.end(); it_tf++) {
@@ -1885,7 +1891,7 @@ void save_eventlog_offsets()
for (eventlog_config_t::iterator conf_iter = g_eventlog_config.begin();
conf_iter != g_eventlog_config.end();
++conf_iter) {
- if ((conf_iter->name == "*") || (conf_iter->name ==
state_iter->name)) {
+ if ((conf_iter->name == "*") || ci_equal(conf_iter->name,
state_iter->name)) {
level = conf_iter->level;
break;
}
@@ -2537,7 +2543,7 @@ void section_eventlog(SOCKET &out)
int hide_context = 0;
for (eventlog_config_t::iterator conf_iter = g_eventlog_config.begin();
conf_iter != g_eventlog_config.end();
++conf_iter) {
- if ((conf_iter->name == "*") || (conf_iter->name ==
it_st->name)) {
+ if ((conf_iter->name == "*") ||
ci_equal(conf_iter->name, it_st->name)) {
level = conf_iter->level;
hide_context = conf_iter->hide_context;
break;
@@ -4987,6 +4993,15 @@ void determine_directories(bool use_cwd)
snprintf(g_temp_dir, sizeof(g_temp_dir), "%s\\temp",
g_agent_directory);
snprintf(g_log_dir, sizeof(g_log_dir), "%s\\log",
g_agent_directory);
+ char *dirs[] = { g_plugins_dir, g_config_dir, g_local_dir, g_spool_dir, g_state_dir,
g_temp_dir, g_log_dir };
+ for (size_t i = 0; i < sizeof(dirs) / sizeof(char*); ++i) {
+ if (!CreateDirectoryA(dirs[i], NULL)) {
+ if (GetLastError() != ERROR_ALREADY_EXISTS) {
+ crash_log("Failed to create directory %s: %s", GetLastError(),
get_last_error_as_string().c_str());
+ }
+ }
+ }
+
snprintf(g_logwatch_statefile, sizeof(g_logwatch_statefile),
"%s\\logstate.txt", g_state_dir);
snprintf(g_eventlog_statefile, sizeof(g_eventlog_statefile),
"%s\\eventstate.txt", g_state_dir);
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index ae2db3a..e256d3a 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.msi b/agents/windows/check_mk_agent.msi
index 042c8a3..c0a28da 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi
differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 865f9df..aefd2bc 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 4f0dd81..a3b6674 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 79080cb..07c47cb 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ