postfix-stats/grapher.sh

50 lines
1.9 KiB
Bash
Raw Normal View History

2018-05-03 19:58:08 +02:00
#!/bin/bash
# Go into appropriate directory
cd `dirname $0`
# Load settings
. ./settings.sh
2018-05-04 15:34:50 +02:00
period_filenames=("hour.png" "6hours.png" "day.png" "week.png" "month.png" "6months.png" "year.png")
period_startparams=("end-1h" "end-6h" "end-24h" "end-7d" "end-1m" "end-6m" "end-1y")
period_texts=("Last hour" "Last 6 hours" "Last day" "Last week" "Last month" "Last 6 months" "Last year")
for index in ${!period_filenames[*]}; do
filename=${period_filenames[$index]}
startparam=${period_startparams[$index]}
text=${period_texts[$index]}
# Draw the graphs
# Outbound mail
rrdtool graph $GRAPHDIR/$filename \
--start $startparam \
--step 60 \
--title "Mail statistics for `hostname -f` - $text" \
--vertical-label "mails/minute" \
-h 200 -w 800 --slope-mode \
DEF:mo_sent=$RRDFILE:mo_sent:AVERAGE \
DEF:mo_deferred=$RRDFILE:mo_deferred:AVERAGE \
DEF:mo_bounced_total=$RRDFILE:mo_bounced_total:AVERAGE \
DEF:mo_bounced_spam=$RRDFILE:mo_bounced_spam:AVERAGE \
DEF:mo_bounced_reputation=$RRDFILE:mo_bounced_reputation:AVERAGE \
DEF:mo_deliverable=$RRDFILE:mo_deliverable:AVERAGE \
DEF:mo_undeliverable=$RRDFILE:mo_undeliverable:AVERAGE \
AREA:mo_deferred#77777733 \
LINE:mo_deferred#777777:'deferred' \
AREA:mo_sent#00DD0055 \
LINE:mo_sent#00DD00:'sent' \
AREA:mo_deliverable#00AA0077 \
LINE:mo_deliverable#00AA00:'deliverable' \
AREA:mo_undeliverable#AA880077 \
LINE:mo_undeliverable#AA8800:'undeliverable' \
AREA:mo_bounced_total#0000FF77 \
LINE:mo_bounced_total#0000FF:'bounced total' \
AREA:mo_bounced_spam#FF0000AA \
LINE:mo_bounced_spam#FF0000:'bounced due to SPAM' \
AREA:mo_bounced_reputation#FF00FFFF \
LINE:mo_bounced_reputation#FF00FFFF:'reputation event'
done