Add doc and helper scripts

This commit is contained in:
cn 2012-01-09 21:07:28 +01:00
parent d020f29b34
commit 8f5d97e002
3 changed files with 45 additions and 2 deletions

25
README.md Normal file
View File

@ -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!**

View File

@ -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 <<EOF
outgoing.value `/opt/syslog5mins /var/log/mail.log | grep "postfix/smtp\[.*status=sent" | wc -l`
outgoing.value `$SYSLOG5MINS $MAILLOG | grep "postfix/smtp\[.*status=sent" | wc -l`
deferred.value `(test -d deferred && find deferred -type f ) | wc -l`
maildrop.value `(test -d maildrop && find maildrop -type f ) | wc -l`
incoming.value `/opt/syslog5mins /var/log/mail.log | grep "postfix/pipe\[.*status=sent" | wc -l`
incoming.value `$SYSLOG5MINS $MAILLOG | grep "postfix/pipe\[.*status=sent" | wc -l`
corrupt.value `(test -d corrupt && find corrupt -type f ) | wc -l`
hold.value `( test -d hold && find hold -type f ) | wc -l`
EOF

15
syslog5mins Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
if [ "$1" == "" ]; then
echo "No file given!"
exit 1
fi
for (( i = 4; i >= 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