mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Category Tree: Collect all postfix plugins in category mail
This commit is contained in:
parent
db240286ab
commit
cc3622d96c
14 changed files with 26 additions and 26 deletions
53
plugins/postfix/postfix-policyd
Executable file
53
plugins/postfix/postfix-policyd
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor incoming mails greylisted by postfix-policyd
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional)
|
||||
#
|
||||
|
||||
MYSQL_USER="postfix-policyd"
|
||||
MYSQL_PASS=""
|
||||
MYSQL_DB="postfixpolicyd"
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -n "${MYSQL_PASS}" ] ; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (set mysql pass)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Postfix-Policyd daily filtering'
|
||||
echo 'graph_order delayed passed whitelisted'
|
||||
echo 'graph_category mail'
|
||||
echo 'graph_vlabel Count'
|
||||
echo 'graph_scale no'
|
||||
|
||||
## echo 'graph_args --base 1000 -l 0'
|
||||
echo 'delayed.label delayed'
|
||||
echo 'delayed.type GAUGE'
|
||||
echo 'passed.label passed'
|
||||
echo 'passed.type GAUGE'
|
||||
echo 'whitelisted.label whitelisted'
|
||||
echo 'whitelisted.type GAUGE'
|
||||
echo 'blacklisted.label blacklisted'
|
||||
echo 'blacklisted.type GAUGE'
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DELAYED="`echo "SELECT COUNT(*) FROM triplet WHERE _count = 0" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`"
|
||||
PASSED="`echo "SELECT COUNT(*) FROM triplet WHERE _count != 0" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`"
|
||||
WHITELISTED="`echo "SELECT COUNT(*) FROM whitelist" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`"
|
||||
BLACKLISTED="`echo "SELECT COUNT(*) FROM blacklist" | mysql -u${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} | egrep [0-9]`"
|
||||
|
||||
echo "delayed.value ${DELAYED}"
|
||||
echo "passed.value ${PASSED}"
|
||||
echo "whitelisted.value ${WHITELISTED}"
|
||||
echo "blacklisted.value ${BLACKLISTED}"
|
134
plugins/postfix/postfix-queue-size
Executable file
134
plugins/postfix/postfix-queue-size
Executable file
|
@ -0,0 +1,134 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: << =cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
postfix_mailqueue - Plugin to monitor postfix mail spools
|
||||
|
||||
=head1 ABOUT
|
||||
|
||||
A guide to postfix mail queue manageent can be found at
|
||||
L<http://www.postfix.org/QSHAPE_README.html#queues>
|
||||
|
||||
A summary:
|
||||
|
||||
=over 4
|
||||
|
||||
=item maildrop
|
||||
|
||||
Messages that have been submitted via the Postfix sendmail(1) command,
|
||||
but not yet brought into the main Postfix queue by the pickup(8)
|
||||
service.
|
||||
|
||||
=item hold
|
||||
|
||||
Messages placed in the "hold" queue stay there until the administrator
|
||||
intervenes
|
||||
|
||||
=item incoming
|
||||
|
||||
Inbound mail from the network, or mail picked up by the local
|
||||
pickup(8) daemon from the maildrop directory.
|
||||
|
||||
=item active
|
||||
|
||||
Messages that the queue manager has opened for delivery. Only a limited number
|
||||
of messages is allowed to enter the active queue (leaky bucket strategy, for a
|
||||
fixed delivery rate).
|
||||
|
||||
=item deferred
|
||||
|
||||
Mail that could not be delivered upon the first attempt. The queue manager
|
||||
implements exponential backoff by doubling the time between delivery attempts.
|
||||
|
||||
=item corrupt
|
||||
|
||||
Unreadable or damaged queue files are moved here for inspection.
|
||||
|
||||
=back
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
By default "postconf -h queue_directory" is used to determine the
|
||||
spool directory. Is postconf is not available in the $PATH then
|
||||
/var/spool/postfix is assumed. This can be overridden by the
|
||||
"spooldir" environment variable like so:
|
||||
|
||||
[postfix_mailqueue]
|
||||
env.spooldir /var/spool/postfix
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Unknown.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Unknown.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
=begin comment
|
||||
|
||||
These magic markers are used by munin-node-configure when installing
|
||||
munin-node.
|
||||
|
||||
=end comment
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=cut
|
||||
|
||||
# atempt to get spooldir via postconf, but environment overrides.
|
||||
|
||||
# Remember that postconf is not available unless postfix is.
|
||||
POSTCONFSPOOL="$(postconf -h queue_directory 2>/dev/null || echo /var/spool/postfix)"
|
||||
SPOOLDIR=${spooldir:-$POSTCONFSPOOL}
|
||||
|
||||
. $MUNIN_LIBDIR/plugins/plugin.sh
|
||||
|
||||
case $1 in
|
||||
autoconf|detect)
|
||||
|
||||
if [ -d $SPOOLDIR ] ; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (spooldir not found)"
|
||||
exit 0
|
||||
fi;;
|
||||
config)
|
||||
cat <<'EOF'
|
||||
graph_title Postfix Queue Size
|
||||
graph_vlabel KB in Queue
|
||||
graph_category mail
|
||||
graph_total Total
|
||||
active.label active
|
||||
deferred.label deferred
|
||||
maildrop.label maildrop
|
||||
incoming.label incoming
|
||||
corrupt.label corrupt
|
||||
hold.label held
|
||||
EOF
|
||||
for field in active deferred maildrop incoming corrupt hold; do
|
||||
print_warning $field
|
||||
print_critical $field
|
||||
done
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
cd $SPOOLDIR >/dev/null 2>/dev/null || {
|
||||
echo "# Cannot cd to $SPOOLDIR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cat <<EOF
|
||||
deferred.value `du -sb $SPOOLDIR/* | grep deferred | awk '{print $1}'`
|
||||
active.value `du -sb $SPOOLDIR/* | grep active | awk '{print $1}'`
|
||||
maildrop.value `du -sb $SPOOLDIR/* | grep maildrop | awk '{print $1}'`
|
||||
incoming.value `du -sb $SPOOLDIR/* | grep incoming | awk '{print $1}'`
|
||||
corrupt.value `du -sb $SPOOLDIR/* | grep corrupt | awk '{print $1}'`
|
||||
hold.value `du -sb $SPOOLDIR/* | grep hold | awk '{print $1}'`
|
||||
EOF
|
45
plugins/postfix/postfix-rbl-blocked-mails
Executable file
45
plugins/postfix/postfix-rbl-blocked-mails
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Made by Stefan Bühler, Switzerland
|
||||
# Monitor blocked Mails during Postfix RBL Scan, included Spamhaus, Spamcop, Manitu, MSRBL, NJABL
|
||||
|
||||
|
||||
LOGFILE=${logfile:-/var/log/mail.log} # 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 RBL Counter'
|
||||
echo 'graph_category mail'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel block during RBL'
|
||||
echo 'spamhaus.label Blocked by Spamhaus.org'
|
||||
echo 'spamcop.label Blocked by Spamcop'
|
||||
echo 'manitu.label Blocked by manitu.net'
|
||||
echo 'msrbl.label Blocked by msrbl.net'
|
||||
echo 'njabl.label Blocked by njabl.org'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
echo -en "spamhaus.value "
|
||||
echo $(grep "blocked using sbl-xbl.spamhaus.org" $LOGFILE | grep "$DATE" | wc -l)
|
||||
echo -en "spamcop.value "
|
||||
echo $(grep "blocked using bl.spamcop.net" $LOGFILE | grep "$DATE" | wc -l)
|
||||
echo -en "manitu.value "
|
||||
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)
|
||||
|
160
plugins/postfix/postfix_filtered
Executable file
160
plugins/postfix/postfix_filtered
Executable file
|
@ -0,0 +1,160 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor incoming Postfix mail.
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional)
|
||||
#
|
||||
|
||||
|
||||
|
||||
# If you are using a postfix policy daemon (such as policyd) to track certain block conditions, place a line
|
||||
# in your /etc/munin/plugin-conf.d/munin-node like:
|
||||
#
|
||||
# [postfix*]
|
||||
# env.policy my policy string
|
||||
#
|
||||
# When env.policy is set, this plugin will match the string you supply as env.policy and return the number of instances
|
||||
# of that string as an output called "policy.value".
|
||||
#
|
||||
# If you are NOt using a postfix policy daemon, as above, use the line
|
||||
#
|
||||
# [postfix*]
|
||||
# env.policy none
|
||||
#
|
||||
# and this plugin will suppress output of policy.value
|
||||
|
||||
|
||||
|
||||
|
||||
POLICY=${policy}
|
||||
|
||||
if [ "$POLICY" = "none" ]
|
||||
then POLICY=""
|
||||
fi
|
||||
|
||||
|
||||
LOGDIR=${logdir:-/var/log/mail}
|
||||
MAIL_LOG=$LOGDIR/${logfile:-info}
|
||||
LOGTAIL=${logtail:-`which logtail`}
|
||||
STATEFILE=/var/lib/munin/plugin-state/postfix_mailfiltered.offset
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Postfix message filtering'
|
||||
|
||||
if [ -z "$POLICY" ]
|
||||
then
|
||||
echo 'graph_order allowed rbl helo client sender recipient relay'
|
||||
else
|
||||
echo 'graph_order allowed rbl policy helo client sender recipient relay'
|
||||
fi
|
||||
echo 'graph_category mail'
|
||||
echo 'graph_vlabel Mails per second'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
|
||||
echo 'allowed.label Allowed'
|
||||
echo 'allowed.min 0'
|
||||
echo 'allowed.type ABSOLUTE'
|
||||
|
||||
echo 'rbl.label RBL blocked'
|
||||
echo 'rbl.min 0'
|
||||
echo 'rbl.type ABSOLUTE'
|
||||
|
||||
if [ -z "$POLICY" ]
|
||||
then
|
||||
echo "empty" > /dev/null
|
||||
else
|
||||
echo 'policy.label Policy blocked'
|
||||
echo 'policy.min 0'
|
||||
echo 'policy.type ABSOLUTE'
|
||||
fi
|
||||
|
||||
echo 'helo.label HELO rejected'
|
||||
echo 'helo.min 0'
|
||||
echo 'helo.type ABSOLUTE'
|
||||
|
||||
echo 'client.label Client rejected'
|
||||
echo 'client.min 0'
|
||||
echo 'client.type ABSOLUTE'
|
||||
|
||||
echo 'sender.label Sender rejected'
|
||||
echo 'sender.min 0'
|
||||
echo 'sender.type ABSOLUTE'
|
||||
|
||||
echo 'recipient.label Recipient unknown'
|
||||
echo 'recipient.min 0'
|
||||
echo 'recipient.type ABSOLUTE'
|
||||
|
||||
echo 'relay.label Relay denied'
|
||||
echo 'relay.min 0'
|
||||
echo 'relay.type ABSOLUTE'
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$POLICY" ]
|
||||
then
|
||||
|
||||
result=`$LOGTAIL ${MAIL_LOG} $STATEFILE \
|
||||
| egrep "postfix\/smtpd?\[[0-9]*\]: ([NOQUA-F]+:|[A-F0-9]+:) " \
|
||||
| grep -v "Server configuration problem" \
|
||||
| grep -v "Data command rejected" \
|
||||
| grep -v " client=" \
|
||||
| sed -e "s/.*\(Relay access denied\|blocked using\|Helo command rejected\|Client host rejected\|Sender address rejected\|Recipient address rejected\|queued as\).*/\1/g" \
|
||||
| sort | uniq -c \
|
||||
| sed -e "s/ *\([0-9]\+\) queued as/value.allowed \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Relay access denied/value.relay \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) blocked using/value.rbl \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Helo command rejected/value.helo \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Client host rejected/value.client \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Sender address rejected/value.sender \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Recipient address rejected/value.recipient \1/" `
|
||||
|
||||
else
|
||||
|
||||
|
||||
result=`$LOGTAIL ${MAIL_LOG} $STATEFILE \
|
||||
| egrep "postfix\/smtpd?\[[0-9]*\]: ([NOQUA-F]+:|[A-F0-9]+:) " \
|
||||
| grep -v "Server configuration problem" \
|
||||
| grep -v " client=" \
|
||||
| sed -e "s/.*\(Relay access denied\|blocked using\|Helo command rejected\|Client host rejected\|Sender address rejected\|Recipient address rejected\|$POLICY\|queued as\).*/\1/g" \
|
||||
| sort | uniq -c \
|
||||
| sed -e "s/ *\([0-9]\+\) queued as/value.allowed \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Relay access denied/value.relay \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) blocked using/value.rbl \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Helo command rejected/value.helo \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Client host rejected/value.client \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Sender address rejected/value.sender \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) Recipient address rejected/value.recipient \1/" \
|
||||
| sed -e "s/ *\([0-9]\+\) $POLICY/value.policy \1/" `
|
||||
|
||||
fi
|
||||
|
||||
|
||||
(echo $result | sed -e "s/value/\nvalue/g" | sed -e "s/value.allowed/allowed.value/" | grep "allowed" ) || echo "allowed.value 0"
|
||||
(echo $result | sed -e "s/value/\nvalue/g" | sed -e "s/value.rbl/rbl.value/" | grep "rbl" ) || echo "rbl.value 0"
|
||||
|
||||
if [ -z "$POLICY" ]
|
||||
then
|
||||
echo "empty" > /dev/null
|
||||
else
|
||||
(echo $result | sed -e "s/value/\nvalue/g" | sed -e "s/value.policy/policy.value/" | grep "policy" ) || echo "policy.value 0"
|
||||
fi
|
||||
(echo $result | sed -e "s/value/\nvalue/g" | sed -e "s/value.helo/helo.value/" | grep "helo" ) || echo "helo.value 0"
|
||||
(echo $result | sed -e "s/value/\nvalue/g" | sed -e "s/value.client/client.value/" | grep "client" ) || echo "client.value 0"
|
||||
(echo $result | sed -e "s/value/\nvalue/g" | sed -e "s/value.sender/sender.value/" | grep "sender" ) || echo "sender.value 0"
|
||||
(echo $result | sed -e "s/value/\nvalue/g" | sed -e "s/value.recipient/recipient.value/" | grep "recipient" ) || echo "recipient.value 0"
|
||||
(echo $result | sed -e "s/value/\nvalue/g" | sed -e "s/value.relay/relay.value/" | grep "relay" ) || echo "relay.value 0"
|
||||
|
115
plugins/postfix/postfix_filtered_awk
Executable file
115
plugins/postfix/postfix_filtered_awk
Executable file
|
@ -0,0 +1,115 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor incoming Postfix mail.
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional)
|
||||
#
|
||||
|
||||
# requires logtail
|
||||
|
||||
# If you are using a postfix policy daemon (such as policyd) to track certain block conditions, place a line
|
||||
# in your /etc/munin/plugin-conf.d/munin-node like:
|
||||
#
|
||||
# [postfix_filtered]
|
||||
# env.policy my policy string
|
||||
#
|
||||
# When env.policy is set, this plugin will match the string you supply as env.policy and return the number of instances
|
||||
# of that string as an output called "policy.value".
|
||||
#
|
||||
# If you are NOT using a postfix policy daemon, as above, use the line
|
||||
#
|
||||
# [postfix_filtered]
|
||||
# env.policy none
|
||||
#
|
||||
# and this plugin will suppress output of policy.value
|
||||
|
||||
POLICY=''
|
||||
[ "${policy}" = 'none' ] || POLICY="${policy}"
|
||||
export POLICY
|
||||
|
||||
|
||||
|
||||
LOGDIR=${logdir:-/var/log/mail}
|
||||
MAIL_LOG=$LOGDIR/${logfile:-info}
|
||||
LOGTAIL=${logtail:-`which logtail`}
|
||||
STATEFILE=/var/lib/munin/plugin-state/postfix_mailfiltered_test.offset
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Postfix message filtering'
|
||||
|
||||
echo 'graph_category mail'
|
||||
echo 'graph_vlabel Mails per second'
|
||||
# echo 'graph_args --base 1000 --logarithmic'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
|
||||
if [ -z "$POLICY" ]
|
||||
then
|
||||
echo 'graph_order rbl helo client sender recipient relay allowed'
|
||||
|
||||
else
|
||||
echo 'graph_order rbl policy helo client sender recipient relay allowed'
|
||||
echo 'policy.label policy blocked'
|
||||
echo 'policy.min 0'
|
||||
echo 'policy.draw LINE1'
|
||||
echo 'policy.type ABSOLUTE'
|
||||
fi
|
||||
|
||||
|
||||
echo 'allowed.draw LINE2'
|
||||
echo 'allowed.type ABSOLUTE'
|
||||
echo 'allowed.colour 00ff00'
|
||||
echo 'rbl.draw LINE2'
|
||||
echo 'rbl.type ABSOLUTE'
|
||||
echo 'rbl.colour 1010ff'
|
||||
|
||||
for i in helo client sender recipient relay;
|
||||
do
|
||||
echo "$i.min 0"
|
||||
echo "$i.type ABSOLUTE"
|
||||
echo "$i.draw LINE1";
|
||||
done
|
||||
|
||||
echo 'allowed.label allowed'
|
||||
echo 'rbl.label RBL blocked'
|
||||
echo 'helo.label HELO rejected'
|
||||
echo 'client.label Client rejected'
|
||||
echo 'sender.label Sender rejected'
|
||||
echo 'recipient.label recipient unknown'
|
||||
echo 'relay.label relay denied'
|
||||
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
$LOGTAIL ${MAIL_LOG} $STATEFILE | \
|
||||
awk 'BEGIN { na= 0; nb= 0; nc= 0; nd= 0; ne= 0; nf= 0; ng= 0; nh= 0 ; st= ENVIRON["POLICY"] }
|
||||
|
||||
{
|
||||
if (index($0, "queued as")) { na++ }
|
||||
else if (index($0, "Relay access denied")) { nb++ }
|
||||
else if (index($0, "blocked using")) { nc++ }
|
||||
else if (index($0, "Helo command rejected")) { nd++ }
|
||||
else if (index($0, "Client host rejected")) { ne++ }
|
||||
else if (index($0, "Sender address rejected")) { nf++ }
|
||||
else if (index($0, "Recipient address rejected")) { ng++ }
|
||||
else if (st && index($0, st)) { nh++ }
|
||||
}
|
||||
END { print "allowed.value " na"\nrelay.value " nb"\nrbl.value " nc"\nhelo.value " nd"\nclient.value " ne"\nsender.value " nf"\nrecipient.value " ng ; if (st) print "policy.value " nh }'
|
||||
|
||||
|
|
@ -36,10 +36,10 @@ 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'
|
||||
echo 'graph_category mail'
|
||||
echo 'received.label Delivered'
|
||||
echo 'sent.label Outgoing'
|
||||
echo 'rejecthelo.label Invalid HELO'
|
||||
echo 'rejectsenderdomain.label need FQDN'
|
||||
|
@ -49,21 +49,21 @@ if [ "$1" = "config" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
echo -en "recieved.value "
|
||||
echo $(grep "postfix/lmtp\[" $LOGFILE | grep "$DATE" -c)
|
||||
echo -en "received.value "
|
||||
echo $(grep "status=sent (delivered" $LOGFILE | grep "$DATE" | wc -l)
|
||||
echo -n
|
||||
echo -en "sent.value "
|
||||
echo $(grep "postfix/smtp\[" $LOGFILE | grep "$DATE" -c)
|
||||
echo $(grep "status=sent (250" $LOGFILE | grep "$DATE" | wc -l)
|
||||
echo -en "rejecthelo.value "
|
||||
echo $(grep "Helo command rejected: need fully-qualified hostname" $LOGFILE | grep "$DATE" -c)
|
||||
echo $(grep "Helo command rejected: need fully-qualified hostname" $LOGFILE | grep "$DATE" | wc -l)
|
||||
echo -en "rejectsenderdomain.value "
|
||||
echo $(grep "Sender address rejected: Domain not found" $LOGFILE | grep "$DATE" -c)
|
||||
echo $(grep "Sender address rejected: Domain not found" $LOGFILE | grep "$DATE" | wc -l)
|
||||
|
||||
|
||||
echo -en "denyrelay.value "
|
||||
echo $(grep "Relay access denied" $LOGFILE | grep "$DATE" -c)
|
||||
echo $(grep "Relay access denied" $LOGFILE | grep "$DATE" | wc -l)
|
||||
echo -en "spamhaus.value "
|
||||
echo $(grep "blocked using sbl-xbl.spamhaus.org" $LOGFILE | grep "$DATE" -c)
|
||||
echo $(grep "blocked using sbl-xbl.spamhaus.org" $LOGFILE | grep "$DATE" | wc -l)
|
||||
echo -en "spamcop.value "
|
||||
echo $(grep "blocked using bl.spamcop.net" $LOGFILE | grep "$DATE" -c)
|
||||
echo $(grep "blocked using bl.spamcop.net" $LOGFILE | grep "$DATE" | wc -l)
|
||||
|
||||
|
|
69
plugins/postfix/postfix_mail_stats1
Executable file
69
plugins/postfix/postfix_mail_stats1
Executable file
|
@ -0,0 +1,69 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Made by Boudewijn Ector, for Boudewijn Ector IT.
|
||||
# Comments can be sent to (boudewijn<AT>boudewijnector'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 <darac+munin@darac.org.uk>, 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_category postfix'
|
||||
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)
|
||||
|
84
plugins/postfix/postfix_mailfiltered
Executable file
84
plugins/postfix/postfix_mailfiltered
Executable file
|
@ -0,0 +1,84 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor incoming Postfix mail.
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional)
|
||||
#
|
||||
|
||||
|
||||
mktempfile () {
|
||||
mktemp -t
|
||||
}
|
||||
|
||||
MAIL_LOG=${logfile:-/var/log/mail.log}
|
||||
LOGTAIL=${logtail:-`which logtail`}
|
||||
STATEFILE=/var/lib/munin/plugin-state/postfix_mailfiltered.offset
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title Postfix daily filtering'
|
||||
echo 'graph_order relay rbl helo client sender recipient'
|
||||
echo 'graph_category mail'
|
||||
echo 'graph_vlabel Count'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_total total'
|
||||
|
||||
echo 'relay.label Relay denied'
|
||||
echo 'relay.min 1'
|
||||
echo 'rbl.label RBL blocked'
|
||||
echo 'rbl.min 1'
|
||||
echo 'helo.label HELO rejected'
|
||||
echo 'helo.min 1'
|
||||
echo 'client.label Client rejected'
|
||||
echo 'client.min 1'
|
||||
echo 'sender.label Sender rejected'
|
||||
echo 'sender.min 1'
|
||||
echo 'recipient.label Recipient unknown'
|
||||
echo 'recipient.min 1'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
relay=u
|
||||
rbl=U
|
||||
helo=U
|
||||
client=U
|
||||
sender=U
|
||||
recipient=U
|
||||
|
||||
TEMP_FILE=`mktempfile munin-postfix_filtered.XXXXXX`
|
||||
|
||||
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
|
||||
then
|
||||
$LOGTAIL ${MAIL_LOG} $STATEFILE | grep "postfix\/smtpd\[[0-9]*\]: NOQUEUE: reject:" > ${TEMP_FILE}
|
||||
|
||||
relay=`grep 'Relay access denied' ${TEMP_FILE} | wc -l`
|
||||
rbl=`grep 'blocked using' ${TEMP_FILE} | wc -l`
|
||||
helo=`grep 'Helo command rejected' ${TEMP_FILE} | wc -l`
|
||||
client=`grep 'Client host rejected' ${TEMP_FILE} | wc -l`
|
||||
sender=`grep 'Sender address rejected' ${TEMP_FILE} | wc -l`
|
||||
recipient=`grep 'Recipient address rejected' ${TEMP_FILE} | grep -v "Greylisted" | wc -l`
|
||||
|
||||
/bin/rm -f $TEMP_FILE
|
||||
fi
|
||||
|
||||
echo "relay.value ${relay}"
|
||||
echo "rbl.value ${rbl}"
|
||||
echo "helo.value ${helo}"
|
||||
echo "client.value ${client}"
|
||||
echo "sender.value ${sender}"
|
||||
echo "recipient.value ${recipient}"
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ case $1 in
|
|||
echo "graph_title Postfix Mailqueue $CONFIG";
|
||||
cat <<'EOF'
|
||||
graph_vlabel Mails in queue
|
||||
graph_category postfix
|
||||
graph_category mail
|
||||
graph_total Total
|
||||
active.label active
|
||||
deferred.label deferred
|
||||
|
|
|
@ -144,7 +144,7 @@ if ($ARGV[0] and $ARGV[0] eq "config")
|
|||
print "graph_vlabel Mails in Queue log\n";
|
||||
print "graph_scale no\n"; # so we do not print "micro, milli, kilo, etc"
|
||||
# print "graph_total Total\n";
|
||||
print "graph_category postfix\n";
|
||||
print "graph_category mail\n";
|
||||
foreach my $i (@status_list)
|
||||
{
|
||||
if ($descriptions{$i})
|
||||
|
|
136
plugins/postfix/postfix_mailstats
Executable file
136
plugins/postfix/postfix_mailstats
Executable file
|
@ -0,0 +1,136 @@
|
|||
#! /usr/bin/perl
|
||||
|
||||
# Copyright (C) 2008 Joey Schulze <joey@infodrom.org>
|
||||
#
|
||||
# This program 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; version 2 dated June, 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
|
||||
|
||||
# Rewrite of the postfix_mailstats plugin with Munin::Plugin
|
||||
|
||||
# Source: http://www.infodrom.org/Infodrom/tools/munin.html
|
||||
|
||||
# Supported configuration:
|
||||
#
|
||||
# [postfix_mailstats]
|
||||
# user root
|
||||
# group adm
|
||||
# env.logdir /var/log
|
||||
# env.logfile mail.log
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Munin::Plugin;
|
||||
|
||||
my $LOGDIR = $ENV{'logdir'} || '/var/log';
|
||||
my $LOGFILE = $ENV{'logfile'} || 'mail.log';
|
||||
my $logfile = $LOGDIR .'/'. $LOGFILE;
|
||||
|
||||
my $delivered;
|
||||
my %rejects;
|
||||
|
||||
sub autoconf
|
||||
{
|
||||
if (-d $LOGDIR) {
|
||||
if (-f $logfile) {
|
||||
if (open(my $f, $logfile)) {
|
||||
while (<$f>) {
|
||||
if (m,postfix/smtpd\[\d+\]: ,) {
|
||||
close $f;
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
print "no (no smtpd logs in logfile)\n";
|
||||
close $f;
|
||||
} else {
|
||||
print "no (logfile not readable)\n";
|
||||
}
|
||||
} else {
|
||||
print "no (logfile not found)\n";
|
||||
}
|
||||
} else {
|
||||
print "no (could not find logdir)\n";
|
||||
}
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub config
|
||||
{
|
||||
print "graph_title Postfix message throughput\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel mails / \${graph_period}\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_total Total\n";
|
||||
print "graph_category mail\n";
|
||||
print "delivered.label delivered\n";
|
||||
print "delivered.type ABSOLUTE\n";
|
||||
print "delivered.draw AREA\n";
|
||||
print "delivered.min 0\n";
|
||||
foreach my $code (sort keys %rejects) {
|
||||
my $name = clean_fieldname('reject ' . $code);
|
||||
printf "%s.label reject %d\n", $name, $code;
|
||||
printf "%s.type ABSOLUTE\n", $name;
|
||||
printf "%s.draw STACK\n", $name;
|
||||
printf "%s.min 0\n", $name;
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
sub parse
|
||||
{
|
||||
my $logfile = shift;
|
||||
my $pos = shift;
|
||||
|
||||
my ($log,$rotated) = tail_open $logfile, $pos;
|
||||
|
||||
while (<$log>) {
|
||||
if (m,.* postfix/smtpd\[\d+\]: NOQUEUE: reject: [^:]+: (\d+) .*,) {
|
||||
$rejects{$1}++;
|
||||
next;
|
||||
} elsif (m/qmgr.*from=.*size=[0-9]*/) {
|
||||
$delivered++;
|
||||
next;
|
||||
}
|
||||
}
|
||||
return tail_close $log;
|
||||
}
|
||||
|
||||
autoconf if $#ARGV > -1 && $ARGV[0] eq "autoconf";
|
||||
|
||||
my @state_vector = restore_state;
|
||||
my $pos = shift @state_vector || 0;
|
||||
my $time = shift @state_vector;
|
||||
$delivered = shift @state_vector || 0;
|
||||
%rejects = @state_vector;
|
||||
|
||||
config if $#ARGV > -1 && $ARGV[0] eq "config";
|
||||
|
||||
if (defined $time) {
|
||||
if ($time < time-(60*5)+15) {
|
||||
$delivered = 0;
|
||||
$rejects{$_} = 0 foreach keys %rejects;
|
||||
$pos = parse $logfile, $pos;
|
||||
save_state $pos, time, $delivered, %rejects;
|
||||
}
|
||||
} else {
|
||||
# Prevent start peak
|
||||
$pos = (stat $logfile)[7];
|
||||
save_state $pos, time, $delivered;
|
||||
exit 0;
|
||||
}
|
||||
|
||||
printf "delivered.value %d\n", $delivered;
|
||||
foreach my $code (sort keys %rejects) {
|
||||
printf "%s.value %d\n", clean_fieldname('reject ' . $code), $rejects{$code};
|
||||
}
|
|
@ -145,7 +145,7 @@ if ( $ARGV[0] and $ARGV[0] eq "config" )
|
|||
print "graph_vlabel mails / \${graph_period}\n";
|
||||
print "graph_scale no\n";
|
||||
print "graph_total Total\n";
|
||||
print "graph_category postfix\n";
|
||||
print "graph_category mail\n";
|
||||
print "delivered.label delivered\n";
|
||||
print "delivered.type DERIVE\n";
|
||||
print "delivered.draw AREA\n";
|
||||
|
|
|
@ -158,7 +158,7 @@ if ($ARGV[0] and $ARGV[0] eq "config")
|
|||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel bytes / \${graph_period}\n";
|
||||
print "graph_scale yes\n";
|
||||
print "graph_category postfix\n";
|
||||
print "graph_category mail\n";
|
||||
print "graph_total Throughput sum\n";
|
||||
# loop through the postfix names and create per config an entry
|
||||
foreach $syslog_name (@postfix_syslog_name)
|
||||
|
|
135
plugins/postfix/postfix_stats
Executable file
135
plugins/postfix/postfix_stats
Executable file
|
@ -0,0 +1,135 @@
|
|||
#!/bin/sh
|
||||
# -*- sh -*-
|
||||
|
||||
: <<=cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
postfix_stats - Munin plugin to monitor postfix statistics.
|
||||
|
||||
=head1 APPLICABLE SYSTEMS
|
||||
|
||||
Any system where pflogsumm script can be executed.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
There is no default configuration. This is an example config for Ubuntu:
|
||||
|
||||
[postfix_stats]
|
||||
env.logfiles /var/log/syslog /var/log/syslog.1
|
||||
env.pflogsumm pflogsumm
|
||||
|
||||
env.logfiles contains space separated syslog logfiles, usually current log
|
||||
and previous log. You can add more log files if you want, but this may
|
||||
increase the time required for analysis.
|
||||
|
||||
env.pflogsumm The "pflogsumm" script, can be pflogsumm.pl if it was manually
|
||||
downloaded and installed, or "pflogsumm" if it was installed by a package
|
||||
manager (like apt-get).
|
||||
|
||||
=head1 INTERPRETATION
|
||||
|
||||
This plugin displays the messages: received, delivered, rejected...
|
||||
Average per minute is made and it shows the total message count.
|
||||
It is useful to know the load and messages being processed.
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
=head1 VERSION
|
||||
0.2 plugin completely rewritten
|
||||
0.1 first release.
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
None known
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Originally: David Obando (david@cryptix.de)
|
||||
Modified by: github.com/cristiandeluxe
|
||||
Thanks to: sumpfralle
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv2
|
||||
|
||||
=cut
|
||||
|
||||
#set -xv
|
||||
SYS_LOG="${logfiles:-/var/log/syslog /var/log/syslog.0}"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
PFLOGSUMM="${pflogsum}"
|
||||
[ -z "$PFLOGSUMM" ] && PFLOGSUMM="$(which pflogsumm pflogsumm.pl | head -1)"
|
||||
|
||||
# Fields (Array to avoid code duplication) must be space separated
|
||||
FIELDS_ARR="received delivered forwarded deferred bounced rejected held discarded"
|
||||
|
||||
#
|
||||
# Autoconf Section
|
||||
#
|
||||
if [ "$1" = 'autoconf' ]; then
|
||||
# Check if pflogsumm exist
|
||||
if [ -z "${PFLOGSUMM}" ]
|
||||
then
|
||||
echo 'no (pflogsum not found in your system)'
|
||||
else
|
||||
echo 'yes'
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# Config Section
|
||||
#
|
||||
if [ "$1" = 'config' ]; then
|
||||
echo 'graph_title Postfix statistics'
|
||||
echo 'graph_vlabel Postfix statistics'
|
||||
echo 'graph_category mail'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_period minute'
|
||||
echo 'graph_total Total'
|
||||
|
||||
# Generate config for each field
|
||||
for i in $FIELDS_ARR; do
|
||||
echo "${i}.label ${i}"
|
||||
echo "${i}.type DERIVE"
|
||||
echo "${i}.min 0"
|
||||
echo "${i}.draw AREASTACK"
|
||||
done
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# Plugin Script
|
||||
#
|
||||
|
||||
# Variable to store the pflogsumm result.
|
||||
# shellcheck disable=SC2086
|
||||
TMP_RAW=$("${PFLOGSUMM}" -d today --detail 0 --zero-fill ${SYS_LOG})
|
||||
|
||||
# Parse value from Raw result
|
||||
#
|
||||
# Return digit if regex are parsed correctly
|
||||
#
|
||||
# Return U (undefined) if any error occurs
|
||||
#
|
||||
parseValue() {
|
||||
# shellcheck disable=SC2155
|
||||
local TMP_RETURN=$(echo "${TMP_RAW}" | grep -Ei "^[[:space:]]+[[:digit:]]+[[:space:]]+${1}.*$" | grep -oEi '[[:digit:]]+[[:space:]]+' | head -n 1 | sed 's: ::g')
|
||||
if [ -z "${TMP_RETURN}" ]; then
|
||||
echo 'U'
|
||||
else
|
||||
echo "${TMP_RETURN}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Print results
|
||||
for i in $FIELDS_ARR; do
|
||||
printf "%s.value " "${i}"
|
||||
parseValue "${i}"
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue