html监控服务器状态,如何监视Apache Web服务器加载和页面统计信息

正如我们在前面的Apache系列教程承诺,今天我们在这里与Apache HTTP Web服务器,它可以使系统管理员的生活更容易使用mod_status的模块来处理Apache Web服务器的负载上的另一篇文章。

什么是mod_status?

mod_status的是一个Apache模块,有助于监视Web服务器的负载电流的httpd连接与HTML接口,可通过Web浏览器访问。

Apache的mod_status显示一个纯HTML页面,其中包含有关Web服务器状态的当前统计信息的信息。

传入请求的总数

总字节数和计数服务器

Web服务器的CPU使用率

服务器加载

服务器正常运行时间

总流量

空闲工作人员总数

PID与相应的客户端和更多。

默认的Apache Project将其服务器统计信息页面启用给公众。要有演示繁忙的网站的状态页面,请访问。

测试环境

我们使用以下测试环境对本文探讨有关使用一些实际的例子和屏幕截图mod_status的多。

操作系统 -的CentOS 6.5

应用 -的Apache Web服务器

IP地址 - 5.175.142.66

DocumentRoot - /var/www/html

Apache配置文件 - /etc/httpd/conf/httpd.conf中(红帽)

默认HTTP端口 - 80 TCP

测试配置设置 -的httpd -t

本教程的先决条件是,你应该已经知道如何安装和配置基本的Apache服务器 。如果您不知道如何设置Apache,请阅读以下可能有助于您设置自己的Apache Web服务器的文章。

如何启用Apache中的mod_status

默认的Apache安装带有启用mod_status模块 。如果没有,请确保在Apache配置文件中启用它。

[root@howtoing ~]# vi /etc/httpd/conf/httpd.conf

搜索“mod_status的 ”单词或直到找到包含线不断向下滚动。

#LoadModule status_module modules/mod_status.so

如果你在“的LoadModule”的开头看到一个“#”字符,这意味着mod_status的是禁用的。 删除'#'来启用mod_status模块。

LoadModule status_module modules/mod_status.so

配置mod_status

现在再次搜索单词“ 位置 ”或向下滚动,直到你找到它mod_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.

#

#

# SetHandler server-status

# Order deny,allow

# Deny from all

# Allow from .example.com

#

在上面的部分,根据您的需求为注释Location指令 ,SetHandler和目录限制线。 例如,我使用简单的订单允许 , 拒绝和它允许所有 。

SetHandler server-status

Order allow,deny

Deny from all

Allow from all

注 :以上配置是默认的Apache网站(一个网站)的默认配置。 如果你已经创建一个或多个Apache的虚拟主机 ,上面的配置将不会起作用。

因此,基本上,您需要为您在Apache中配置的任何域定义每个虚拟主机的相同配置。例如,mod_status的虚拟主机配置如下所示。

ServerAdmin howtoing@example.com

DocumentRoot /var/www/html/example.com

ServerName example.com

ErrorLog logs/example.com-error_log

CustomLog logs/example.com-access_log common

SetHandler server-status

Order allow,deny

Deny from all

Allow from example.com

启用ExtendedStatus

在“ExtendedStatus”设置添加到统计页面了解更多信息,CPU占用率 , 每秒的要求 , 总流量等。要启用它,编辑同一httpd.conf文件并搜索单词“ 扩展 ”,并取消对行并置“ 开 ”ExtendedStatus指令。

# 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

重新启动Apache

现在请确保您已正确启用和配置Apache服务器状态页。您还可以检查使用以下命令在httpd.conf配置错误。

[root@howtoing ~]# httpd -t

Syntax OK

有一次,你得到的语法是OK,你可以能够重新启动httpd服务。

[root@howtoing ~]# service httpd restart

Stopping httpd: [ OK ]

Starting httpd: [ OK ]

访问mod_status页

Apache的状态页将通过您的域名为“/ 服务器状态 ”在以下网址的访问。

http://serveripaddress/server-status

OR

