Chinaunix首页 | 论坛 | 博客
  • 博客访问: 90388
  • 博文数量: 33
  • 博客积分: 1088
  • 博客等级: 少尉
  • 技术积分: 365
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-30 13:59
文章分类

全部博文(33)

文章存档

2011年(18)

2010年(9)

2009年(6)

分类: LINUX

2010-02-19 00:09:20

Awstats分析Suid日志配置办法

         Awstatssquid日志的分析采用的是将日志传送到日志服务器,并对日志进行集中分析,被分析的日志内容包括squidapachenginx日志。

1、  squid日志配置

squid日志需配置日志格式,在/etc/squid3/squid.conf中定义日志格式combined

logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %h" "%{User-Agent}>h" %Ss:%Sh %{host}>h

配置由syslog监听日志,这里采用的是sysloglocal5

access_log syslog:local5 combined

如在本地保留日志,可以单独配置:

emulate_httpd_log on                 #使用apache格式记录日志

access_log /var/log/squid3/access.log

重启动squid服务:

 /etc/init.d/squid3 reload

2、  配置本地的syslog

编辑/etc/rsyslog.conf,配置对讲local5传送到远程服务器192.168.0.8

local5.*     @192.168.0.8

重启动syslog服务:

/etc/init.d/rsyslog restart

3、  Awstats服务器日志配置

配置允许从远程接收数据,修改/etc/default/syslogd

SYSLOGD="-r"

配置接收远程数据的位置,修改/etc/syslog.conf

local5.* /opt/awstats/apache_log/access_

4、  配置Awstats对日志进行分析:

LogFile="/opt/awstats/apache_log/access_"      #日志文件位置

LogType=W                                                                                                                                                                                                                            #分析的日志为web格式

LogFormat = "%other %other %other %other %other %other %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %other %virtualname" #日志格式

SiteDomain=                                                                                  #默认域名

HostAliases="gonline.com 127.0.0.1 localhost REGEX[.*\.gonline\.com$]"                                                                     #alias域名

DNSLookup=2                                                                                                                  #dns读取数据

DirData="/opt/awstats/data"                                                                                   #保存分析后的数据

DirCgi="/awstats"                                                                                                         #apache中配置的cgi名称

 

         其它部分采用默认即可。

         配置自动执行awstats,在crontab加入:

                   30 * * * * /root/scripts/apache_awstats.sh                    

         脚本内容:

                   #!/bin/bash

slogfile=/opt/awstats/apache_log/access_

dlogfile=/opt/awstats/apache_log/d_access_

cat=/bin/cat

awk=/usr/bin/awk

mv=/bin/mv

rm=/bin/rm

awstats=/opt/awstats/wwwroot/cgi-bin/awstats.pl

h=`date +%H`

d=`date -d'1 day ago' -I`

od=`date -d'30 days ago' -I`

 

#$cat $slogfile |$awk -F'(squid):' '{print $2}'|sed -e 's#^ ##g' >> $dlogfile && $cat /dev/null > $slogfile

$awstats -update -config=

 

[ $h -eq 0 ] && $mv $dlogfile $dlogfile.$d

[ -f $dlogfile.$od ] && $rm $dlogfile.$od

5、   

阅读(788) | 评论(0) | 转发(0) |
0

上一篇:nginx的防盗链

下一篇:root下crontab不执行

给主人留下些什么吧!~~