Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1380540
  • 博文数量: 77
  • 博客积分: 2104
  • 博客等级: 大尉
  • 技术积分: 2322
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-19 13:21
个人简介

关注于系统高可用、网站架构

文章分类

全部博文(77)

文章存档

2018年(1)

2017年(1)

2015年(4)

2014年(8)

2013年(4)

2012年(12)

2011年(17)

2010年(30)

分类: 系统运维

2010-08-24 11:30:01

系统运行中,需要了解用户访问哪个页面比较多,耗时比较长。给优化提供参考
运行比较慢的往往是动态文件,本次我们集中在action页面,考虑到action 的url后面有不同的id值(前面都是一样的),我们需要做个url截断。
 
下面是分析代码的shell文件,前10位访问最多的
#!/bin/sh
>action.tmp
cat access.log|awk '{print $7}'|grep action| while read Line
       do
                svn_path=${Line%%\?*}
                 echo $svn_path>>action.tmp
        done
cat action.tmp|sort|uniq -c|sort -nr|head -n 10
 
line=${line%%\?*}截断line字符串,去掉?号后面的字符串(包括?),并把结果赋值给变量line
 
 
另外响应时间也是要关注的
需要在nginx里做配置,增加request_time项
 
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '"$status" $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" $request_time';
 
统计一分钟产生的流量
grep showTbMatchData.do huabao.taotaosou.net.log |grep "2012:17:01"|awk '{ print $10 }'|sort -n|awk '{sum+=$1}END{print sum}'
得出的结果*8/60 就是平均每秒的实际占用带宽
 
 
阅读(2834) | 评论(0) | 转发(0) |
0

上一篇:heartbeat安装

下一篇:xen 在线安装

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