分析请求时间以查找慢速页面

我正在寻找一个很大的自定义PHP CMS网站缓慢的页面。

我不想在现有糟糕的没有logging的代码中发现,发现Apache访问日志可以显示服务请求的时间,以秒和毫秒为单位。

CONF:

CustomLog /var/log/httpd/timed_access_log timed LogFormat "%h %l %u %t \"%r\" %>s %b - %T/%D" timed 

输出:

 86.132.***.*** - - [22/Jun/2010:13:25:31 +0100] "GET /menu/topscript/ HTTP/1.1" 200 183 - 0/12418 86.132.***.*** - - [22/Jun/2010:13:25:31 +0100] "GET /search/script/ HTTP/1.1" 200 266 - 0/13173 86.132.***.*** - - [22/Jun/2010:13:25:31 +0100] "GET /subscribe/script/ HTTP/1.1" 200 279 - 0/12882 

有没有简单的方法来find最高的平均缓慢的要求?

对分析程序感兴趣,比如awstats或awk脚本(我从来没有得到过我的头)。

相关: AWStats和时间服务请求

我的最终解决scheme,基于半径的答案:

 awk '{cnt[$7]+=substr($12,1+match($12,"/")); i[$7]+=1}END{for (x in cnt){if (i[x] > 5) print x,i[x],cnt[x]/i[x]}}' timed_access_log | sort -k3nr | head -20 

只计算至less有5个请求,通过降低平均时间对它们进行sorting,并返回前20个。

你可以试试这个,我希望它能起作用,如果你给我们一些样本日志文件,我可以检查它是否

 awk '{cnt[$7]+=substr($12,1+match($12,"/")); i[$7]+=1}END{for (x in cnt){print x,cnt[x]/i[x]}}' access_log