要看 Apache Loading 的狀況, 可以看 Apache Status, 但是 Nginx server 的 loading / Status 要怎麼查看呢?
啟用 Nginx Status 的設定步驟
設定參考: Nginx Http Stub Status
- vim /etc/nginx/sites-available/default
server { ... location /nginx_status { stub_status on; access_log off; allow 123.123.123.123; # 允許看到的 IP allow 127.0.0.1; deny all; } }
- /etc/init.d/nginx restart
- curl http://localhost/nginx_status # 查看 Nginx status
curl nginx_status 的回傳格式如下:
Active connections: 816 server accepts handled requests 39600484 39600484 24795538 Reading: 0 Writing: 4 Waiting: 794
下述說明摘錄自此篇:Module ngx_http_stub_status_module
- Active connections
- The current number of active client connections including Waiting connections.
- accepts
- The total number of accepted client connections.
- handled
- The total number of handled connections. Generally, the parameter value is the same as accepts unless some resource limits have been reached (for example, the worker_connections limit).
- requests
- The total number of client requests.
- Reading
- The current number of connections where nginx is reading the request header.
- Writing
- The current number of connections where nginx is writing the response back to the client.
- Waiting
- The current number of idle client connections waiting for a request.
監看 Nginx status 的 Script
監控 Status 的 Script, 讓 Status 比較容易看
- wget https://raw.githubusercontent.com/magicdrums/Scripts/master/nginxstats.py
- chmod +x ./nginxstats.py
- ./nginxstats.py http://localhost/nginx_status
- 其它參數:nginxstats.py --servers="http://localhost/nginx_status" --time=5
相關網頁
- Monitoring nginx Server Statistics With rrdtool - 狀態畫成圖表 (apt-get install librrds-perl libwww-perl)
- Enable Nginx Status Page