Search

Blogroll

Meta:

Daily sendmail stats on Linux server

August 20th, 2007 by vicky

I always wanted to see mail stats on my server, who receives and sends the most mails, what are the busiest hours, etc.. to better track mail problems, catch spammers and to satisfy my admin’s ego ;-) . I found this little script that goes through senmail’s log and produces output. In my case I will send the output to root via email.

Here are the features that I receive from this little script:

SendmailStats reports:

  • Time/date of log beginning and end
  • Total bytes transferred and total MB transferred
  • Total bytes in and total MB in (locally delivered)
  • Number of messages sent out
  • Number of messages coming in
  • Messages per hour graph
  • Top 20 remote sending hosts
  • Total number of sending hosts and number of their attempted messages
  • Top 20 destination hosts
  • Total number of destination hosts and number of messages sent to them
  • Top 20 local deliveries
  • Total number of local accounts that received mail
  • Total number of messages delivered locally
  • Top 20 senders
  • Total number of senders and total number of messages sent

These are the steps that need to be done to make it work:

wget http://www.reedmedia.net/software/sendmail_stats/sendmail_stats-0.9.txt
mv sendmail_stats-0.9.txt /root/sendmailstats
chmod 755 /root/sendmailstats
vi /root/sendmailstats

edit dit the “$default_hostname = ‘EDIT-THIS-default-domain.net’;” line matching your hostname

vi /etc/cron.daily/smailstats

into the file paste this line:

/root/sendmailstats < /var/log/maillog | less | mail -s “sendmail stats” root

Save the file & close it.

chmod 755 /etc/cron.daily/smailstats

And you are finished. The script will run every day when is your daily cron set and you receive email with the stats.

Die spam! :-)



Posted in General linux admin | Comments Off

Comments are closed.