diff --git a/plugins/mail/postfix_stats b/plugins/mail/postfix_stats index 7a2bcd5b..f0690c96 100755 --- a/plugins/mail/postfix_stats +++ b/plugins/mail/postfix_stats @@ -3,6 +3,15 @@ # Plugin to show Postfix statistics - needs pflogsumm # # Contributed by David Obando (david@cryptix.de) - 16.04.2007 +# Rewrited by Cristian Deluxe (me@cristiandeluxe.com) - 02.11.2016 +# +# +# Example config for Ubuntu (You need: apt-get install pflogsumm) +# +# [postfix_stats] +# env.logfile /var/log/syslog +# env.logfile2 /var/log/syslog.1 +# env.pflogsumm pflogsumm # # # Magic markers - optional - used by installation scripts and @@ -12,41 +21,89 @@ #%# capabilities=autoconf #set -xv +SYS_LOG=${logfile:-/var/log/syslog} +SYS_LOG2=${logfile2:-/var/log/syslog.0} +PFLOGSUMM=${pflogsumm:-pflogsumm.pl} -case $1 in - config) - cat <<'EOF' -system.type COUNTER -graph_title Postfix statistics -graph_vlabel Postfix statistics -graph_category Mail -graph_total Total -received.label received -delivered.label delivered -forwarded.label forwarded -deferred.label deferred -bounced.label bounced -rejected.label rejected -held.label held -discarded.label discarded -EOF - exit 0;; -esac +# +# Autoconf Section +# +if [ "$1" = "autoconf" ]; then + # Try to find pflogsumm with default name + PFLOG_EXIST=$(command -v pflogsumm.pl) + # Try to find pflogsumm without any extension + if [[ -z "${PFLOG_EXIST}" ]] + then + PFLOG_EXIST=$(command -v pflogsumm) + fi -TMP=`mktemp /tmp/tmp.XXXXXXXX` -pflogsumm.pl --smtpd_stats -d today /var/log/syslog /var/log/syslog.0 | head -n 15 > $TMP + if [[ -z "${PFLOG_EXIST}" ]] + then + echo "no"; + else + echo "yes" + fi + exit 0; +fi -cat <