E-Mail Notifications

I chose postfix as an MTA, as mentioned above. I bound it only to the loopback-interface, so it doesn't listen on any physical network interface. I deactivated logrotation, and a shellscript greps the times and ip-addresses of connections, and sends it to the SA-department. Then I do the logrotation myself, with the few files that I really want to rotate.

My script looks like this:

#!/bin/bash

# report and rotate logs

echo "From: VPN-Master <root@company.net>" > \ 

/tmp/daily_report

echo "To: admin@company.net" >> \

/tmp/daily_report

echo "Subject: VPN Connections - Daily report"\

>> /tmp/daily_report

grep l2tpd /var/log/messages | grep established \

| grep Call | awk '{print ($1 " "  $2 "\

" $3 " " $10)}' | sed 's/,//' >> \

/tmp/daily_report

grep Call | cut -d ' ' -f 1-3,10 | sed 's/,//'\ 

>> /tmp/daily_report

/usr/sbin/sendmail admin@company.net < /tmp/daily_report

Logrotation (in this example only for one file, just to get the idea) is done by:

ln /var/log/messages /var/log/messages.0

rm /var/log/messages

killall -HUP syslogd



Wolfgang Hennerbichler 2004-12-21