Add new comment

Want to support HowtoForge? Become a subscriber!
Submitted by gumicsoves (registered user) on Mon, 2007-12-10 02:26.

Hi,

Thanks for the article it was a very good starting point for me and I'd also like to contribute with my two comments:

- pflogsumm is capable of sending reports for yesterday and today so there's no need to change the rotation of the mail log files. You can just simply execute:

cat /var/log/mail.log.0 /var/log/mail.log | pflogsumm -d yesterday --problems_first

This is going to give you statistics for yesterday.

I personally created a file in /etc/cron.daily/ with this content:

#!/bin/sh
echo -e "From: root@example.com\nSubject: Daily Mail Statistics on `hostname --fqdn`\nTo: <postmaster@example.com>\n\n`cat /var/log/mail.log.0 /var/log/mail.log | pflogsumm -d yesterday --problems_first`\n\n\n\n`cat /var/log/mail.log.0 /var/log/mail.log | pflogsumm -d today --mailq --problems_first`\n"|sendmail -t
exit 0

This gives me statistics for yesterday 0-24 and also for today 0-6:47 am and also lists the content of the queues.

- If for some reason this was not working for you than it is very important to use the right tool for the log rotation. /var/log/mail* files are rotated by a script which comes with the sysklogd package. In your solution /var/log/mail.log is rotated twice, once by the sysklogd script on Sunday and once every day at 6:25. Which will result in a strange situation and you have only 4 days of history, because the sysklogd keeps only 4 versions.

So you can either disable the weekly rotation and use the rotation you described or do it the "proper way". I'm saying proper because the sysklogd rotation is doing other things as well. 

You need to edit two files in order to change the default (weekly rotation with 4 weeks of history) behavior. Add mail to the daily rotation script:

/etc/cron.daily/sysklogd

Add these lines: (-c 14 means keep 14 days of history)

# Non default logrotate for mail logs
for LOG in `syslogd-listfiles -a | grep mail`
do
  if [ -s $LOG ]; then
    savelog -g adm -m 640 -u root -c 14 $LOG >/dev/null
  fi
done

Disable mail logs in the weekly rotation file:

/etc/cron.weekly/sysklogd

modify this line: 

for LOG in `syslogd-listfiles --weekly`

to look like this: 

for LOG in `syslogd-listfiles --weekly -s mail`


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.

Reply

*
*
The content of this field is kept private and will not be shown publicly.


*

  • Images can be added to this post.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <div>
  • Lines and paragraphs break automatically.