From 8f5d97e002a1c0beeb7bb4b8040c7ede1a293db2 Mon Sep 17 00:00:00 2001 From: cn Date: Mon, 9 Jan 2012 21:07:28 +0100 Subject: [PATCH] Add doc and helper scripts --- README.md | 25 +++++++++++++++++++++++++ postfix_mailqueue | 7 +++++-- syslog5mins | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 README.md create mode 100755 syslog5mins diff --git a/README.md b/README.md new file mode 100644 index 0000000..42ec1a5 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +Low volume postfix_mailqueue munin plugin +========================================= + +The original postfix_mailqueue plugin delivered with munin does very well +in many aspects. But it has a design related problem: to measure the number +of mails per queue (active, incomming, deferred, ...) it counts the entries +in the corresponding spool directories every 5 minutes (when munin core asks). +If a mail only stays a short time in a queue (especially active and incomming +queues) it won't get recognized by postfix_mailqueue. + +Since on my low volume mailserver I'm interested in the total number of sent/ +recieved messages in the last 5 minutes (for the deferred and hold queues the +original method is good enough since a mail there probably stays longer than +5 minutes) I changed the behavior and meaning of the "active" and "incomming" +graphs to "outgoing" (to the network) and "incomming" (from the network). +To determine the number of mails for these graphs the recent (5 minutes, hardcoded) +syslog entries are grep'ed for signaling sequences indicating some kind of +action of postfix. + +syslog5mins +----------- + +This little script returns the entries of a (syslog created) file of the last +5 minutes. +**You should modify the scripts location in postfix_mailqueue script!** diff --git a/postfix_mailqueue b/postfix_mailqueue index 882e2ee..3e3b11c 100755 --- a/postfix_mailqueue +++ b/postfix_mailqueue @@ -78,6 +78,9 @@ munin-node. =cut +MAILLOG="/var/log/mail.log" +SYSLOG5MINS="/opt/syslog5mins" + # atempt to get spooldir via postconf, but environment overrides. # Remember that postconf is not available unless postfix is. @@ -127,10 +130,10 @@ cd $SPOOLDIR >/dev/null 2>/dev/null || { } cat <= 0; i-- )) ; do + # In %_d the underscore is important since it demands `date` + # to pad with spaces (like syslog for e.g. "Jan 1" to "Jan 9") + # instead of zeros. + dstring=`LANG=C date -d "-$i min" +"%b %_d %R"` + #echo "Entries for '$dstring':" + grep "^$dstring:.. " $1 +done