Module: check_mk
Branch: master
Commit: 4a808ab8064c0c5f5db2ded7c3f5d8e957106613
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4a808ab8064c0c…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Nov 11 14:51:34 2016 +0100
3963 check_mk_agent.linux: fixed strayed output of postfix status command
---
.werks/3963 | 10 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 17 +++++++++++++++--
checks/postfix_mailq_status | 2 +-
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.werks/3963 b/.werks/3963
new file mode 100644
index 0000000..4553b23
--- /dev/null
+++ b/.werks/3963
@@ -0,0 +1,10 @@
+Title: check_mk_agent.linux: fixed strayed output of postfix status command
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i3
+Date: 1478872023
+
+
diff --git a/ChangeLog b/ChangeLog
index 0d7db06..67a55b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
* 3979 FIX: vbox_guest: Only try to fetch VBox state in case the vboxguest module is
loaded
* 3750 FIX: cmc_temp: Check now also works when using Nagios core
* 3983 FIX: mssql_instance: Be more robust agains missing instance info in case of
connection issues
+ * 3963 FIX: check_mk_agent.linux: fixed strayed output of postfix status command
Multisite:
* 3974 FIX: Sorting comments in hover menu of comments icon by time now
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index e68ebb1..81e5180 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -668,9 +668,22 @@ elif [ -x /usr/sbin/ssmtp ] ; then
fi
# postfix would write to stderr but only if it's a tty
-if type postmulti >/dev/null ; then
+# Another quirk: output would be strayed if not stored
+# in extra variable
+if type postfix >/dev/null ; then
echo "<<<postfix_mailq_status:sep(58)>>>"
- postfix_out=$(script -qfc 'postmulti -p status' /dev/null)
+ multi_instances_dirs=$(postconf -c /etc/postfix 2>/dev/null | grep
^multi_instance_directories | sed 's/.*=[[:space:]]*//g')
+ if [ ! -z "$multi_instances_dirs" ]; then
+ for queue_dir in $multi_instances_dirs
+ do
+ if [ -n "$queue_dir" ]; then
+ postfix_out=$(script -qfc "postfix -c $queue_dir status"
/dev/null)
+ fi
+ done
+
+ else
+ postfix_out=$(script -qfc 'postfix status' /dev/null)
+ fi
echo $postfix_out
fi
diff --git a/checks/postfix_mailq_status b/checks/postfix_mailq_status
index c8cc56b..c9fad62 100644
--- a/checks/postfix_mailq_status
+++ b/checks/postfix_mailq_status
@@ -58,7 +58,7 @@ def inventory_postfix_mailq_status(parsed):
def check_postfix_mailq_status(item, params, parsed):
if item in parsed:
state_readable = parsed[item]["state"]
- pid = parsed[item].get("pid", "")
+ pid = parsed[item].get("pid")
if state_readable.endswith("is running"):
state = 0
else: