设为首页 收藏本站
查看: 1613|回复: 0

[经验分享] Windows下使用awstats6.5来分析Tomcat5.x的网站访问日志

[复制链接]

尚未签到

发表于 2015-11-27 15:12:11 | 显示全部楼层 |阅读模式
1.安装perl,下载地址:
http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.6.811-MSWin32-x86-122208.msi
http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
b.运行安装程序,安装到d:/perl,其余使用默认值,安装完成即可。
2.让Tomcat支持cgi.(只需要第一步)
1. 把servlets-cgi.renametojar (在CATALINA_HOME/server/lib/目录下)改名为servlets-cgi.jar。处理CGI的servlet应该位于Tomcat的CLASSPATH下。
3.按照http://www.pchighway.com/helpdesk/index.php?page=index_v2&id=1675&c=2
或者http://www.turro.org/Portal?xpc=1$@8$@1$@1&folder=20050104154634840
下载那个http://www.pchighway.com/helpdesk/awstats.war
解压到D:/jakarta-tomcat-5.5.7/webapps.
先把D:/jakarta-tomcat-5.5.7/webapps/awstats/WEB-INF/cgi-bin下的awstats.model.conf命名为common.conf,
接着建立新文件,awstats.localhost.conf内容
Include "common.conf"
LogFile="d:/tomcat5.0/webapps/awstats/WEB-INF/tools/logresolvemerge.pl d:/tomcat5.0/logs/ana.log"
SiteDomain="localhost"
HostAliases="localhost"
DefaultFile="index.html"
DirData="d:/tomcat5.0/logs/"
启动Tomcat,通过
http://localhost:8080/awstats/cgi-bin/awstats.pl?config=localhost&update=1
就可以生成日志分析结果了。
相关参考资源:
http://www.chedong.com/tech/awstats.html
http://www.chedong.com/cgi-bin/awstats/awstats.pl?config=chedong
http://www.chedong.com/tech/search_engines.pm
http://awstats.sourceforge.net/
  
DSC0000.gif

Changing Tomcat access logs format
  Tomcat access logs format isn't exactly what we need. We could also have modified AWStats configuration files, but with the loss of important information. Thus, let's make Tomcat logs compatible with AWStats. Logs are configured in [Tomcat_install]/conf/server.xml. They might look something like:
  <Valve className=&quot;org.apache.catalina.valves.AccessLogValve&quot; directory=&quot;logs&quot; prefix=&quot;localhost_access_log.&quot; suffix=&quot;.txt&quot; pattern=&quot;common&quot; resolveHosts=&quot;false&quot;/>
  

Normally this lines are commented. Just take in mind they should appear, uncommented, within your Host definition.  
  We will replace the valve definition with this one:
  <Valve className=&quot;org.apache.catalina.valves.AccessLogValve&quot; directory=&quot;logs&quot; prefix=&quot;www_mydomain_com_access_log.&quot; suffix=&quot;.log&quot; pattern=&quot;combined&quot; fileDateFormat=&quot;dd-MM-yy&quot; resolveHosts=&quot;false&quot;/>

Enable Perl scripts
  Tomcat has disabled by default CGI executions. This is because CGIs do not conform Tomcat security box. But we know exactly what we are going to do, aren't we  ?
  The only thing you need to do is renaming [Tomcat_install]/server/lib/servlets-cgi.renametojar to [Tomcat_install]/server/lib/servlets-cgi.jar. This will enable AWStats Perl scripts to execute on Tomcat server. When it's done, restart Tomcat.
  

There is something more done through awstats.war file's web.xml. You might want to look at this file once downloaded.  

Install AWStats
  AWStats is included in awstats.war file, therefore you will not need to install AWStats by hand.
  Deploy awstats.war file. Will suffice copying this file into [Tomca_install]/webapps folder, but in case your Tomcat is configured not to auto-deploy war files, unzip it yourself. By default would create an [Tomca_install]/webapps/awstats folder.
  

Although you could change default context, isn't a good idea. At least not to start with. Better make it work and then think about changing things.  

Configure AWStats
  This is the hardest part, did you already take a coffe?  
  First we will make some assumptions, are these ones:


  • awstats.war was deployed into /awstats default context. See Install AWStats.
  • Our domain is www.mydomain.com.
  Now, go to [Tomca_install]/webapps/awstats/WEB-INF/cgi-bin folder. Next instructions make the assumption this is your current working folder.


  • Copy awstats.model.conf into awstats.www.mydomain.com.conf.
  • Edit awstats.www.mydomain.com.conf.
  You can use any text editor of your preference. Now, we will change some file default values. You must look for the attributes and change their values as shown below:

LogFile=&quot;[TI]/webapps/awstats/WEB-INF/tools/logresolvemerge.pl [TI]/logs/*.log |&quot;
LogType=W
LogFormat=1
LogSeparator=&quot; &quot;
SiteDomain=&quot;www.mydomain.com&quot;
DNSLookup=1
DirData=&quot;.&quot;
DirCgi=&quot;/cgi-bin&quot;
DirIcons=&quot;/awstats/icon&quot;
  

Remember replacing [TI] with full path to Tomcat. And www.mydomain.com with your domain name.  

Update site statistics.
  Here you have two choices:


  • Set AllowToUpdateStatsFromBrowser=1 in awstats.www.mydomain.com.conf file, see above. This will allow updating from the web browser with: http://www.mydomain.com/awstats/cgi-bin/awstats.pl?config=www.mydomain.com&update=1.
  • Using Telnet or SSH, go to [Tomca_install]/webapps/awstats/WEB-INF/cgi-bin folder and run perl awstats.pl -config=www.mydomain.com -update.

View site statistics.
  Type http://www.mydomain.com/awstats/cgi-bin/awstats.pl?config=www.mydomain.com. That was all.

Creating separated domain statistics.
  From the instructions above, everything is valid for creating separated domain statistics, except for one thing:
  Inside your awstats.www.mydomain.com.conf we said:
  LogFile=&quot;[TI]/webapps/awstats/WEB-INF/tools/logresolvemerge.pl [TI]/logs/*.log |&quot;
  This line was gathering the whole set of log files, and this is against having statistics appart for each domain. We should replace this line to match the log files for the corresponding domain, as we said when changing Tomcat access logs format:
  LogFile=&quot;[TI]/webapps/awstats/WEB-INF/tools/logresolvemerge.pl [TI]/logs/www_mydomain_com*.log |&quot;
  Important! Don't omit the asterisk in pointing the log files. Take in mind that Tomcat will create an access log file for each day, and that final file's name will include the date.
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-144195-1-1.html 上篇帖子: awstats导入旧日志 下篇帖子: win7下日志分析工具awstats的搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表