How can I install pflogsumm for Postfix mail log analyzer?

5,851

to install pflogsumm in your Ubuntu, open your terminal with CTRL+ALT+T and type as

sudo apt-get install pflogsumm 

Configuration:

We want pflogsumm to be run by a cron job each day and send the report to [email protected]. Therefore we must configure our system that it writes one mail log file for 24 hours, and afterwards starts the next mail log so that we can feed the old mail log to pflogsumm. Therefore we configure logrotate (that's the program that rotates our system's log files) like this: open /etc/logrotate.conf and append the following stanza to it, after the line # system-specific logs may be configured here:

in terminal do as

sudo -i

nano /etc/logrotate.conf 

then

/var/log/mail.log {
    missingok
    daily
    rotate 7
    create
    compress
    start 0
}

There's a logrotate script in /etc/cron.daily. This script is called everyday between 06:00h and 07:00h. With the configuration we just made, it will copy the current Postfix log /var/log/mail.log to /var/log/mail.log.0 and compress it, and the compressed file will be /var/log/mail.log.0.gz. It will also create a new, empty /var/log/mail.log to which Postfix can log for the next 24 hours.

Now we create the script /usr/local/sbin/postfix_report.sh which invokes pflogsumm and makes it send the report to [email protected]:

nano /usr/local/sbin/postfix_report.sh

script as

#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
gunzip /var/log/mail.log.0.gz

pflogsumm /var/log/mail.log.0 | formail -c -I"Subject: Mail Statistics" -I"From: pflogsumm@localhost" -I"To: [email protected]" -I"Received: from www.example.com ([192.168.0.100])" | sendmail [email protected]

gzip /var/log/mail.log.0
exit 0 

We must make this script executable:

chmod 755 /usr/local/sbin/postfix_report.sh

Then we create a cron job which calls the script everyday at 07:00h:

crontab -e

then

 0 7 * * * /usr/local/sbin/postfix_report.sh &> /dev/null

This will send the report to [email protected]. It looks like this in an email client:

enter image description here

For more information & must read : click here

Share:
5,851

Related videos on Youtube

Ferdous Mahmud
Author by

Ferdous Mahmud

Having over 5 years of extensive IT experience in various aspects of software application analysis, design, development and maintenance i would like to be a part of team where my silks could be utilized to the fullest. We are engaged in providing best SEO, SMO, SMM Services to our clients. these services bought a unique change in the field of Internet Marketing industry. These services help in selecting and specifying the exact target audience and in knowing their psychology for online marketing, Search Engine Optimization, Viral Marketing and Word of Mouth Marketing. Aim of these services is to attract large volume of internet viewers for a specific website. Owing to our expertise and impressive strategy, we have been able to offer effective and timely services to our clients. Service Description Online Marketing Services like Search Engine Optimization, Social Media Marketing, Search Engine Marketing, Social Media Optimization and more web Promotion Services. SEO (Search Engine Optimization) • Evaluation & Planning • Execution • SEO Implementation • Completion • Monitoring SMM (Social Media Marketing) • Consulting and Decision Making • Blog Development and Design • Social Media Account Set Up • Twitter/Facebook/Linkedin/Google Plus Campaign

Updated on September 18, 2022

Comments

  • Ferdous Mahmud
    Ferdous Mahmud almost 2 years

    I am useing Postfix mail server in Ubuntu 13.04. I want to install pflogsumm in my server and analyze the mail log. How can I do this?