From 892be6fa13d6a4d7e7992417c033ec04e7493047 Mon Sep 17 00:00:00 2001 From: "Roberto \"Roobre\" Santalla" Date: Wed, 19 Nov 2014 05:30:31 +0100 Subject: [PATCH 1/2] Fixed sent/received count and replaced wc -l with -c --- plugins/postfix/postfix_mail_stats | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 plugins/postfix/postfix_mail_stats diff --git a/plugins/postfix/postfix_mail_stats b/plugins/postfix/postfix_mail_stats new file mode 100755 index 00000000..f9e1e237 --- /dev/null +++ b/plugins/postfix/postfix_mail_stats @@ -0,0 +1,68 @@ +#!/bin/bash +# +# Made by Boudewijn Ector, for Boudewijn Ector IT. +# Comments can be sent to (boudewijnboudewijnector'dot'NL) +# Loosely based on http://munin.projects.linpro.no/attachment/wiki/PluginCat/postfix_messages_hourly.txt +# Script to show postfix stuff +# +# Modified by Paul Saunders , 10 Dec 2010 +# +# Parameters understood: +# +# config (required) +# autoconf (optional - used by munin-config) +# +# +# Magic markers (optional - used by munin-config and installation +# scripts): +# +#%# family=auto +#%# capabilities=autoconf + + +LOGFILE=${logfile:-/var/log/maillog} # Allow user to specify logfile through env.logfile +DATE=`date '+%b %e %H'` +MAXLABEL=20 + +if [ "$1" = "autoconf" ]; then + if [[ -r $LOGFILE ]]; then + echo yes + else + echo no + fi + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title Postfix Mail Counter' + echo 'graph_args --base 1000 -l 0' + echo 'graph_vlabel Hourly Messages' + echo 'recieved.label Delivered' + echo 'sent.label Outgoing' + echo 'rejecthelo.label Invalid HELO' + echo 'rejectsenderdomain.label need FQDN' + echo 'denyrelay.label Relay Denied' + echo 'spamhaus.label Blocked using Spamhaus.org' + echo 'spamcop.label Blocked using Spamcop' + exit 0 +fi + +echo -en "recieved.value " +echo $(grep "postfix/lmtp\[" $LOGFILE | grep "$DATE" -c) +echo -n +echo -en "sent.value " +echo $(grep "postfix/smtp\[" $LOGFILE | grep "$DATE" -c) +echo -en "rejecthelo.value " +echo $(grep "Helo command rejected: need fully-qualified hostname" $LOGFILE | grep "$DATE" -c) +echo -en "rejectsenderdomain.value " +echo $(grep "Sender address rejected: Domain not found" $LOGFILE | grep "$DATE" -c) + + +echo -en "denyrelay.value " +echo $(grep "Relay access denied" $LOGFILE | grep "$DATE" -c) +echo -en "spamhaus.value " +echo $(grep "blocked using sbl-xbl.spamhaus.org" $LOGFILE | grep "$DATE" -c) +echo -en "spamcop.value " +echo $(grep "blocked using bl.spamcop.net" $LOGFILE | grep "$DATE" -c) + From 72c5b59d4860185db3227ed0cae8939c4b6e67d5 Mon Sep 17 00:00:00 2001 From: "Roberto \"Roobre\" Santalla" Date: Wed, 19 Nov 2014 05:40:27 +0100 Subject: [PATCH 2/2] Now category "postfix" is correctly reported. --- plugins/postfix/postfix_mail_stats | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/postfix/postfix_mail_stats b/plugins/postfix/postfix_mail_stats index f9e1e237..2ac2866e 100755 --- a/plugins/postfix/postfix_mail_stats +++ b/plugins/postfix/postfix_mail_stats @@ -36,6 +36,7 @@ fi if [ "$1" = "config" ]; then echo 'graph_title Postfix Mail Counter' + echo 'graph_category postfix' echo 'graph_args --base 1000 -l 0' echo 'graph_vlabel Hourly Messages' echo 'recieved.label Delivered'