Postfix 輔助工具

郵件流量分析

Mailgraph is a very simple mail statistics RRDtool frontend for Postfix that produces daily, weekly, monthly and yearly graphs of received/sent and bounced/rejected mail

mailgraph homepage:http://people.ee.ethz.ch/~dws/software/mailgraph/

他的開發者 David Schweikert:http://people.ee.ethz.ch/~dws/人還廷爽 :-)

mailgraph 安裝與配置

  1. 安裝rrdtool,Tail模組

    [root@linuxas3 src]# wget http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/rrdtool-1.0.49.tar.gz
    --12:35:11--  http://people.ee.ethz.ch/%7Eoetiker/webtools/rrdtool/pub/rrdtool-1.0.49.tar.gz
               => `rrdtool-1.0.49.tar.gz'
    Resolving people.ee.ethz.ch... done.
    Connecting to people.ee.ethz.ch[129.132.2.204]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1,466,897 [application/x-tar]
    
    100%[==================================================================================>] 1,466,897     18.93K/s    ETA 00:00
    
    12:36:34 (18.93 KB/s) - `rrdtool-1.0.49.tar.gz' saved [1466897/1466897]
    
    [root@linuxas3 src]# tar rrdtool-1.0.49.tar.gz
    ...
    ...
    [root@linuxas3 src]# cd rrdtool-1.0.49
    [root@linuxas3 rrdtool-1.0.49]# sh configure
    [root@linuxas3 rrdtool-1.0.49]# make
    [root@linuxas3 rrdtool-1.0.49]# make install
    [root@linuxas3 rrdtool-1.0.49]# make site-perl-install
    [root@linuxas3 rrdtool-1.0.49]# cd ..
    
    [root@linuxas3 src]# cpan
    cpan> install Time::HiRes
    cpan> install File::Tail
    cpan> exit
    			
  2. 下載安裝 mailgraph

    [root@linuxas3 src]# wget http://people.ee.ethz.ch/~dws/software/mailgraph/pub/mailgraph-1.9.tar.gz
    --11:55:20--  http://people.ee.ethz.ch/%7Edws/software/mailgraph/pub/mailgraph-1.9.tar.gz
               => `mailgraph-1.9.tar.gz'
    Resolving people.ee.ethz.ch... done.
    Connecting to people.ee.ethz.ch[129.132.2.204]:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 18,375 [application/x-tar]
    
    100%[========================================================>] 18,375        17.64K/s    ETA 00:00
    
    11:55:31 (17.64 KB/s) - `mailgraph-1.9.tar.gz' saved [18375/18375]
    
    [root@linuxas3 src]# tar zxvf mailgraph-1.9.tar.gz
    mailgraph-1.9/
    mailgraph-1.9/mailgraph.pl
    mailgraph-1.9/mailgraph.cgi
    mailgraph-1.9/mailgraph-init
    mailgraph-1.9/README
    mailgraph-1.9/COPYING
    mailgraph-1.9/CHANGES
    [root@linuxas3 src]#
    [root@linuxas3 src]# cd mailgraph-1.9
    [root@linuxas3 mailgraph-1.9]#
    [root@linuxas3 mailgraph-1.9]# mkdir ~netkiller/mailgraph
    [root@linuxas3 mailgraph-1.9]# cp mailgraph.cgi /home/netkiller/mailgraph
    [root@linuxas3 mailgraph-1.9]# chmod 755 -R ~netkiller/mailgraph/
    [root@linuxas3 mailgraph-1.9]# chown postfix.postfix -R ~netkiller/mailgraph/
    
    [root@linuxas3 mailgraph-1.9]# cp mailgraph.pl /usr/local/bin/
    [root@linuxas3 mailgraph-1.9]# cp mailgraph-init /etc/init.d/
    [root@linuxas3 mailgraph-1.9]# chmod 755 /etc/init.d/mailgraph-init
    [root@linuxas3 mailgraph-1.9]# cd /var/log
    [root@linuxas3 log]# ln -s  maillog syslog
    [root@linuxas3 log]# cd -
    [root@linuxas3 mailgraph-1.9]# vi /etc/init.d/mailgraph-init
    #RRD_DIR=/var/lib
    RRD_DIR=/home/netkiller/mailgraph #mailgraph.cgi的安裝目錄即cgi-bin目錄
    
    [root@linuxas3 mailgraph-1.9]# /etc/init.d/mailgraph-init start
    Starting mail statistics grapher: mailgraph
    [root@linuxas3 mailgraph-1.9]# ps ax|grep mailgraph
    30400 ?        S      0:00 /usr/bin/perl -w /usr/local/bin/mailgraph.pl -l /var/log/syslog -d --daemon_pid=/var/run/mailgraph.pid --daemon_rrd=/var/lib
    30408 pts/2    S      0:00 grep mailgraph
    [root@linuxas3 mailgraph-1.9]#
    			
  3. 配置Apache VirtualHost

    [root@linuxas3 mailgraph-1.9]# vi /etc/httpd/conf/httpd.conf
    <VirtualHost 202.105.113.174>
    ServerAdmin openunix@163.com
    DocumentRoot /home/netkiller/web
    ServerName www.9812.net
    # SuexecUserGroup netkiller netkiller
    ErrorLog /home/netkiller/logs/netkiller-error_log
    CustomLog /home/netkiller/logs/netkiller-access_log common
    ScriptAlias /mailgraph/ "/home/netkiller/mailgraph/"
    </VirtualHost>
    [root@linuxas3 mailgraph-1.9]# service httpd reload
    Reloading httpd:                                           [  OK  ]
    [root@linuxas3 mailgraph-1.9]#
    
    			
  4. 測試

    http://www.9812.net/mailgraph/mailgraph.cgi