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

 

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: 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

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

以上图中可以看出已经访问成功。 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值