安裝 awstats postfix on centos
- Category: 電腦相關
- Last Updated: Sunday, 25 March 2012 00:52
- Published: Saturday, 24 March 2012 20:14
- Written by sam
使用 AWStats 來作 Postfix 的監控流量
- wget http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpm
--2012-03-24 12:15:17-- http://prdownloads.sourceforge.net/awstats/awstats-7.0-1.noarch.rpm
正在查找主機 prdownloads.sourceforge.net... 216.34.181.59
正在連接 prdownloads.sourceforge.net|216.34.181.59|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 301 Moved Permanently
位置: http://downloads.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0-1 .noarch.rpm [跟隨至新的 URL]
--2012-03-24 12:15:18-- http://downloads.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0-1.noarch.rpm
正在查找主機 downloads.sourceforge.net... 216.34.181.59
繼續使用和 prdownloads.sourceforge.net:80 的連線。
已送出 HTTP 要求,正在等候回應... 302 Found
位置: http://nchc.dl.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0-1.noarch.rpm [跟隨至新的 URL]
--2012-03-24 12:15:19-- http://nchc.dl.sourceforge.net/project/awstats/AWStats/7.0/awstats-7.0-1.noarch.rpm
正在查找主機 nchc.dl.sourceforge.net... 211.79.60.17, 2001:e10:ffff:1f02::17
正在連接 nchc.dl.sourceforge.net|211.79.60.17|:80... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 1263821 (1.2M) [application/octet-stream]
Saving to: `awstats-7.0-1.noarch.rpm'
100%[======================================>] 1,263,821 1.41M/s in 0.9s
2012-03-24 12:15:20 (1.41 MB/s) -- 已儲存 ‘awstats-7.0-1.noarch.rpm’ [1263821/1263821])
- [root@myla tmp]# rpm -ivh awstats-7.0-1.noarch.rpm
正在準備… ########################################### [100%]
1:awstats ########################################### [100%]
1:awstats ########################################### [100%]
----- AWStats 7.0 - Laurent Destailleur -----
AWStats files have been installed in /usr/local/awstats
AWStats files have been installed in /usr/local/awstats
If first install, follow instructions in documentation
(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:
Step 1 : Install and Setup with awstats_configure.pl (or manually)
Step 2 : Build/Update Statistics with awstats.pl
Step 3 : Read Statistics
(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:
Step 1 : Install and Setup with awstats_configure.pl (or manually)
Step 2 : Build/Update Statistics with awstats.pl
Step 3 : Read Statistics
- 以上就安裝完畢 再來是設定部份
cp /etc/awstats/awstats.model.conf awstats.XXX.conf
XXX 替換為你要的名稱
vi awstats.XXX.conf
照著 官網 提示 修改以下項目
LogFile="perl /path/to/maillogconvert.pl standard < /pathtomaillog/maillog |" perl後面的路徑接上maillogconvert.pl程式 將maillog格式轉為 awstats認得的格式 正常沒改的話 postfix log 在 /var/log/maillog
maillogconvert.pl LogType=M
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
LevelForBrowsersDetection=0
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForWormsDetection=0
LevelForSearchEnginesDetection=0
LevelForFileTypesDetection=0
ShowMenu=1
ShowSummary=HB
ShowMonthStats=HB
ShowDaysOfMonthStats=HB
ShowDaysOfWeekStats=HB
ShowHoursStats=HB
ShowDomainsStats=0
ShowHostsStats=HBL
ShowAuthenticatedUsers=0
ShowRobotsStats=0
ShowEMailSenders=HBML
ShowEMailReceivers=HBML
ShowSessionsStats=0
ShowPagesStats=0
ShowFileTypesStats=0
ShowFileSizesStats=0
ShowBrowsersStats=0
ShowOSStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowSMTPErrorsStats=1
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForWormsDetection=0
LevelForSearchEnginesDetection=0
LevelForFileTypesDetection=0
ShowMenu=1
ShowSummary=HB
ShowMonthStats=HB
ShowDaysOfMonthStats=HB
ShowDaysOfWeekStats=HB
ShowHoursStats=HB
ShowDomainsStats=0
ShowHostsStats=HBL
ShowAuthenticatedUsers=0
ShowRobotsStats=0
ShowEMailSenders=HBML
ShowEMailReceivers=HBML
ShowSessionsStats=0
ShowPagesStats=0
ShowFileTypesStats=0
ShowFileSizesStats=0
ShowBrowsersStats=0
ShowOSStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowSMTPErrorsStats=1
- 執行
[root@myla cgi-bin]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=XXX -update
一樣XXX 替換為剛剛取的名稱 執行畫面如下
Create/Update database for config "/etc/awstats/awstats.postfix.conf" by AWStats version 7.0 (build 1.971)
From data in log file "perl /etc/awstats/maillogconvert.pl standard < /var/log/maillog |"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Jumped lines in file: 0
Parsed lines in file: 38
Found 0 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 38 old records,
Found 0 new qualified records.
- 檢視成果
在 http://你的ip或網域名/cgi-bin/awstats/awstats.pl?config=XXX 請記得替換為你的設定
再來就是使用cron來定時執行即可!!!