如何开启apachectl status的server-status辅助分析工具

Apache Server Status主机状态查看 - 禅达的爱 - 博客园
10月30日,国外安全研究人员发现由于对apache设置不严,导致服务器状态暴露于公网。本来apache有一个叫server-status 的功能,为方便管理员检查服务器运行状态的。它是一个HTML页面,可以显示正在工作的进程数量,每个请求的状态,访问网站的客户端ip地址,正在被请求 的页面。
但是如果这个页面对公网开放,就会存在一些安全隐患,例如任何人口可以看到谁在访问网站,甚至包括一些本来隐藏的管理页面。
如果没有加载这个模块,如果您是linux服务器,那么就需要您重新编译apache了,编译的时候加上参数--enable-module=so即可, 如果你是windows系统的话,无需任何编译,只要把刚才时候说的LoadModule status_module modules/mod_status.so这句加上,如果前面有带#号,开启的话,需要将#去除。
http://192.168.99.99/Server-status?refresh=N将表示访问状态页面可以每N秒自动刷新一次;
在httpd.conf 增加
#-Apache Server Status--------------
ExtendedStatus On
&Location /Server-status&
SetHandler Server-status
Order deny,allow
Deny from all
Allow from 192.168.99.99
&/Location&
##--Apache Server Status--end---------
Deny from表示禁止的访问地址,如果访问报错可将此行注释,但是安全性会降低;
Allow from表示允许的地址访问。这里应该写允许的客户端IP,似乎不应该是域名
ExtendedStatus On表示的是待会访问的时候能看到详细的请求信息,另外该设置仅能用于全局设置,不能在特定的虚拟主机中打开或关闭。启用扩展状态信息将会导致服务器运行效率降低。
http://192.168.99.99/Server-status
默认为查看第一个虚拟主机的信息。。。
Apache Server Status for
Server Version: Apache
Server Built: Apr 4 :54
Current Time: Friday, 30-Jul-:01 CST
Restart Time: Friday, 30-Jul-:38 CST
Parent Server Generation: 0
Server uptime: 23 seconds
Total accesses: 1 - Total Traffic: 1 kB
CPU Usage: u0 s0 cu0 cs0
.0435 requests/sec - 44 B/second - 1024 B/request
1 requests currently being processed, 9 idle workers
Scoreboard Key:
" Waiting for Connection, "
" Starting up, "
" Reading Request,
" Sending Reply, "
" Keepalive (read), "
" DNS Lookup,
" Closing connection, "
" Logging, "
" Gracefully finishing,
" Idle cleanup of worker, "
" Open slot with no current process
114.92.*.222
GET /SEC HTTP/1.1
114.92.*.222
GET /Server-status HTTP/1.1
Child Server number - generation
OS process ID
Number of accesses this connection / this child / this slot
Mode of operation
CPU usage, number of seconds
Seconds since beginning of most recent request
Milliseconds required to process most recent request
Kilobytes transferred this connection
Megabytes transferred this child
Total megabytes transferred this slot
Apache Server at
server-status 的输出中每个字段所代表的意义如下:
字段 & & && &&& &&& &&&& &&说明
Server Version & & & Apache 服务器的版本。
Server Built & & &&& & &Apache 服务器编译安装的时间。
Current Time & & &&& &目前的系统时间。
Restart Time & & &&& &&Apache 重新启动的时间。
Parent Server Generation & & & Apache 父程序 (parent process) 的世代编号,就是 httpd 接收到 SIGHUP 而重新启动的次数。
Server uptime & & &&&&Apache 启动后到现在经过的时间。
Total accesses & & & &到目前为此 Apache 接收的联机数量及传输的数据量。
CPU Usage & & &&& & &目前 CPU 的使用情形。
_SWSS.... & & & 所有 Apache process 目前的状态。每一个字符表示一个程序,最多可以显示 256 个程序的状态。
Scoreboard Key & & & 上述状态的说明。以下为每一个字符符号所表示的意义:
* _:等待连结中。
* S:启动中。
* R: 正在读取要求。
* W:正在送出回应。
* K:处于保持联机的状态。
* D:正在查找 DNS。
* C:正在关闭连结。
* L:正在写入记录文件。
* G:进入正常结束程序中。
* I:处理闲置。
* .:尚无此程序。
Srv & & & 本程序与其父程序的世代编号。
PID & & & 本程序的 process id。
Acc & & & 分别表示本次联机、本程序所处理的存取次数。
M & & & 该程序目前的状态。
CPU & & & 该程序所耗用的 CPU 资源。
SS & & & 距离上次处理要求的时间。
Req & & & 最后一次处理要求所耗费的时间,以千分之一秒为单位。
Conn & & & 本次联机所传送的数据量。
Child & & & 由该子程序所传送的数据量。
Slot & & & 由该 Slot 所传送的数据量。
Client & & & 客户端的地址。
VHost & & & 属于哪一个虚拟主机或本主机的 IP。
Request & & & 联机所提出的要求信息。
查看Apache的请求数和开启Apache Server Status&
在Linux下查看Apache的负载情况,最简单有有效的方式就是查看Apache Server Status,在没有开启Apache Server Status的情况下,或安装的是其他的Web Server,比如Nginx的时候,下面的命令就体现出作用了。
ps -ef|grep httpd|wc -l命令
#ps -ef|grep httpd|wc -l
统计httpd进程数,连个请求会启动一个进程,使用于Apache服务器。
表示Apache能够处理1388个并发请求,这个值Apache可根据负载情况自动调整,我这组服务器中每台的峰值曾达到过2002。
netstat -nat|grep -i “80″|wc -l命令
#netstat -nat|grep -i “80″|wc -l
netstat -an会打印系统当前网络链接状态,而grep -i “80″是用来提取与80端口有关的连接的, wc -l进行连接数统计。
最终返回的数字就是当前所有80端口的请求总数。
netstat -na|grep ESTABLISHED|wc -l命令
#netstat -na|grep ESTABLISHED|wc -l & & & & ---------个人测试此命令比较准确
netstat -an会打印系统当前网络链接状态,而grep ESTABLISHED 提取出已建立连接的信息。 然后wc -l统计。
最终返回的数字就是当前所有80端口的已建立连接的总数。
netstat -nat||grep ESTABLISHED|wc - & 可查看所有建立连接的详细记录
查看Apache的并发请求数及其TCP连接状态:
Linux命令:
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
(这条语句非常不错)
返回结果示例:
LAST_ACK 5
SYN_RECV 30
ESTABLISHED 1597
FIN_WAIT1 51
FIN_WAIT2 504
TIME_WAIT 1057
其中的SYN_RECV表示正在等待处理的请求数;ESTABLISHED表示正常数据传输状态;TIME_WAIT表示处理
完毕,等待超时结束的请求数。5564人阅读
Apache(16)
如果没有加载这个模块,如果您是linux服务器,那么就需要您重新编译apache
了,编译的时候加上参数--enable-module=so即可, 如果你是windows系统的话
,无需任何编译,只要把刚才时候说的LoadModule status_module
modules/mod_status.so这句加上,如果前面有带#号,开启的话,需要将#去除
。将表示访问状态页面可以每N
秒自动刷新一次;
在httpd.conf 增加#-Apache Server Status--------------ExtendedStatus On
&Location /Server-status&SetHandler Server-statusOrder deny,allowDeny from allAllow from 192.168.99.99&/Location&##--Apache Server Status--end---------
Deny from表示禁止的访问地址,如果访问报错可将此行注释,但是安全性会降低
;Allow from表示允许的地址访问。这里应该写允许的客户端IP,似乎不应该是域
名ExtendedStatus On表示的是待会访问的时候能看到详细的请求信息,另外该设
置仅能用于全局设置,不能在特定的虚拟主机中打开或关闭。启用扩展状态信息
将会导致服务器运行效率降低。
默认为查看第一个虚拟主机的信息。。。
Apache Server Status for Server Version: Apache Server Built: Apr 4 :54
---------------------------------------------------------------------
-----------
Current Time: Friday, 30-Jul-:01 CST Restart Time: Friday, 30-Jul-:38 CST Parent Server Generation: 0 Server uptime: 23 seconds Total accesses: 1 - Total Traffic: 1 kB CPU Usage: u0 s0 cu0 cs0 .0435 requests/sec - 44 B/second - 1024 B/request 1 requests currently being processed, 9 idle workers
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 /1 _ 0.00 11 134 0.0 0.00 0.00 114.92.*.222
/SEC HTTP/1.1 1-0 /0 W 0.00 0 0 0.0 0.00 0.00 114.92.*.222
/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
---------------------------------------------------------------------
-----------
Apache Server at
Port 80server-status 的输出中每个字段所代表的意义如下:字段&&&&&& 说明Server Version&&&&&& Apache 服务器的版本。Server Built&&&&&& Apache 服务器编译安装的时间。Current Time&&&&&& 目前的系统时间。Restart Time&&&&&& Apache 重新启动的时间。Parent Server Generation&&&&&& Apache 父程序 (parent process) 的世代编
号,就是 httpd 接收到 SIGHUP 而重新启动的次数。Server uptime&&&&&& Apache 启动后到现在经过的时间。Total accesses&&&&&& 到目前为此 Apache 接收的联机数量及传输的数据量。CPU Usage&&&&&& 目前 CPU 的使用情形。_SWSS....&&&&&& 所有 Apache process 目前的状态。每一个字符表示一个程序
,最多可以显示 256 个程序的状态。Scoreboard Key&&&&&& 上述状态的说明。以下为每一个字符符号所表示的意义
* _:等待连结中。* S:启动中。* R: 正在读取要求。* W:正在送出回应。* K:处于保持联机的状态。* D:正在查找 DNS。* C:正在关闭连结。* L:正在写入记录文件。* G:进入正常结束程序中。* I:处理闲置。* .:尚无此程序。
Srv&&&&&& 本程序与其父程序的世代编号。PID&&&&&& 本程序的 process id。Acc&&&&&& 分别表示本次联机、本程序所处理的存取次数。M&&&&&& 该程序目前的状态。CPU&&&&&& 该程序所耗用的 CPU 资源。SS&&&&&& 距离上次处理要求的时间。Req&&&&&& 最后一次处理要求所耗费的时间,以千分之一秒为单位。Conn&&&&&& 本次联机所传送的数据量。Child&&&&&& 由该子程序所传送的数据量。Slot&&&&&& 由该 Slot 所传送的数据量。Client&&&&&& 客户端的地址。VHost&&&&&& 属于哪一个虚拟主机或本主机的 IP。Request&&&&&& 联机所提出的要求信息。
查看Apache的请求数和开启Apache Server Status 在Linux下查看Apache的负载情况,以前也说过,最简单有有效的方式就是查看
Apache Server Status(如何开启Apache Server Status点这里),在没有开启
Apache Server Status的情况下,或安装的是其他的Web Server,比如Nginx的
时候,下面的命令就体现出作用了。ps -ef|grep httpd|wc -l命令#ps -ef|grep httpd|wc -l1388统计httpd进程数,连个请求会启动一个进程,使用于Apache服务器。表示Apache能够处理1388个并发请求,这个值Apache可根据负载情况自动调整,
我这组服务器中每台的峰值曾达到过2002。
netstat -nat|grep -i &80&P|wc -l命令#netstat -nat|grep -i &80&P|wc -l4341netstat -an会打印系统当前网络链接状态,而grep -i &80&P是用来提取与80
端口有关的连接的, wc -l进行连接数统计。最终返回的数字就是当前所有80端口的请求总数。
netstat -na|grep ESTABLISHED|wc -l命令#netstat -na|grep ESTABLISHED|wc -l&&&&&&&& ---------个人测试此命令比
较准确 376netstat -an会打印系统当前网络链接状态,而grep ESTABLISHED 提取出已建立
连接的信息。 然后wc -l统计。最终返回的数字就是当前所有80端口的已建立连接的总数。
netstat -nat||grep ESTABLISHED|wc -&& 可查看所有建立连接的详细记录
查看Apache的并发请求数及其TCP连接状态:Linux命令:netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
(这条语句非常不错)返回结果示例:LAST_ACK 5SYN_RECV 30ESTABLISHED 1597FIN_WAIT1 51FIN_WAIT2 504TIME_WAIT 1057其中的SYN_RECV表示正在等待处理的请求数;ESTABLISHED表示正常数据传输状
态;TIME_WAIT表示处理完毕,等待超时结束的请求数。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:369754次
积分:4920
积分:4920
排名:第5670名
原创:87篇
转载:257篇
评论:14条
(4)(1)(2)(3)(10)(1)(2)(8)(9)(40)(16)(14)(38)(35)(18)(9)(1)(18)(3)(14)(11)(2)(2)(6)(1)(12)(11)(8)(2)(1)(9)(24)(9)用户名:z永
文章数:85
评论数:200
访问量:229819
注册日期:
阅读量:1297
阅读量:3317
阅读量:442993
阅读量:1129029
51CTO推荐博文
apache server-status介绍我们平时使用apache常常了解他的性能只能使用ps aux|grep httpd|wc -l查看有多少个进程,但处理了多少http的请求我们不清楚,进程是不是在工作,还是在等都不是很明白,要了解apache的性能,我们需要使用 Apache Server Status的模块来详细了解apache工作的怎么样。打开Apache Server Status&如果你的Apache配置文件httpd.conf或者extra/httpd-info.conf中有LoadModule status_module modules/mod_status.so话,说明你的Apache已经加载了此模块;或者编译的时候加上了Cenable-module=so也表明服务器支持server-status。你可以用以下命令查看是否已经加载了模块: # /usr/local/apache/bin/httpd -l | grep mod_status.c如果没有安装这个模块,那么就需要您重新编译这个模块了,进入 apache 的源码目录:# cd /usr/local/src/httpd-2.2.14/modules/generators
# /usr/local/apache/bin/apxs -cia mod_status.c 这样模块就编译好了。你查看一下 apache 的配置文件里已经增加了LoadModule status_module
modules/mod_status.so 启动 server-status 功能,在 apache 的配置文件中增加一下配置代码: ExtendedStatus On
&Location /server-status&
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from IP
&/Location& 打开查看的话就使用来访问,如果需要自动更新,可以用,N是更新时间,默认是秒。下面是我的服务器的server-status显示:Apache Server Status for xxx.xxx.xxx.xxx
Server Version: Apache/2.2.14 (Unix) PHP/4.4.9
Server Built: May 31 :44Current Time: Thursday, 16-Sep-:34 CST
Restart Time: Monday, 13-Sep-:00 CST
Parent Server Generation: 5
Server uptime: 3 days 6 hours 40 minutes 33 seconds
Total accesses: 3303 - Total Traffic: 12.5 MB
CPU Usage: u.53 s.17 cu0 cs0 - .000247% CPU load
.0117 requests/sec - 46 B/second - 3958 B/request
1 requests currently being processed, 5 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 processSrv PID Acc M CPU
SS Req Conn Child Slot Client VHost Request
0-5 /552 W
0.12 0 0 0.0 2.08 2.08
xxx.xxx.xxx.xxx localhost.localdomain GET /status HTTP/1.1
1-5 /551 _
0.12 .0 2.08 2.08
xxx.xxx.xxx.xxx localhost.localdomain GET /status?refresh=5 HTTP/1.1
2-5 /551 _
0.11 .0 2.08 2.08
xxx.xxx.xxx.xxx localhost.localdomain GET /status HTTP/1.1
3-5 /566 _
1.14 .0 2.10 2.10
xxx.xxx.xxx.xxx localhost.localdomain GET /awstatsicons/browser/firefox.png HTTP/1.1
4-5 /563 _
0.65 .0 2.15 2.15
xxx.xxx.xxx.xxx localhost.localdomain GET /awstatsicons/browser/msie.png HTTP/1.1
5-5 /560 _
0.13 .0 2.08 2.08
xxx.xxx.xxx.xxx localhost.localdomain GET /awstatsicons/os/linux.png 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 server-status 的输出中每个字段所代表的意义如下:字段
说明Server Version
Apache 服务器的版本。Server Built
Apache 服务器编译安装的时间。Current Time
目前的系统时间。Restart Time
Apache 重新启动的时间。Parent Server Generation
Apache 父程序 (parent process) 的世代编号,就是 httpd 接收到 SIGHUP 而重新启动的次数。Server uptime
Apache 启动后到现在经过的时间。Total accesses
到目前为此 Apache 接收的联机数量及传输的数据量。CPU Usage
目前 CPU 的使用情形。_SWSS….
所有 Apache process 目前的状态。每一个字符表示一个程序,最多可以显示 256 个程序的状态。Scoreboard Key
上述状态的说明。以下为每一个字符符号所表示的意义:
* _:等待连结中。
* S:启动中。
* R: 正在读取要求。
* W:正在送出回应。
* K:处于保持联机的状态。
* D:正在查找 DNS。
* C:正在关闭连结。
* L:正在写入记录文件。
* G:进入正常结束程序中。
* I:处理闲置。
* .:尚无此程序。Srv
本程序与其父程序的世代编号。PID
本程序的 process id。Acc
分别表示本次联机、本程序所处理的存取次数。M
该程序目前的状态。CPU
该程序所耗用的 CPU 资源。SS
距离上次处理要求的时间。Req
最后一次处理要求所耗费的时间,以千分之一秒为单位。Conn
本次联机所传送的数据量。Child
由该子程序所传送的数据量。Slot
由该 Slot 所传送的数据量。Client
客户端的地址。VHost
属于哪一个虚拟主机或本主机的 IP。Request
联机所提出的要求信息。不错吧,挺直观的吧。本文转载自 http://854/392839
了这篇文章
类别:┆阅读(0)┆评论(0)mod_status - Apache HTTP Server
Apache Module mod_status
Available Languages:
Provides information on server activity and
performance
status_module
mod_status.c
Warning: This document has not been updated
to take into account changes made in the 2.0 version of the
Apache HTTP Server. Some of the information may still be
relevant, but please use it with care.
The Status module allows a server administrator to find out
how well their server is performing. A HTML page is presented
that gives the current server statistics in an easily readable
form. If required this page can be made to automatically
refresh (given a compatible browser). Another page gives a
simple machine-readable list of the current server state.
The details given are:
The number of children serving requests
The number of idle children
The status of each child, the number of requests that
child has performed and the total number of bytes served by
the child (*)
A total number of accesses and byte count served (*)
The time the server was started/restarted and the time it
has been running for
Averages giving the number of requests per second, the
number of bytes served per second and the average number of
bytes per request (*)
The current percentage CPU used by each child and in
total by Apache (*)
The current hosts and requests being processed (*)
A compile-time option must be used to display the details
marked "(*)" as the instrumentation required for obtaining
these statistics does not exist within standard Apache.
Directives
To enable status reports only for browsers from
domain add this code to your httpd.conf
configuration file
&Location /server-status&
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from .
&/Location&
You can now access server statistics by using a Web browser
to access the page
http://your.server.name/server-status
will only work
when you are running Apache in
mode and not
You can get the status page to update itself automatically if
you have a browser that supports "refresh". Access the page
http://your.server.name/server-status?refresh=N to
refresh the page every N seconds.
A machine-readable version of the status file is available by
accessing the page
http://your.server.name/server-status?auto. This
is useful when automatically run, see the Perl program in the
/support directory of Apache,
log_server_status.
It should be noted that if
compiled into the server, its handler capability is available
in all configuration files, including
per-directory files (e.g.,
.htaccess). This may have security-related
ramifications for your site.
Keep track of extended status information for each
ExtendedStatus On|Off
ExtendedStatus Off
server config
mod_status
ExtendedStatus is only available in Apache 1.3.2 and
This setting applies to the entire server, and cannot be
enabled or disabled on a virtualhost-by-virtualhost basis.
The collection of extended status information can slow down
the server.
Available Languages:

我要回帖

更多关于 mac apache status 的文章

 

随机推荐