您的位置:首页 > 运维架构 > Apache

WEB服务(九)网页形式监测apache服务器运行状态(转)

2011-03-28 15:38 711 查看
apache服务中加载mod_status.c模块可把web服务的一些信息统计出来,并制作成网页。只要网络管理员浏览设置好的网页网址就可以访问并了解到网站的相关信息。

这些相关的信息包括:服务器的版本、服务器系统的当前时间、服务器最后一次启动时间、访问服务器的数目、目前为止传输的总位数、每秒平均请求数及cpu,还有apache的负载情况,虚拟机和当前处理的请求列表等。。。

一、要实现这种功能首先让我们来配置一下apache的主配置文件httpd.conf。在配置文件的第191到201行左右,这一部分定义设置开启web服务器的状态信息。如下所示:

#
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
#ExtendedStatus On

以上部分为代开状态信息,请把#ExtendedStatus On语句前的‘#’去掉,变成ExtendedStatus On。

二、从配置文件的第930到939行左右,如下所示内容:

#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status # Change the ".example.com" to match your domain to enable.
#
#<Location /server-status>
# SetHandler server-status
# Order deny,allow
# Deny from all
# Allow from .example.com
#</Location>

将<Location /server-status>到</Location>部分的所有‘#’注视去掉,然后将Allow from .example.com一句中的‘.example.com’更改为自己用来访问客户端的主机的ip地址或所在的域名。最好将<Location /server-status>中的 ‘server-status’改成自己定义的名字。

举例说明:

#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status # Change the ".example.com" to match your domain to enable.
#
<Location /xudeqiang>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 192.168.1.140(说明:192.168.1.140是我访问apache服务器的客户机ip。Allow from 192.168.1.140的意思是说允许来自192.168.1.140的访问,类似于客户端控制列表)
</Location>

三、查看服务器信息

看服务器状态信息时,在浏览器中输入http://web 服务器的名字/server-status(如果 /server-status已经更改为自己定义的名字,这里就要使用自己定义的名字访问),例如按照上面的举例说明中的配置,我要查看服务器状态就要在浏览器中输入http://http://xcs.xj.webdev/server-status(注意:在浏览器中如何的ip地址不是客户端的了,而是服务器的。)
如下图所示:

Apache Server Status for xcs.xj.webdev

Server Version: ApacheServer Built: Mar 27 2010 13:52:45

Current Time: Monday, 28-Mar-2011 15:31:57 CSTRestart Time: Monday, 28-Mar-2011 15:31:51 CSTParent Server Generation: 3Server uptime: 6 secondsTotal accesses: 0 - Total Traffic: 0 kBCPU Usage: u0 s0 cu0 cs00 requests/sec - 0 B/second -1 requests currently being processed, 7 idle workers
W_______........................................................
................................................................
................................................................
................................................................

Scoreboard Key:
"
_
" Waiting for Connection, "
S
" Starting up, "
R
" Reading Request,
"
W
" Sending Reply, "
K
" Keepalive (read), "
D
" DNS Lookup,
"
C
" Closing connection, "
L
" Logging, "
G
" Gracefully finishing,
"
I
" Idle cleanup of worker, "
.
" Open slot with no current process

SrvPIDAccMCPUSSReqConnChildSlotClientVHostRequest
0-356890/0/0W0.000775733770.00.000.00192.168.1.140xcs.xj.webdevGET /server-status HTTP/1.1
SrvChild Server number - generation
PIDOS process ID
AccNumber of accesses this connection / this child / this slot
MMode of operation
CPUCPU usage, number of seconds
SSSeconds since beginning of most recent request
ReqMilliseconds required to process most recent request
ConnKilobytes transferred this connection
ChildMegabytes transferred this child
SlotTotal megabytes transferred this slot

以上图中可以看出已经访问成功。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: