Apche和Nginx 状态页面开启设置

[attach]1483[/attach]

Apache Server Status​设置

1、确认apache已经加载了status_module 模块 一般yum安装的apache已经在主配置文件/etc/httpd/conf/httpd.conf 里面已经加载了
LoadModule status_module modules/mod_status.so
检验如下:
[root@web1 httpd]# apachectl -M |grep -i 'status'
 status_module (shared)
Syntax OK
如果是编译安装的apache,那你就可能没有安装了,编译安装的,动态添加如下:
# 进入到apache的源码mod_status.c目录
cd /usr/local/httpd-2.2.3/modules/generators
# 执行编译加载程序
/usr/local/apache/bin/apxs -i -a -c mod_status.c
# 重启httpd服务
service httpd restart
最后在用httpd -M检查模块是否已经加载,确认模块已经加载没有问题后,在httpd.conf文件增加相应的配置路径 ,引入mod_status.so的配置段:
ExtendedStatus On

SetHandler Server-status
Order deny,allow
Deny from all
Allow from 192.168.1.100
说明:
  1. Deny from表示禁止的访问地址;
  2. Allow from表示允许的地址访问;
  3. ExtendedStatus On表示的是待会访问的时候能看到详细的请求信息,另外该设置仅能用于全局设置,不能在特定的虚拟主机中打开或关闭。启用扩展状态信息将会导致服务器运行效率降低。
 状态页的配置到这里就结束了,下面我们来访问一下,看看具体状态页有哪些可以利用的价值数据。 输入网址http://IP:PORT/server-status就可以看到apache状态页了。
Apache Server Status for localhost
Server Version: Apache/2.2.3 (Centos)
Server Built: Nov 9 2016 15:18:56

Current Time: Sunday, 11-Nov-2016 17:44:21 Öйú±ê׼ʱ¼ä
Restart Time: Sunday, 11-Nov-2016 17:36:28 Öйú±ê׼ʱ¼ä
Parent Server Generation: 1
Server uptime: 7 minutes 52 seconds
Total accesses: 0 - Total Traffic: 0 kB
0 requests/sec - 0 B/second -
1 requests currently being processed, 63 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    SS    Req    Conn    Child    Slot    Client    VHost    Request
0-1    4140    0/0/0    W    0    287636364    0.0    0.00    0.00    127.0.0.1    192.168.0.100    GET /c-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
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 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     联机所提出的要求信息。

Nginx 状态页配置

如果你的nginx看到了--with-http_sub_module 这个模块,就代表可以启用status,使用nginx -V 就可以看到你的编译参数,如果没有的话,自行重新编译加上--with-http_sub_module 就好。   1、添加nginx status配置 在默认主机里面加上location或者你希望能访问到的主机里面
 location /nginx_status {
       stub_status on;
       access_log off;
       allow 10.0.1.xx;
       allow 139.59.253.28;
       deny all;
    }
2、重启nginx
# service nginx restart
3、查看status页面
# curl http://127.0.0.1/nginx_status
Active connections: 10132 
server accepts handled requests
 11302 11302 11409 
Reading: 0 Writing: 7 Waiting: 142
第1列: 当前与http建立的连接数,包括等待的客户端连接:10132 第2列: 接受的客户端连接总数目:11302 处理的客户端连接总数目:11302 客户端总的请求数目:11409 总共处理了11302个连接 , 成功创建11302次握手, 总共处理了11409个请求 第3列: reading — 读取客户端的连接数. writing — 响应数据到客户端的数量 waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.   nginx plus (企业用户)官网(http://demo.nginx.com/status.html#)图示如下: [attach]1484[/attach]

0 个评论

要回复文章请先登录注册