Module: check_mk
Branch: master
Commit: 7104b7963f82cf1403abfd9bdbf2923a0b74ea2b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7104b7963f82cf…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 3 15:06:17 2014 +0100
#1564 FIX check_mk_agent.linux: fix situation where async plugin is not executed after
crash
When executing asynchronous sections or plugins the Check_MK Agent uses
<tt>run_cached()</tt> for putting them in the background. This function
creates a cachefile with the extension <tt>.new</tt> and removes that suffix
when the actual plugin has finished. If due to a server crash the file keeps
lying around the the plugin would not be executed anymore.
We now remove that file if it is older then twice the cache age <i>and
we kill</i> any process that still has open that file. That way we avoid
overlapping plugins in case of a real hanger.
---
.werks/1564 | 17 +++++++++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 4 ++++
3 files changed, 22 insertions(+)
diff --git a/.werks/1564 b/.werks/1564
new file mode 100644
index 0000000..27feb51
--- /dev/null
+++ b/.werks/1564
@@ -0,0 +1,17 @@
+Title: check_mk_agent.linux: fix situation where async plugin is not executed after
crash
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417615386
+Class: fix
+
+When executing asynchronous sections or plugins the Check_MK Agent uses
+<tt>run_cached()</tt> for putting them in the background. This function
+creates a cachefile with the extension <tt>.new</tt> and removes that suffix
+when the actual plugin has finished. If due to a server crash the file keeps
+lying around the the plugin would not be executed anymore.
+
+We now remove that file if it is older then twice the cache age <i>and
+we kill</i> any process that still has open that file. That way we avoid
+overlapping plugins in case of a real hanger.
diff --git a/ChangeLog b/ChangeLog
index f3d3dce..2680676 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,7 @@
* 1602 FIX: dell_om_esmlog: Fixed typo in plugin output
* 1563 FIX: Reworked configuration of process monitoring...
NOTE: Please refer to the migration notes!
+ * 1564 FIX: check_mk_agent.linux: fix situation where async plugin is not executed
after crash...
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index abb95f2..c734bb1 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -81,6 +81,10 @@ function run_cached () {
if [ -e "$CACHEFILE.new" ] ; then
local CF_ATIME=$(stat -c %X "$CACHEFILE.new")
if [ $((NOW - CF_ATIME)) -ge $((MAXAGE * 2)) ] ; then
+ # Kill the process still accessing that file in case
+ # it is still running. This avoids overlapping processes!
+ fuser -k -9 "$CACHEFILE.new" >/dev/null 2>&1
+ rm -f "$CACHEFILE.new"
return
fi
fi