Module: check_mk
Branch: master
Commit: fdb7be44da538cc09a9f5cbc604779e4e67f9b15
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fdb7be44da538c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 2 16:05:07 2015 +0100
#2876 FIX mk_logwatch: Avoid parsing lines that are currently being written by
application
Thanks to Václav Chlumský.
---
.werks/2876 | 9 +++++++++
ChangeLog | 1 +
agents/plugins/mk_logwatch | 6 ++++++
3 files changed, 16 insertions(+)
diff --git a/.werks/2876 b/.werks/2876
new file mode 100644
index 0000000..280d94f
--- /dev/null
+++ b/.werks/2876
@@ -0,0 +1,9 @@
+Title: mk_logwatch: Avoid parsing lines that are currently being written by application
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1449068658
+Class: fix
+
+Thanks to Václav Chlumský.
diff --git a/ChangeLog b/ChangeLog
index 13e90bf..ec0fbee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -128,6 +128,7 @@
* 2857 FIX: fritz.conn: Handling missing connection state infos as UNKNOWN
* 2858 FIX: hp_proliant_da_phydrv: Adding disk controller to check items...
NOTE: Please refer to the migration notes!
+ * 2876 FIX: mk_logwatch: Avoid parsing lines that are currently being written by
application...
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/agents/plugins/mk_logwatch b/agents/plugins/mk_logwatch
index efbb40e..6e114b8 100755
--- a/agents/plugins/mk_logwatch
+++ b/agents/plugins/mk_logwatch
@@ -165,6 +165,12 @@ def next_line(file_handle):
else:
try:
line = file_handle.next()
+ # Avoid parsing of (yet) incomplete lines (when acutal application
+ # is just in the process of writing)
+ if not line.endswith(os.linesep):
+ begin_of_line_offset = file_handle.tell() - len(line)
+ os.lseek(file_handle.fileno(), begin_of_line_offset, 0)
+ return None
return line
except:
return None