天天看點

監控nginx運作狀态

使用http_stub_status_module

在編譯安裝nginx的時候可以加上--with-http_stub_status_module,如果已經安裝好nginx可以參考nginx安裝完成後增加子產品的博文,

在nginx.conf的server塊中添加如下代碼

location /status {

    # Turn on nginxstats

    stub_status on;

    # I do not needlogs for stats

    access_log   off;

    # Security:Only allow access from 192.168.1.100 IP #

    #allow192.168.1.100;

    # Send rest ofthe world to /dev/null #

    #deny all;

}

重新開機nginx即可通過ip:端口/status就可以檢視到了類似下面的頁面

Active connections: 3 
server accepts handled requests
 10 10 137 
Reading: 0 Writing: 1 Waiting: 2      

繼續閱讀