http://serev-hostname/server-status

你会看到类似与ExtendedStatus以下页面启用了一些东西。

1a86d4571cb27c16e2412256925d2328.png

Apache mod_status视图

在上面的快照,你可以看到一个HTML界面,显示有关服务器正常运行的所有信息, 进程ID与其各自的客户端 ,网页,他们试图访问。

它还显示了用于显示状态的所有缩写的含义和用法,这有助于我们更好地理解情况。

您也可以刷新页面每次秒(比如5秒 ),以查看更新的统计数据。 要设置自动化更新,请加“? 刷新= N”的网址的结尾。 其中N可以用秒数来代替您希望您的网页得到刷新。

http://serveripaddress/server-status/?refresh=5

ae673b7d5ec473cfac159b3507986666.png

Apache mod_status刷新

命令行状态页面视图

您还可以使用特殊的命令行浏览器称为命令行界面查看Apache的状态页的链接或猞猁 。 你可以使用默认的包,如下图所示叫做Yum管理器实用程序安装它们。

# yum install links

OR

# yum install lynx

一旦你安装了,你可以通过使用以下命令在终端上获得相同的统计信息。

[root@howtoing ~]# links http://serveripaddress/server-status

OR

[root@howtoing ~]# lynx http://serveripaddress/server-status

OR

[root@howtoing ~]# /etc/init.d/httpd fullstatus

示例输出

Apache Server Status for localhost

Server Version: Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3

Server Built: Aug 13 2013 17:29:28

--------------------------------------------------------------------------

Current Time: Tuesday, 14-Jan-2014 04:34:13 EST

Restart Time: Tuesday, 14-Jan-2014 00:33:05 EST

Parent Server Generation: 0

Server uptime: 4 hours 1 minute 7 seconds

Total accesses: 2748 - Total Traffic: 9.6 MB

CPU Usage: u.9 s1.06 cu0 cs0 - .0135% CPU load

.19 requests/sec - 695 B/second - 3658 B/request

1 requests currently being processed, 4 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-0 - 0/0/428 . 0.30 5572 0 0.0 0.00 1.34 127.0.0.1 5.175.142.66 OPTIONS * HTTP/1.0

GET

1-0 5606 0/639/639 _ 0.46 4 0 0.0 2.18 2.18 115.113.134.14 5.175.142.66 /server-status?refresh=5

HTTP/1.1

GET

2-0 5607 0/603/603 _ 0.43 0 0 0.0 2.09 2.09 115.113.134.14 5.175.142.66 /server-status?refresh=5

HTTP/1.1

3-0 - 0/0/337 . 0.23 5573 0 0.0 0.00 1.09 127.0.0.1 5.175.142.66 OPTIONS * HTTP/1.0

GET

4-0 5701 0/317/317 _ 0.23 9 0 0.0 1.21 1.21 115.113.134.14 5.175.142.66 /server-status?refresh=5

HTTP/1.1

GET

5-0 5708 0/212/213 _ 0.15 6 0 0.0 0.85 0.85 115.113.134.14 5.175.142.66 /server-status?refresh=5

HTTP/1.1

6-0 5709 0/210/210 W 0.16 0 0 0.0 0.84 0.84 127.0.0.1 5.175.142.66 GET /server-status

HTTP/1.1

7-0 - 0/0/1 . 0.00 5574 0 0.0 0.00 0.00 127.0.0.1 5.175.142.66 OPTIONS * HTTP/1.0

--------------------------------------------------------------------------

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

--------------------------------------------------------------------------

Apache/2.2.15 (CentOS) Server at localhost Port 80

结论

Apache的mod_status的模块是一个Web服务器的活动进行监控的表现非常方便的监控工具,可以能够突出问题本身。有关更多信息,请阅读可帮助您成为更成功的Web服务器管理员的状态页面。

mod_status的现在,我们就来了,在以后的教程一些技巧和提示在Apache。 直到再留怪异和调整,以Howtoing.com不要忘记添加您的宝贵意见。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值