WEB服务(九)网页形式监测apache服务器运行状态(转)
apache服务中加载mod_status.c模块可把web服务的一些信息统计出来,并制作成网页。只要网络管理员浏览设置好的网页网址就可以访问并了解到网站的相关信息。 这些相关的信息包括:服务器的版本、服务器系统的当前时间、服务器最后一次启动时间、访问服务器的数目、目前为止传输的总位数、每秒平均请求数及cpu,还有apache的负载情况,虚拟机和当前处理的请求列表等。。。 一、要实现这种功能首先让
·
apache
服务中加载
mod_status.c
模块可把
web
服务的一些信息统计出来,并制作成网页。只要网络管理员浏览设置好的网页网址就可以访问并了解到网站的相关信息。
这些相关的信息包括:服务器的版本、服务器系统的当前时间、服务器最后一次启动时间、访问服务器的数目、目前为止传输的总位数、每秒平均请求数及
cpu
,还有
apache
的负载情况,虚拟机和当前处理的请求列表等。。。
#
# 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 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。
#
# 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>
# 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 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: Apache
Server Built: Mar 27 2010 13:52:45
-
Current Time: Monday, 28-Mar-2011 15:31:57 CST
Restart Time: Monday, 28-Mar-2011 15:31:51 CST
Parent Server Generation: 3
Server uptime: 6 seconds
Total accesses: 0 - Total Traffic: 0 kB
CPU Usage: u0 s0 cu0 cs0
0 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
Srv | PID | Acc | M | CPU | SS | Req | Conn | Child | Slot | Client | VHost | Request |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0-3 | 5689 | 0/0/0 | W | 0.00 | 0 | 77573377 | 0.0 | 0.00 | 0.00 | 192.168.1.140 | xcs.xj.webdev | GET /server-status HTTP/1.1 |
Srv | Child Server number - generation |
---|---|
PID | OS process ID |
Acc | Number of accesses this connection / this child / this slot |
M | Mode of operation |
CPU | CPU usage, number of seconds |
SS | Seconds since beginning of most recent request |
Req | Milliseconds required to process most recent request |
Conn | Kilobytes transferred this connection |
Child | Megabytes transferred this child |
Slot | Total megabytes transferred this slot |
以上图中可以看出已经访问成功。
更多推荐
已为社区贡献2条内容
所有评论(0)