2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Plugin postfix-rbl-blocked-mails: separate count function

This commit is contained in:
Lars Kruse 2018-08-03 13:05:16 +02:00
parent f3525cfa4a
commit e77b778c91

View File

@ -9,6 +9,15 @@ LOGFILE=${logfile:-/var/log/mail.log}
DATE=`date '+%b %e %H'` DATE=`date '+%b %e %H'`
MAXLABEL=20 MAXLABEL=20
get_blocked_by_domain_count() {
local escaped_domain
# escape dots - for a proper regular expression
escaped_domain=$(echo "$1" | sed 's/\./\\./g')
grep -c "$DATE.*blocked using [^ ]*${escaped_domain}" "$LOGFILE"
}
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ -r "$LOGFILE" ]; then if [ -r "$LOGFILE" ]; then
echo yes echo yes
@ -32,14 +41,8 @@ if [ "$1" = "config" ]; then
fi fi
echo -en "spamhaus.value " printf 'spamhaus.value %s\n' "$(get_blocked_by_domain_count "sbl-xbl.spamhaus.org")"
echo $(grep "blocked using sbl-xbl.spamhaus.org" $LOGFILE | grep "$DATE" | wc -l) printf 'spamcop.value %s\n' "$(get_blocked_by_domain_count "bl.spamcop.net")"
echo -en "spamcop.value " printf 'manitu.value %s\n' "$(get_blocked_by_domain_count "ix.dnsbl.manitu.net")"
echo $(grep "blocked using bl.spamcop.net" $LOGFILE | grep "$DATE" | wc -l) printf 'msrbl.value %s\n' "$(get_blocked_by_domain_count "combined.rbl.msrbl.net")"
echo -en "manitu.value " printf 'njabl.value %s\n' "$(get_blocked_by_domain_count "combined.njabl.org")"
echo $(grep "blocked using ix.dnsbl.manitu.net" $LOGFILE | grep "$DATE" | wc -l)
echo -en "msrbl.value "
echo $(grep "blocked using combined.rbl.msrbl.net" $LOGFILE | grep "$DATE" | wc -l)
echo -en "njabl.value "
echo $(grep "blocked using combined.njabl.org" $LOGFILE | grep "$DATE" | wc -l)