Module: check_mk
Branch: master
Commit: 984801a221fdbc2e9f1b9ce2fb5374f70f1d81e3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=984801a221fdbc…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Oct 18 11:39:47 2013 -0500
FIX: Windows agent: gracefully handle garbled logstate.txt
---
.bugs/1037 | 8 ++++++--
ChangeLog | 1 +
agents/windows/check_mk_agent.cc | 8 +++++++-
agents/windows/check_mk_agent.exe | Bin 151040 -> 151040 bytes
agents/windows/install_agent.exe | Bin 142807 -> 146764 bytes
5 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/.bugs/1037 b/.bugs/1037
index 461ab1d..ad21eff 100644
--- a/.bugs/1037
+++ b/.bugs/1037
@@ -1,9 +1,9 @@
Title: check_mk_agent.exe unable to restart after a crash: logstate.txt 0 bytes
Component: checks
-Class: bug
-State: open
+State: done
Date: 2013-08-27 10:58:29
Targetversion: 1.2.3i2
+Class: bug
Host = Windows 7
CMK Agent = Agent version 1.2.2p1
@@ -42,3 +42,7 @@ running on a VM server which has had problems, but the currupt
logstate.txt
file is always 123k in size and looks the same when edited.
2013-08-28: user did supply original logstate.txt file, see feedback/gitbug folder
+
+2013-10-18 11:39:01: changed state open -> done
+Should be fixed now. We now simply ignore invalid lines in logstate.txt.
+Had no chance to test it, though.
diff --git a/ChangeLog b/ChangeLog
index 78d7587..c4159ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -49,6 +49,7 @@
* check_tcp: Now able to set custom service description
* Apache ActiveMQ: New Special Agent and Check to query ActiveMQ Queues
* check_ftp: can now be configured via Wato
+ * FIX: Windows agent: gracefully handle garbled logstate.txt
* FIX: esx_vsphere_counters: added missing ramdisk type upgradescratch
* FIX: esx_vsphere_hostsystem: fixed bug in handling of params
* FIX: local: tolerate invalid output lines
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index df99612..5b1d486 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -1483,7 +1483,7 @@ void save_logwatch_offsets()
fclose(file);
}
-void parse_logwatch_state_line(char *line)
+void parse_logwatch_state_line(char *line)
{
/* Example: line = "M://log1.log|98374598374|0|16"; */
rstrip(line);
@@ -1492,11 +1492,17 @@ void parse_logwatch_state_line(char *line)
*p = 0;
char *path = line;
p++;
+
char *token = strtok(p, "|");
+ if (!token) return; // Ignore invalid lines
unsigned long long file_id = string_to_llu(token);
+
token = strtok(NULL, "|");
+ if (!token) return;
unsigned long long file_size = string_to_llu(token);
+
token = strtok(NULL, "|");
+ if (!token) return;
unsigned long long offset = string_to_llu(token);
logwatch_textfile *tf = new logwatch_textfile();
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index fe95a9c..4da6c4d 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index cd6d5d7..04df2af 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