ApacheTop实现网站实时监测
前天公司老大说叫我要自己去学习有关对服务器对网站实时监测了解的东西,如何去实现。好吧,其实自己也从来没考虑这东西,然而现在工作需要不得不学不了解。充分利用搜索引擎措施,和同事一起找到ApacheTop还有IISTracer来实现对web访问、mtop对mysql数据库操作的监测效果,接下来就稍微介绍下这几款工具吧,想必作为一位网站管理员监测维护管理会有所帮助吧。
As a webmaster, I’ve often wanted to be able to see real-time hits as they arrive. Sure, Google Analytics is a wonderful package for looking at trends over time, but there’s a delay of a few hours there, and you really can’t see data like requests per second or total bytes.
This is where the apachetop utility comes in. It’s a very simple command line utility that you can use to monitor traffic real-time. Itaccomplishes this by parsing the apache logfiles and displaying meaningful output to the screen.
由于公司服务器主要使用的是CentOS 5.1版本的操作系统,所以这里我也只在虚拟机上编译安装测试过。。。
Install ApacheTop On CentOS 5.1 By Opensource:
wget http://www.webta.org/apachetop/apachetop-0.12.6.tar.gz
yum install readline-devel
yum install ncurses-devel
tar xvzf apachetop-0.12.6.tar.gz
cd apachetop-0.12.6
./configure
make
make install
使用方法:
一般使用方法:
引用# apachetop -f /var/log/httpd.access
下面是用法说明:
引用ApacheTop v0.12.6 – Usage:File options:
-f logfile open logfile (assumed common/combined) [/var/log/httpd-access.log]
(repeat option for more than one source)
URL/host/referrer munging options:
-q 保持请求字符串[no]
-l 所有的url小写[no]-s num 保持url路径段数量 [all]
-p 在referrer前面保留协议 [no]
-r 保留每一个的主机/ip [no]
Stats options:
必须提供两个参数 default: [-T 30]缺省设置为保持记录状态30秒,30秒后数据刷新了。
为了提供更多的信息给我们分析,我们可以调节下面的参数。
-H hits 保持状态只到多少点击数
-T secs 保持状态只到多少秒
-d secs 刷新延迟时间[5]
-h 这个帮助。
当执行之后,还有命令可以切换显示状态:
引用ApacheTop version 0.12.6, Copyright (c) 2003-2004, Chris Elsworth
ONE-TOUCH COMMANDS
d : 切换urls/referrers/hosts显示模式开关
n : 切换hits & bytes或返回代码开关
h or ? : 帮助信息
p : (un)暂停显示 (冻结更新)
q : 退出 ApacheTop
up/down : 移动星标 up/down
right/left : 进入/退出逐条显示模式
子菜单:
s: 排序: [the appropriate menu will appear for your display]
r) requests R) reqs/sec b) bytes B) bytes/sec
2) 2xx 3) 3xx 4) 4xx 5) 5xx
t: 固定显示 ON/OFF:
u) urls r) referrers h) hosts
f: 使用过滤器:
a) add/edit menu c) clear all s) show active (not done yet)
a: ADD FILTER SUBMENU
u) to urls r) to referrers h) to hosts

