Module: check_mk
Branch: master
Commit: c3a38138c36d6847d551e1c03324d4226ee93795
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c3a38138c36d68…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Oct 4 17:00:56 2016 +0200
3819 FIX windows agent: fixed 2 bugs related to mrpe
Calling MRPE scripts could cause an agent freeze.
The <i>run as</i> option didn't work as well.
Both issues have been fixed.
---
.werks/3819 | 12 ++++++++++++
ChangeLog | 1 +
agents/windows/sections/SectionMRPE.cc | 10 +++++-----
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/.werks/3819 b/.werks/3819
new file mode 100644
index 0000000..5504644
--- /dev/null
+++ b/.werks/3819
@@ -0,0 +1,12 @@
+Title: windows agent: fixed 2 bugs related to mrpe
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.4.0i2
+Date: 1475593227
+Class: fix
+
+Calling MRPE scripts could cause an agent freeze.
+The <i>run as</i> option didn't work as well.
+
+Both issues have been fixed.
diff --git a/ChangeLog b/ChangeLog
index 8309f46..b87c8cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
* 3841 cups_queues: thresholds are now configurable in WATO...
* 3894 FIX: mkeventd_status: Fixed bug in case Event Console is not running
* 3907 FIX: oracle_tablespaces: simplyfied free space calculation depending on
version...
+ * 3819 FIX: windows agent: fixed 2 bugs related to mrpe...
WATO:
* 3915 User access times: New icon when never logged in; New column "last
seen"
diff --git a/agents/windows/sections/SectionMRPE.cc
b/agents/windows/sections/SectionMRPE.cc
index 9fba51a..e4a69e0 100644
--- a/agents/windows/sections/SectionMRPE.cc
+++ b/agents/windows/sections/SectionMRPE.cc
@@ -125,17 +125,17 @@ bool SectionMRPE::produceOutputInner(std::ostream &out,
crash_log("%s (%s) %s ", entry->run_as_user, entry->plugin_name,
entry->service_description);
- char command[1024];
+ char modified_command[1024];
char run_as_prefix[512];
memset(run_as_prefix, 0, sizeof(run_as_prefix));
if (strlen(entry->run_as_user) > 0)
snprintf(run_as_prefix, sizeof(run_as_prefix), "runas /User:%s ",
entry->run_as_user);
- snprintf(command, sizeof(command), "%s%s", run_as_prefix,
+ snprintf(modified_command, sizeof(command), "%s%s", run_as_prefix,
entry->command_line);
try {
- ExternalCmd command(entry->command_line);
+ ExternalCmd command(modified_command);
crash_log("Script started -> collecting data");
std::string buffer;
buffer.resize(8192);
@@ -143,11 +143,11 @@ bool SectionMRPE::produceOutputInner(std::ostream &out,
char *pos = &buffer[0];
while (command.exitCode() == STILL_ACTIVE) {
DWORD read = command.readStdout(
- pos, buffer.size() - (pos - buf_start), true);
+ pos, buffer.size() - (pos - buf_start), false);
pos += read;
Sleep(10);
}
- command.readStdout(pos, buffer.size() - (pos - buf_start), true);
+ command.readStdout(pos, buffer.size() - (pos - buf_start), false);
char *output_end = rstrip(&buffer[0]);
char *plugin_output = lstrip(&buffer[0]);