免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6212 | 回复: 3

[Mail] AWStats分析postfix日志(这个文章很详细所以转过来) [复制链接]

论坛徽章:
0
发表于 2008-04-01 08:57 |显示全部楼层
【前言】
AWStats是一套免費及功能強大的Log分析軟體,它可以透過CGI及Command line的方式來產生報表。

它支援了以下的Log格式

(1)Apache-combined log(XLF/ELF)
(2)Apache or Squid-common log(CLF)
(3)IIS 5.0/6.0-W3C log
(4)大部份的Web/Wap/Proxy/Streaming Servers(Apache 1.3.x and 2.x, IIS 5.0 and 6.0, WebStar, WebLogic, WebSite, Windows Media Server, Tomcat, Squid, Sambar,Roxen, Resin, RealMedia server, Oracle9iAS, Lotus Notes/Domino, Darwin, IPlanet, IceCast, ZeroBrand, Zeus, Zope,
Abyss..)
(5)FTP Server(ProFTP...)
(6)Mail Server(Postfix/Sendmail/QMail/Mdaemon/www4mail...)


支援平台

(1)Windows 2000/NT4/Me、Linux、Macintosh、Solaris、Aix、BeOS、FreeBSD
(2)ActivePerl 5.6/5.8、Perl 5.6/5.8


=========================================
作者: zoob (vincent@myunix.idv.tw)

版權聲明:可以任意轉載,轉載時請務必標明原始出處和作者資訊

【安裝AWStats】

(1)請先從官方網址 ( http://awstats.sourceforge.net/ ) 下載AWStats ( http://prdownloads.sourceforge.net/awstats/awstats-6.1.tgz )

(2)解壓縮 awstats-6.1.tgz

(3)將解壓縮出來的 tools 及 wwwroot 目錄複製到 /usr/local/awstats 目錄下

(4)切換目錄至 /usr/local/awstats 目錄

(5)執行 tools 目錄下的 configure.pl

代碼:
tools/configure.pl


(6)設定config檔
----- AWStats configure 1.0 (build 1.32) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).

-----> Running OS detected: Linux, BSD or Unix

-----> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf <-----輸入httpd.conf的絕對路徑

-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
AWStats directives already present.

-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ?y

-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.myunix.idv.tw <-------- 輸入你所要建立的WebSite name

-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=wwww.myunix.idv.tw
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...

A SIMPLE config file has been created: /etc/awstats/awstats.wwww.myunix.idv.tw.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'wwww.myunix.idv.tw' with command:
> perl awstats.pl -update -config=wwww.myunix.idv.tw
You can also read your statistics for 'wwww.myunix.idv.tw' with URL:
> http://localhost/awstats/awstats.pl?config=wwww.myunix.idv.tw

Press ENTER to finish...

(7)以上步驟完成後,會在/etc/awstats目錄下建立一檔案- awstats.www.myunix.idv.tw.conf

(建立 /var/lib/awstats 目錄,並給予 777 之權限
註:若不給予777權限,將來若設定 AllowToUpdateStatsFromBrowser=1 時,會無法透過Browser來即時更新Report

(9)設定 httpd.conf,檢查在httpd.conf中是否有以下設定,如果沒有的話,請自行加入,並且重新啟動httpd服務

代碼:
#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path "/usr/local/awstats/" must reflect your AWStats install path.
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory> 【分析 Mail Log-Postfix/Sendmail/Qmail/MDaemon】
適用於:Postfix/Sendmail/Qmail/MDaemon

(1)設定awstats.mail.myunix.idv.tw.conf

代碼:
LogFile="perl /usr/local/awstats/tools/maillogconvert.pl standard < /var/log/maillog |"  <----請指定你mail log file的絕對路徑及log名稱
LogType=M <---- M代表分析類型為mail log files
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
SiteDomain="mail.myunix.idv.tw" <----指定定從log檔中過濾符合SiteDomain的記錄
HostAliases="myunix.idv.tw mail.myunix.idv.tw localhost 127.0.0.1" <-----指定哪些Domain或ip address為Local,其餘皆視為External
LevelForBrowsersDetection=0
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForWormsDetection=0
LevelForSearchEnginesDetection=0
LevelForFileTypesDetection=0
ShowMenu=1
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



設定完畢,請存檔

(2)執行awstats.pl,記得指定設定檔時,不要輸入設定檔名前面的 awstats. 及 .conf

代碼:
[root@xxx awstats]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=mail.myunix.idv.tw -update


如果出現以下訊息,就代表執行成功


Update for config "/etc/awstats/awstats.mail.myunix.idv.tw.conf"
With data in log file "perl /usr/local/awstats/tools/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: 358
Found 0 dropped records,
Found 0 corrupted records,
Found 358 old records,
Found 0 new qualified records.


(3)開啟Browser,輸入 http://www.xxx.xxx/awstats/awstats.pl?config=mail.myunix.idv.tw ,便可檢視你剛剛所產生的報表了。

Demo Site

(4)記得將步驟(2)的指令設定在crontab,讓它定期產生Log Report

论坛徽章:
0
发表于 2008-04-03 15:13 |显示全部楼层
很好的东西为什么没人顶呢?

论坛徽章:
0
发表于 2008-09-08 10:06 |显示全部楼层
好文,马上测试下。。。

论坛徽章:
8
综合交流区版块每周发帖之星
日期:2015-12-02 15:03:53数据库技术版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每日发帖之星
日期:2015-09-14 06:20:00金牛座
日期:2014-10-10 11:23:34CU十二周年纪念徽章
日期:2013-10-24 15:41:34酉鸡
日期:2013-10-19 10:17:1315-16赛季CBA联赛之北京
日期:2017-03-06 15:12:44
发表于 2008-09-08 10:57 |显示全部楼层
AWStats非常不错
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP