使用awstats统计分析tengine日志访问量及各种http网站数据
下载awstats最新安装包并解压
cd /usr/local/src
wget http://www.awstats.org/files/awstats-7.3.tar.gz tar -zxvf awstats-7.3.tar.gz
把awstats解压目录更名及把需要用到的pl文件提高到可执行权限、创建需要用到的文件夹:
mv awstats-7.3 awstats mv awstats /usr/local/ chmod +x /usr/local/awstats/tools/awstats_configure.pl chmod +x /usr/local/awstats/wwwroot/cgi-bin/awstats.pl chmod +x /usr/local/awstats/tools/awstats_buildstaticpages.pl # 这里是用来存放 AWStats 的数据库文件的
mkdir /var/lib/awstats
新建 awstats 配置文件(运行前查看perl版本是否安装)
perl /usr/local/awstats/tools/awstats_configure.pl
-----> 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):
#> none #因为我们这里用的是 Nginx,所以写 none,跳过。
回车
Your web server config file(s) could not be found.
You will need to setup your web server manually to declare AWStats
script as a CGI, if you want to build reports dynamically.
See AWStats setup documentation (file docs/index.html) -----> 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 #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.moabc.net #统计网站的域名
回车
-----> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
#>
使用默认直接回车,接下来便会出现以下的提示
----> 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=www.moabc.net
#回头把该命令填入crontab 按指定时间执行
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.www.moabc.net.conf
#新配置文件所在的路径
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'www.moabc.net' with command:
> perl awstats.pl -update -config=www.moabc.net
You can also build static report pages for 'www.moabc.net' with command:
> perl awstats.pl -output=pagetype -config=www.moabc.net Press ENTER to finish...
回车完成向导,接下来修改 www.moabc.net 的统计配置
vi /etc/awstats/awstats.www.moabc.net.conf
找到统计的日志文件的路径
LogFile="/var/log/httpd/mylog.log"
改为
LogFile="/usr/local/tengine/logs/access_%YYYY-0%MM-0%DD-0.log
对应上边 Nginx 日志切割程序的所生成的目录存放结构,要注意 Awstats 的年月日格式的跟 Nginx 的写法有所不同。我们现在执行统计的顺序是:
Nginx 产生日志 –> 日志切割 –> Nginx 继续产生日志 –> 另存切割日志 –> 交由Awstats统计 –> 生成结果
在本文中 Awstats 所统计的日志,是已切下来的那部分。也能调转顺序,先统计完了再切。不过这比较容易造成统计的遗漏。配置修改完成后,保存退出。然后我们可以开始试一下手动执行。
创建切割日志脚本:
vi /usr/local/tengine/sbin/log_cut.sh #!/bin/bash
# 这里根据你自己的文件名来写 mv /usr/local/tengine/logs/access.log /usr/local/tengine/logs/access_$(date -d "today" +"%Y%m%d").log #这里时tengine的pid存放目录
kill -USR1 `cat /usr/local/tengine/logs/nginx.pid`
保存
设置可执行权限:
chmod +x /usr/local/tengine/sbin/log_cut.sh
可以试一下运行:
/usr/local/tengine/sbin/log_cut.sh
新建要生成 HTML 报告的目录,把图片和CSS复制进去:
mkdir -p /usr/local/tengine/html/awstats/ cp -R /usr/local/awstats/wwwroot/css /usr/local/tengine/html/awstats/ cp -R /usr/local/awstats/wwwroot/icon /usr/local/tengine/html/awstats/
生成 awstats 数据库:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.moabc.net #这里 -config=www.moabc.net 意思是说使用 /etc/awstats/awstats.www.moabc.net.conf 这个文件
生成 AWStats 日志分析报告
/usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.moabc.net -lang=cn -dir=/usr/local/tengine/html/awstats/ awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
配置tengine页面访问认证
通过使用apache的创建认证文件工具创建
htpasswd -c /usr/local/tengine/sbin/pd mike
如果没用可以用网上的认证工具生成验证账户和密码(如:http://www.4webhelp.net/us/password.php)
vi /usr/local/tengine/sbin/pd mike:79y.NuPCo1CqU
保存
再tengine配置文件server主机中添加http访问增加一下代码:
location /awstats {
charset gbk;
access_log off;
root /usr/local/tengine/html;
index index.html index.htm;
auth_basic "awstats login";
auth_basic_user_file /usr/local/tengine/sbin/pd;
}
location /icon {
charset gbk;
access_log off;
root /usr/local/tengine/html/awstats;
index index.html index.htm;
}
至此浏览器打开可以看到分析结果页面了
接下来配置分析日志定时任务
crontab -e * * - /bin/bash /usr/local/tengine/sbin/log_cut.sh
* * - /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.moabc.net -lang=cn -dir=/usr/local/tengine/html/awstats/ awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
设置成了每天晚上11点执行切割tengine日志,每天网上11点30分执行更新awstats分析日志生成静态分析日志结果html文档到目录。
awstats中文关键字乱码
修改awstats的配置文件
在使用centos/redhat系统的rpm包安装的awstats的配置路径为/etc/awstats下。打开所要统计网站的配置文件awstats.xxxxx.conf,将下面一行的#去掉:
LoadPlugin="decodeutfkeys"
不过打开这个plugin 需要perl模块儿Encode和URI::Escape的支持,一般情况下perl是默认支持的。
如果打开AWStats会显示:
Error: Plugin load for plugin 'decodeutfkeys' failed with return code: Error: Can't locate URI/Escape.pm in @INC (@INC contains: /usr/lib/perl5/5.8.7/i686-linux /usr/lib/perl5/5.8.7 /usr/lib/perl5/site_perl/5.8.7/i686-linux /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl . ./lib ./plugins) at (eval 4) line 1.
這是因為缺少 Perl 的 URI:Escape模块
下载安装URI:Escape模块:
cd /usr/local/src wget http://www.cpan.org/authors/id/G/GA/GAAS/URI-1.60.tar.gz tar -zxvf URI-1.60.tar.gz cd URI-1.60 perl Makefile.PL make make install
然后再更新下awstats重新更新tengine日志
/usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www.moabc.net -lang=cn -dir=/usr/local/tengine/html/awstats/ awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl
刷新下页面关键字乱码就正常了。
完毕。
使用awstats统计分析tengine日志访问量及各种http网站数据的更多相关文章
- 烂泥:利用awstats分析nginx日志
本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb 昨天把nginx的日志进行了切割,关于如何切割nginx日志,可以查看<烂泥:切割 ...
- linux服务器上nginx日志访问量统计命令
linux服务器上nginx日志访问量统计命令 日志文件所在地方:/var/log/nginx/access_iqueendress.com.log/var/log/nginx/access_m.iq ...
- 使用awstats分析nginx日志
1.awstats介绍 本文主要是记录centos6.5下安装配置awstats,并统计nginx访问日志 1.1 awstats介绍 awstats是一款日志统计工具,它使用Perl语言编写,可统计 ...
- tengine日志切割-配置分钟级别日志自动切割
tengine日志切割-配置分钟级别日志自动切割 安装 以安装最新版本的tengine-2.1.2版本 下载连接 tengine支持许多变量 变量 $conn_requests 当前请求在长连接上的序 ...
- 【慕课网实战】八、以慕课网日志分析为例 进入大数据 Spark SQL 的世界
用户行为日志:用户每次访问网站时所有的行为数据(访问.浏览.搜索.点击...) 用户行为轨迹.流量日志 日志数据内容: 1)访问的系统属性: 操作系统.浏览器等等 2)访问特征:点击的ur ...
- 如何使用 Python 统计分析 access 日志?
一.前言 性能场景中的业务模型建立是性能测试工作中非常重要的一部分.而在我们真实的项目中,业务模型跟线上的业务模型不一样的情况实在是太多了.原因可能多种多样,这些原因大大降低了性能测试的价值. 今天的 ...
- Awstats分析Nginx日志
1.nginx日志格式设定 log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$ ...
- Nginx配置Awstats分析Nginx日志笔记
1.修改Nginx日志格式: log_format json '$remote_addr - $remote_user [$time_local] "$request" ' ...
- lograte切割tengine日志
记录 /srv/logs/nginx/*log { create 0644 nobody nobody daily rotate 10 missingok notifempty compress sh ...
随机推荐
- UVA 297 Quadtrees(四叉树建树、合并与遍历)
<span style="font-size: 18pt; font-family: Arial, Helvetica, sans-serif; background-color: r ...
- sql server和my sql 命令(语句)的差别,sql server与mysql的比較
sql与mysql的比較 1.连接字符串 sql :Initial Catalog(database)=x; --数据库名称 Data Source(source)=x; ...
- 单片机IO口驱动能力
以STM32的IO口为例,最大的输出电流和灌入电流在芯片手册上都有说明.单个IO口一般都是十几mA到几十mA,同时总的VDD电流也有限制,大概为150mA.所以单片机驱动外设时,如果不是信号型而是功率 ...
- nodejs保存文件的问题
从前端到那里jar包失败: 保存到本地管理机jar包md5sum上传正确的值md5sum值不相等.并上传 处理 没有错误,说明保存过程中的错误: 前面是base64然后转码后jar包内容放进reque ...
- EditText操作收集
1.android EditText插入字符串到光标所在位置 EditText mTextInput=(EditText)findViewById(R.id.input);//EditText对象 i ...
- MySQLdb安装和使用2
http://blog.chinaunix.net/uid-8487640-id-3183185.html MySQLdb是Python连接MySQL的模块,下面介绍一下源码方式安装MySQLdb: ...
- Android 指定日期时间执行任务的Timer
放上一个指定详细日期及时间的timer public class MainActivity extends Activity { private Handler handler = new Handl ...
- PLSQL Developer操作
1.设置 1)下载32位Oracle InstantClient 2)将Oracle InstantClient解压到某目录 3)设置环境变量(修改NLS_LANG和TNS_ADMIN环境变量)对 ...
- ANDROID 通过监听来电去电,并弹出悬浮窗
要监听android打电话和接电话,有一种的是通过新建一个Receiver继承自BroadcastReceiver. 还有一种也可通过PhoneStateListener来实现.今天就说说后面一种,废 ...
- java反射的应用+mybatis+spring动态生成数据库表
最近接触了一个类似于代码生成工具的活.思路是,通过java的反射机制得到类的字段和字段类型, 从而可以创建一个map集合存储表名(由类名决定的特殊结构字符串),表字段(由类变量确定),表字段类型(由变 ...