Module: check_mk
Branch: master
Commit: a50bbb6f450a8c5f79837be45ff9f99dccb60851
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a50bbb6f450a8c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 18 14:50:51 2016 +0200
3672 FIX Agent sections cached by the agent could cause stale services
There are situations, when the agent is caching sections and the check
interval of a check is configured to a special value, that services will
become stale even when the agent could still send cached information.
For example the ntp section which is cached for 30 seconds, wen using a
check interval of 120 seconds, could become stale after 180 seconds when
the update of the agent cache takes more than 60 seconds. The agent would
then throw away the cache which is currently updated and return no ntp
section which results in a stale service then.
The fix is now, that in such a situation the agent is processing the old,
already cached, section and restarting the cache update immediately
(instead of the last run as it was before).
---
.werks/3672 | 22 ++++++++++++++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 7 ++++---
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.werks/3672 b/.werks/3672
new file mode 100644
index 0000000..4fee24f
--- /dev/null
+++ b/.werks/3672
@@ -0,0 +1,22 @@
+Title: Agent sections cached by the agent could cause stale services
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1468845997
+
+There are situations, when the agent is caching sections and the check
+interval of a check is configured to a special value, that services will
+become stale even when the agent could still send cached information.
+
+For example the ntp section which is cached for 30 seconds, wen using a
+check interval of 120 seconds, could become stale after 180 seconds when
+the update of the agent cache takes more than 60 seconds. The agent would
+then throw away the cache which is currently updated and return no ntp
+section which results in a stale service then.
+
+The fix is now, that in such a situation the agent is processing the old,
+already cached, section and restarting the cache update immediately
+(instead of the last run as it was before).
diff --git a/ChangeLog b/ChangeLog
index 219c4a7..cea99fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -313,6 +313,7 @@
* 3708 FIX: cisco_vpn_tunnel: fixed missing phase 2 data
* 3556 FIX: agent_vsphere.pysphere: The ESX 4.1 compatible agent version no longer validates the ssl certificate
* 3709 FIX: cisco_wlc, cisco_wlc_clients: fixed scan function and incomplete listing of interfaces
+ * 3672 FIX: Agent sections cached by the agent could cause stale services...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 30afede..fa4e8db 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -145,8 +145,10 @@ function run_cached () {
if [ ! -d $MK_VARDIR/cache ]; then mkdir -p $MK_VARDIR/cache ; fi
CACHEFILE="$MK_VARDIR/cache/$NAME.cache"
- # Check if the creation of the cache takes suspiciously long and return
- # nothing if the age (access time) of $CACHEFILE.new is twice the MAXAGE
+ # Check if the creation of the cache takes suspiciously long and kill the
+ # process if the age (access time) of $CACHEFILE.new is twice the MAXAGE.
+ # Output the evantually already cached section anyways and start the cache
+ # update again.
if [ -e "$CACHEFILE.new" ] ; then
local CF_ATIME=$(stat -c %X "$CACHEFILE.new")
if [ $((NOW - CF_ATIME)) -ge $((MAXAGE * 2)) ] ; then
@@ -154,7 +156,6 @@ function run_cached () {
# it is still running. This avoids overlapping processes!
fuser -k -9 "$CACHEFILE.new" >/dev/null 2>&1
rm -f "$CACHEFILE.new"
- return
fi
fi
Module: check_mk
Branch: master
Commit: f44b2f0925b735e5fbd4443a5c203cd1dadfc672
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f44b2f0925b735…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Jul 18 11:16:07 2016 +0200
3558 check_mail: now able to process mail body with Content-Transfer-Encoding base64
When forwarding mails to the event console the plugin now
decodes any base64 content back to human readable lines.
---
.werks/3558 | 10 ++++++++++
ChangeLog | 1 +
doc/treasures/active_checks/check_mail | 15 ++++++++++++---
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/.werks/3558 b/.werks/3558
new file mode 100644
index 0000000..7eda279
--- /dev/null
+++ b/.werks/3558
@@ -0,0 +1,10 @@
+Title: check_mail: now able to process mail body with Content-Transfer-Encoding base64
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i1
+Date: 1468833224
+Class: feature
+
+When forwarding mails to the event console the plugin now
+decodes any base64 content back to human readable lines.
diff --git a/ChangeLog b/ChangeLog
index 6b2d57b..c35803a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -114,6 +114,7 @@
* 3554 Inotify: Added configurable levels for movedto, movefrom and move self
* 3706 hp_proliant_systeminfo, hp_proliant_mem, hp_proliant_da_phydrv: new inventory plugins
* 3671 mssql_backup: Is now aware of backup types and outputs ages per backup type
+ * 3558 check_mail: now able to process mail body with Content-Transfer-Encoding base64...
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/doc/treasures/active_checks/check_mail b/doc/treasures/active_checks/check_mail
index bdc2ba2..d88ae28 100755
--- a/doc/treasures/active_checks/check_mail
+++ b/doc/treasures/active_checks/check_mail
@@ -26,6 +26,7 @@
import sys, getopt, os, time, random, poplib, imaplib, email
import traceback, socket, re
+import base64
def parse_exception(e):
e = str(e)
@@ -296,7 +297,8 @@ def forward_to_ec(mails):
cur_time = syslog_time()
priority = 5 # OK
for index, msg in mails.items():
- subject = msg.get('Subject', 'None')
+ subject = msg.get('Subject', 'None')
+ encoding = msg.get('Content-Transfer-Encoding', 'None')
log_line = subject
# Now add the body to the event
if msg.is_multipart():
@@ -305,10 +307,17 @@ def forward_to_ec(mails):
content_type = part.get_content_type()
disposition = str(part.get('Content-Disposition'))
if content_type == 'text/plain' and 'attachment' not in disposition:
- log_line += '|' + part.get_payload()[:body_limit]
+ payload = part.get_payload()
+ if encoding == "base64"
+ payload = base64.b64decode(payload)
+ log_line += '|' + payload[:body_limit]
break
else:
- log_line += '|' + msg.get_payload()[:body_limit]
+ payload = msg.get_payload()
+ if encoding == "base64"
+ payload = base64.b64decode(payload)
+ log_line += '|' + payload[:body_limit]
+
log_line = log_line.replace('\r\n', '\0')
log_line = log_line.replace('\n', '\0')