Exim relay daily stats – bash

#!/bin/bash
ESEND=$(egrep "(=>|->)" /var/log/exim4/mainlog.1 -c)
YDATE=$(date -d "1 day ago" '+%Y-%m-%d')
echo
echo -== Report for $YDATE ==-
echo
echo Total emails send by SMTP relay on $HOSTNAME:
echo
egrep "(=>|->)" /var/log/exim4/mainlog.1 | gawk '{ print $5 }'| sort | uniq -c | sort -nr
echo
echo Total: $ESEND
echo

output:

/root/exim-stats.sh

-== Report for 2016-02-28 ==-

Total emails send by SMTP relay on some.hostname:

20 someone@example.com
10 someone_else@email.com
1 sales@domain.com

Total: 31

Advertisements