Module: check_mk
Branch: master
Commit: faca93075fda5d40bc51ba3b86a72d2845a93c65
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=faca93075fda5d…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Oct 10 09:15:32 2016 +0200
3954 postfix_mailq_status: new check which monitors the status of postfix mail instances
---
.werks/3954 | 9 +++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 5 +++
checkman/postfix_mailq_status | 15 +++++++++
checks/postfix_mailq_status | 77 +++++++++++++++++++++++++++++++++++++++++++
5 files changed, 107 insertions(+)
diff --git a/.werks/3954 b/.werks/3954
new file mode 100644
index 0000000..1ad9120
--- /dev/null
+++ b/.werks/3954
@@ -0,0 +1,9 @@
+Title: postfix_mailq_status: new check which monitors the status of postfix mail
instances
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i2
+Date: 1476083683
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 399c932..bfd956e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@
* 3911 if.include: each operational state can now be mapped to a check state
* 3912 elphase.include: now device states can be mapped to monitoring states
* 3913 gude_relayport, gude_temp, gude_humidity: new checks and relayport check now
monitors electricity
+ * 3954 postfix_mailq_status: new check which monitors the status of postfix mail
instances
* 3894 FIX: mkeventd_status: Fixed bug in case Event Console is not running
* 3907 FIX: oracle_tablespaces: simplyfied free space calculation depending on
version...
* 3819 FIX: windows agent: fixed 2 bugs related to mrpe...
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index c7dfcf8..c44f860 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -667,6 +667,11 @@ elif [ -x /usr/sbin/ssmtp ] ; then
fi
+if type postmulti >/dev/null ; then
+ echo "<<<postfix_mailq_status:sep(58)>>>"
+ postmulti -p status
+fi
+
# Check status of qmail mailqueue
if type qmail-qstat >/dev/null
diff --git a/checkman/postfix_mailq_status b/checkman/postfix_mailq_status
new file mode 100644
index 0000000..323cfce
--- /dev/null
+++ b/checkman/postfix_mailq_status
@@ -0,0 +1,15 @@
+title: Status of postfix mail instances
+agents: linux
+catalog: app/postfix
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the status of postfix mail instances on linux hosts.
+
+ The status is OK if the mail instance is running, otherwise CRIT.
+
+item:
+ The instance name if multi instance is configured.
+
+inventory:
+ One service per instance is created.
diff --git a/checks/postfix_mailq_status b/checks/postfix_mailq_status
new file mode 100644
index 0000000..c8cc56b
--- /dev/null
+++ b/checks/postfix_mailq_status
@@ -0,0 +1,77 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2016 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+# single
+# <<<postfix_mailq_status:sep(58)>>>
+# postfix/postfix-script: the Postfix mail system is running: PID: 2839
+
+# multi instances
+# <<<postfix_mailq_status:sep(58)>>>
+# postfix/postfix-script: the Postfix mail system is running: PID: 12910
+# postfix-external/postfix-script: the Postfix mail system is running: PID: 12982
+# postfix-internal/postfix-script: the Postfix mail system is running: PID: 13051
+# postfix-uat-cdi/postfix-script: the Postfix mail system is not running
+
+
+def parse_postfix_mailq_status(info):
+ parsed = {}
+ for line in info:
+ stripped_line = map(lambda x: x.strip(), line)
+ queuename = stripped_line[0].split("/")[0]
+ if queuename == "postfix":
+ queuename = ""
+ parsed.setdefault(queuename, { "state" : stripped_line[1] })
+ if len(line) > 2:
+ parsed[queuename]["pid"] = stripped_line[-1]
+
+ return parsed
+
+
+def inventory_postfix_mailq_status(parsed):
+ return [ (queuename, None) for queuename in parsed ]
+
+
+def check_postfix_mailq_status(item, params, parsed):
+ if item in parsed:
+ state_readable = parsed[item]["state"]
+ pid = parsed[item].get("pid", "")
+ if state_readable.endswith("is running"):
+ state = 0
+ else:
+ state = 2
+ yield state, 'Status: %s' % state_readable
+
+ if pid:
+ yield 0, 'PID: %s' % pid
+
+
+check_info['postfix_mailq_status'] = {
+ 'parse_function' : parse_postfix_mailq_status,
+ 'inventory_function' : inventory_postfix_mailq_status,
+ 'check_function' : check_postfix_mailq_status,
+ 'service_description' : 'Postfix status %s',
+}