http status code information nginx statistical response (ngx-http-status-code-counter)

1. Introduction ngx-http-status-code- counter is used to record statistical information nginx a response status code, the author of this module will be analyzed in conjunction with the munin site http status, we also can use this with nagios, zabbix or other monitoring system would like to combine with the operation and maintenance module can no longer use a script to analyze the log. 2. Install nginx installation say no more, please refer to the operation and maintenance of early survival time " nginx installation ," and I am using the test nginx-1.4.2 do. Author only on the 0.8.50 version, the module is relatively simple, usually compatible with the new version, but we better do a test before using.
# cd /usr/local/src/
# wget https://github.com/kennon/ngx_http_status_code_counter/archive/master.zip
# unzip master
# cd nginx-1.4.2 
# ./configure --prefix=/usr/local/nginx-1.4.2 --add-module=../ngx_http_status_code_counter-master
# make
# make install
3. Configure NGINX
# for http_code_status
location /ttlsa_http_code_status/
{
        show_status_code_count on;
}

location /ttlsa_http_code_status500/
{
        return 500;
}

location /ttlsa_http_code_status502/
{
        return 502;
}
4. Test were manufactured http://test.ttlsa.com/ttlsa_http_code_status500 access http://test.ttlsa.com/ttlsa_http_code_status502/ and a status code of 500 and 502, and a random access response code page 404 for producing, all It is to test. FIG test output follows [Caption ID = "attachment_4114" align = left = "alignnone" width = "516"] ngx_http_status_code_counter ngx_http_status_code_counter [/ Caption] 5. The drawback of significant drawbacks, all data stored in the memory nginx, once or reload nginx re-opened, the data is empty. Another drawback is that it is ongoing statistical data superimposed, there is no time to distinguish, if you want statistics http response code each time you need to regularly reboot nginx. 5. Compatibility compatible 0.8.x, but 0.7.x test. My current version is 1.4.2 running the OK 6. Conclusion In this function, the statistics out nginx http response code into the surveillance system, easy to troubleshoot system problems. Subsequent re-posted monitoring system integrated into the case, please continue to focus on the operation and maintenance of survival time. Site: operation and maintenance lifetime URL: http: //www.ttlsa.com/nginx/nginx-modules-ngx-http-status-code-counter/

Reproduced in: https: //my.oschina.net/766/blog/211506

Guess you like

Origin blog.csdn.net/weixin_34041003/article/details/91547901