{"id":4343,"date":"2015-05-12T11:34:23","date_gmt":"2015-05-12T03:34:23","guid":{"rendered":"https:\/\/www.hmouse.tk\/?p=4343"},"modified":"2015-06-07T11:03:22","modified_gmt":"2015-06-07T03:03:22","slug":"zabbix%e6%b7%bb%e5%8a%a0%e6%a8%a1%e5%9d%97%e7%9b%91%e6%8e%a7","status":"publish","type":"post","link":"https:\/\/www.hmouse.cn\/?p=4343","title":{"rendered":"zabbix\u6dfb\u52a0\u6a21\u5757\u76d1\u63a7"},"content":{"rendered":"<p>\u6dfb\u52a0nginx<\/p>\n<p>\u53c2\u8003url\uff1a<a title=\"http:\/\/john88wang.blog.51cto.com\/2165294\/1577269\" href=\"http:\/\/john88wang.blog.51cto.com\/2165294\/1577269\">http:\/\/john88wang.blog.51cto.com\/2165294\/1577269<\/a><\/p>\n<p>Nginx\u81ea\u5e26\u76d1\u63a7\u6a21\u5757ngx_http_stub_status_module\u63d0\u4f9bNginx\u7684\u57fa\u672c\u4fe1\u606f  <\/p>\n<p>\u5728\u7f16\u8bd1\u5b89\u88c5Nginx\u65f6\u52a0\u53c2\u6570 &#8211;with-http_stub_status_module&nbsp; <\/p>\n<p>\u5b89\u88c5\u597d\u4ee5\u540e\u53ef\u4ee5\u901a\u8fc7nginx -V|grep http_stub_status_module \u67e5\u770b\u72b6\u6001\u6a21\u5757\u662f\u5426\u5df2\u5b89\u88c5  <\/p>\n<p>PHP-FPM\u4e5f\u81ea\u5e26\u76d1\u63a7\uff0c\u901a\u8fc7\u5728php-fpm.conf\u4e2d\u8bbe\u7f6e  <\/p>\n<p>pm.status_path = \/php-fpm_status  <\/p>\n<p>\u5c31\u53ef\u4ee5\u83b7\u53d6URL\u7684\u65b9\u5f0f\u83b7\u53d6PHP-FPM\u7684\u72b6\u6001  <\/p>\n<p>\u53c2\u8003\u6587\u7ae0  <\/p>\n<p><a href=\"https:\/\/rtcamp.com\/tutorials\/php\/fpm-status-page\/\">https:\/\/rtcamp.com\/tutorials\/php\/fpm-status-page\/<\/a>  <\/p>\n<ol>\n<li>\n<p>\u6dfb\u52a0nginx_status.conf<\/p>\n<\/li>\n<\/ol>\n<p><code>server {<\/code>  <\/p>\n<p><code><\/code><code>listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 88 ;<\/code>  <\/p>\n<p><code><\/code><code>location \/nginx_status {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code><code>stub_status on;<\/code>  <\/p>\n<p><code><\/code><code>access_log off;<\/code>  <\/p>\n<p><code><\/code><code>allow 127.0.0.1;<\/code>  <\/p>\n<p><code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; allow 10.4.1.125;<\/code>  <\/p>\n<p><code><\/code><code>deny all;<\/code>  <\/p>\n<p><code><\/code><code>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>location \/php-fpm_status {<\/code>  <\/p>\n<p><code><\/code><code>fastcgi_pass 127.0.0.1:9000;<\/code>  <\/p>\n<p><code><\/code><code>fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<\/code>  <\/p>\n<p><code><\/code><code>include fastcgi_params;<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>$ curl&nbsp; 127.0.0.1:88\/nginx_status<\/code>  <\/p>\n<p><code>Active connections: 1 <\/code> <\/p>\n<p><code>server accepts handled requests<\/code>  <\/p>\n<p><code><\/code><code>788163 788163 788163 <\/code> <\/p>\n<p><code>Reading: 0 Writing: 1 Waiting: 0<\/code>  <\/p>\n<p>Active connections&nbsp;&nbsp;&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The current number of active client connections including <code>Waiting<\/code> connections.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u6d3b\u8dc3\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\uff0c\u5305\u62ec\u5904\u4e8e\u7b49\u5f85\u72b6\u6001\u7684\u8fde\u63a5\u6570  <\/p>\n<p><code>accepts<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The total number of accepted client connections.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u63a5\u6536\u5230\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u603b\u6570  <\/p>\n<p><code>handled<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The total number of handled connections. Generally, the parameter value is the same as <code>accepts<\/code> unless some resource limits have been reached&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5904\u7406\u8bf7\u6c42\u7684\u603b\u6570\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u503c\u548caccepts\u7684\u503c\u76f8\u540c\u3002\u9664\u975e\u8fbe\u5230\u4e86\u4e00\u4e9b\u8d44\u6e90\u9650\u5236\u3002\u4f8b\u5982\u8bbe\u7f6e<strong>worker_connections<\/strong> <em>1024\uff1b&nbsp; \u8bbe\u7f6e\u4e00\u4e2aworker\u8fdb\u7a0b\u80fd\u591f\u6253\u5f00\u7684\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u6570\u3002<\/em>  <\/p>\n<p><code>requests<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The total number of client requests.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5ba2\u6237\u7aef\u8bf7\u6c42\u603b\u6570  <\/p>\n<p><code>Reading<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The current number of connections where nginx is reading the request header.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5f53\u524dNginx\u6b63\u5728\u8bfb\u53d6\u8bf7\u6c42\u5934\u7684\u8fde\u63a5\u6570\u91cf  <\/p>\n<p><code>Writing<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The current number of connections where nginx is writing the response back to the client.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5f53\u524dNginx\u6b63\u5728\u5c06\u54cd\u5e94\u5199\u56de\u5230\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u6570\u91cf  <\/p>\n<p><code>Waiting<\/code>  <\/p>\n<p>The current number of idle client connections waiting for a request.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5f53\u524d\u6b63\u5728\u7b49\u5f85\u8bf7\u6c42\u7684\u95f2\u7f6e\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\u91cf  <\/p>\n<p><code>$ curl&nbsp; 127.0.0.1:88\/php-fpm_status<\/code>  <\/p>\n<p><code>pool:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; www<\/code>  <\/p>\n<p><code>process manager:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dynamic<\/code>  <\/p>\n<p><code>start time:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16\/Nov\/2014:13:29:11 +0800<\/code>  <\/p>\n<p><code>start since:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 77844<\/code>  <\/p>\n<p><code>accepted conn:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 202788<\/code>  <\/p>\n<p><code>listen queue:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>max listen queue:&nbsp;&nbsp;&nbsp;&nbsp; 1<\/code>  <\/p>\n<p><code>listen queue len:&nbsp;&nbsp;&nbsp;&nbsp; 128<\/code>  <\/p>\n<p><code>idle processes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6<\/code>  <\/p>\n<p><code>active processes:&nbsp;&nbsp;&nbsp;&nbsp; 1<\/code>  <\/p>\n<p><code>total processes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<\/code>  <\/p>\n<p><code>max active processes: 4<\/code>  <\/p>\n<p><code>max children reached: 0<\/code>  <\/p>\n<p><code>slow requests:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p>pool&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pool\u540d\u79f0  <\/p>\n<p>process manager&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static or dynamic  <\/p>\n<p>start time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u542f\u52a8\u65f6\u95f4  <\/p>\n<p>start since&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u542f\u52a8\u4e86\u591a\u957f\u65f6\u95f4\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d  <\/p>\n<p>accepted conn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pool\u63a5\u6536\u5230\u7684\u8bf7\u6c42\u6570\u91cf  <\/p>\n<p><strong>listen queue<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of request in the queue of pending connections.\u8fd9\u4e2a\u503c\u5982\u679c\u4e0d\u4e3a0\uff0c\u6700\u597d\u589e\u52a0PHP-FPM\u7684\u8fdb\u7a0b\u6570\u91cf  <\/p>\n<p><strong>max listen queue<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the maximum number of requests in the queue of pending connections since FPM has started  <\/p>\n<p><strong>listen queue len<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the size of the socket queue of pending connections  <\/p>\n<p><strong>idle processes<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of idle processes  <\/p>\n<p><strong>active processes<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of active processes  <\/p>\n<p><strong>total processes<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of idle + active processes  <\/p>\n<p><strong>max active processes<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the maximum number of active processes since FPM has started  <\/p>\n<p><strong>max children reached&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/strong>number of times, the process limit has been reached, when pm tries to start more children. If that value is not zero, then you may need to increase max process limit for your PHP-FPM pool. Like this, you can find other useful information to tweak your pool better way.\u5982\u679c\u8fd9\u4e2a\u503c\u4e0d\u4e3a0\uff0c\u6700\u597d\u589e\u5927\u6700\u5927\u8fdb\u7a0b\u7684\u9650\u5236\u3002  <\/p>\n<p><strong>slow requests<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5982\u679c\u8fd9\u4e2a\u503c\u4e0d\u4e3a0\uff0c\u8868\u793a\u6709\u5904\u7406\u6162\u7684\u7a0b\u5e8f  <\/p>\n<p>&nbsp; <\/p>\n<p><code>$ curl 127.0.0.1:88\/php-fpm_status?full<\/code>  <\/p>\n<p><code>pool:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; www<\/code>  <\/p>\n<p><code>process manager:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dynamic<\/code>  <\/p>\n<p><code>start time:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 17\/Nov\/2014:16:09:17 +0800<\/code>  <\/p>\n<p><code>start since:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1139<\/code>  <\/p>\n<p><code>accepted conn:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3354<\/code>  <\/p>\n<p><code>listen queue:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>max listen queue:&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>listen queue len:&nbsp;&nbsp;&nbsp;&nbsp; 128<\/code>  <\/p>\n<p><code>idle processes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5<\/code>  <\/p>\n<p><code>active processes:&nbsp;&nbsp;&nbsp;&nbsp; 1<\/code>  <\/p>\n<p><code>total processes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6<\/code>  <\/p>\n<p><code>max active processes: 2<\/code>  <\/p>\n<p><code>max children reached: 0<\/code>  <\/p>\n<p><code>slow requests:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>************************<\/code>  <\/p>\n<p><code>pid:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19921<\/code>  <\/p>\n<p><code>state:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Idle<\/code>  <\/p>\n<p><code>start time:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 17\/Nov\/2014:16:09:17 +0800<\/code>  <\/p>\n<p><code>start since:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1139<\/code>  <\/p>\n<p><code>requests:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 563<\/code>  <\/p>\n<p><code>request duration:&nbsp;&nbsp;&nbsp;&nbsp; 223<\/code>  <\/p>\n<p><code>request method:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GET<\/code>  <\/p>\n<p><code>request URI:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/php-fpm_status<\/code>  <\/p>\n<p><code>content length:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>user:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<\/code>  <\/p>\n<p><code>script:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<\/code>  <\/p>\n<p><code>last request cpu:&nbsp;&nbsp;&nbsp;&nbsp; 0.00<\/code>  <\/p>\n<p><code>last request memory:&nbsp; 262144<\/code>  <\/p>\n<p>curl 127.0.0.1:88\/php-fpm_status?json  <\/p>\n<p>curl 127.0.0.1:88\/php-fpm_status?html  <\/p>\n<p>curl 127.0.0.1:88\/php-fpm_status?xml  <\/p>\n<p>2.\u7f16\u5199Nginx\u548cPHP-FPM\u72b6\u6001\u4fe1\u606f\u83b7\u53d6\u811a\u672c  <\/p>\n<p>nginx_status.sh  <\/p>\n<p><code>#!\/bin\/bash<\/code>  <\/p>\n<p><code>#check nginx status<\/code>  <\/p>\n<p><code>#ip=$(ifconfig eth0|grep \"inet addr\"|sed&nbsp; 's\/^.*addr:\/\/'|awk '{print $1}')<\/code>  <\/p>\n<p><code>#echo $ip<\/code>  <\/p>\n<p><code>ip=127.0.0.1<\/code>  <\/p>\n<p><code>port=88<\/code>  <\/p>\n<p><code>#echo $ip:$port<\/code>  <\/p>\n<p><code>function active()&nbsp; {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|grep \"Active\"|awk '{print $NF}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function reading() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|grep \"Reading\"|awk '{print $2}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function writing() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|grep \"Writing\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function waiting() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|grep \"Waiting\"|awk '{print $6}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function accepts() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|awk 'NR==3{print $1}'&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function handled() {<\/code>  <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|awk 'NR==3{print $2}'&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function requests(){<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|awk 'NR==3{print $3}'&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>case $1 in<\/code>  <\/p>\n<p><code><\/code><code>active)<\/code>  <\/p>\n<p><code><\/code><code>active<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>reading)<\/code>  <\/p>\n<p><code><\/code><code>reading<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>writing)<\/code>  <\/p>\n<p><code><\/code><code>writing<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>waiting)<\/code>  <\/p>\n<p><code><\/code><code>waiting<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>accepts)<\/code>  <\/p>\n<p><code><\/code><code>accepts<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>handled)<\/code>  <\/p>\n<p><code><\/code><code>handled<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>requests)<\/code>  <\/p>\n<p><code><\/code><code>requests<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>*)<\/code>  <\/p>\n<p><code><\/code><code>exit 1<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code>esac<\/code>  <\/p>\n<p>php-fpm_status.sh  <\/p>\n<p><code>#!\/bin\/bash<\/code>  <\/p>\n<p><code>#check php-fpm status<\/code>  <\/p>\n<p><code>ip=127.0.0.1<\/code>  <\/p>\n<p><code>port=88<\/code>  <\/p>\n<p><code>function idle()&nbsp; {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"idle processes\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function active() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"active processes\"|awk '{print $3}'|grep -v \"processes\"<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function total() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"total processes\"|awk '{print $3}'|grep -v \"processes\"<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function mactive() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"max active processes\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function conn()&nbsp;&nbsp;&nbsp; {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"accepted conn\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function since() {<\/code>  <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"start since\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function slow()&nbsp;&nbsp; {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"slow requests\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function listenqueue() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"listen queue:\"|grep -v \"max\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function maxlistenqueue() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"max listen queue:\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function listenqueuelen() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"listen queue len:\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function maxchildren() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"max children reached:\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>$1<\/code>  <\/p>\n<p>3.\u6dfb\u52a0zabbix\u7684\u5b50\u914d\u7f6e\u6587\u4ef6  <\/p>\n<p>nginx_status_zabbix.conf  <\/p>\n<p><code>### Option: UserParameter<\/code>  <\/p>\n<p><code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; User-defined parameter to monitor. There can be several user-defined parameters.<\/code>  <\/p>\n<p><code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Format: UserParameter=&lt;key&gt;,&lt;shell command&gt;<\/code>  <\/p>\n<p><code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; See 'zabbix_agentd' directory for examples.<\/code>  <\/p>\n<p><code>#<\/code>  <\/p>\n<p><code># Mandatory: no<\/code>  <\/p>\n<p><code># Default:<\/code>  <\/p>\n<p><code># UserParameter=<\/code>  <\/p>\n<p><code># \/usr\/local\/zabbix\/bin\/nginx_status.sh<\/code>  <\/p>\n<p><code>UserParameter=nginx.accepts,\/usr\/local\/zabbix\/bin\/nginx_status.sh accepts<\/code>  <\/p>\n<p><code>UserParameter=nginx.handled,\/usr\/local\/zabbix\/bin\/nginx_status.sh handled<\/code>  <\/p>\n<p><code>UserParameter=nginx.requests,\/usr\/local\/zabbix\/bin\/nginx_status.sh requests<\/code>  <\/p>\n<p><code>UserParameter=nginx.connections.active,\/usr\/local\/zabbix\/bin\/nginx_status.sh active<\/code>  <\/p>\n<p><code>UserParameter=nginx.connections.reading,\/usr\/local\/zabbix\/bin\/nginx_status.sh reading<\/code>  <\/p>\n<p><code>UserParameter=nginx.connections.writing,\/usr\/local\/zabbix\/bin\/nginx_status.sh writing<\/code>  <\/p>\n<p><code>UserParameter=nginx.connections.waiting,\/usr\/local\/zabbix\/bin\/nginx_status.sh waiting<\/code>  <\/p>\n<p>php-fpm_status.conf  <\/p>\n<p><code>UserParameter=php-fpm.idle.processes,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh idle<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.total.processes,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh total<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.active.processes,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh active<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.max.active.processes,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh mactive<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.listen.queue.len,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh listenqueuelen<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.listen.queue,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh listenqueue<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.start.since,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh since<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.accepted.conn,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh conn<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.slow.requests,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh slow<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.max.listen.queue,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh maxlistenqueue<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.max.children,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh maxchildren<\/code>  <\/p>\n<p>4.\u6dfb\u52a0zabbix\u76d1\u63a7\u6a21\u677f  <\/p>\n<p>\u6a21\u677f\u53c2\u89c1\u9644\u4ef6<\/p>\n<p>&nbsp;<\/p>\n<p>mysql \u7684\u6a21\u677f \u5728<a title=\"https:\/\/github.com\/zbal\/zabbix\/tree\/master\/server_template\" href=\"https:\/\/github.com\/zbal\/zabbix\/tree\/master\/server_template\">https:\/\/github.com\/zbal\/zabbix\/tree\/master\/server_template<\/a><\/p>\n<p>\u4ee5\u524d\u7684\u6211\u8bb0\u5f97\u662f\u901a\u8fc7php\u83b7\u53d6\u7684\uff0c\u627e\u4e0d\u5230\u4e86\u8fd9\u4e2a\u76f4\u63a5\u901a\u8fc7mysql \u5ba2\u6237\u7aef\u83b7\u53d6\u7684<\/p>\n<p>\u540e\u6765\u53d1\u73b0\u627e\u4e0d\u5230 \u539f\u6765\u662f\u56e0\u4e3a\u5b98\u7f51 \u5220\u9664\u4e86\u7f51\u9875\u4e86 \u6211\u65e5\u554a<\/p>\n<p><a title=\"http:\/\/os.51cto.com\/art\/201104\/253006_all.htm\" href=\"http:\/\/os.51cto.com\/art\/201104\/253006_all.htm\">http:\/\/os.51cto.com\/art\/201104\/253006_all.htm<\/a>&nbsp; \u539f\u6765\u7684\u5b89\u88c5\u65b9\u6cd5\u3002<\/p>\n<p><strong>zabbix<\/strong>\u5168\u9762\u76d1\u63a7<strong>mysql<\/strong>\u5b9e\u65bd\u8d77\u6765\u8fd8\u662f\u6bd4\u8f83\u7ed9\u529b\u7684\uff01 <\/p>\n<p><strong>\u4e00\u3001\u4ece\u7f51\u4e0a\u4e0b\u8f7d\u76f8\u5e94\u811a\u672c\u4e0eXML\u5b9a\u4e49\u6587\u4ef6\u3002<\/strong> <\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/www.zabbix.com\/wiki\/doku.php?id=extensive_mysql_monitoring_including_replication<\/p>\n<pre><ol><li>Template_MySQL_Server.xml&nbsp; <li>&nbsp;<li>Template_MySQL_Replication_Master.xml&nbsp; <li>&nbsp;<li>Template_MySQL_Replication_Slave.xml&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u548c\u6267\u884c\u811a\u672c\uff1amysql.php<\/p>\n<p><strong>\u4e8c\u3001\u628amysql.php\u4e0a\u4f20\u81f3\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55\/etc\/zabbix\/<\/strong><\/p>\n<pre><ol><li>chmod 755 mysql.php&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p><strong>\u4e09\u3001\u4fee\u6539mysql.php\u6587\u4ef6<\/strong><\/p>\n<p>\u6839\u636e\u672c\u673a\u73af\u5883\u3002<\/p>\n<p>\u7b2c\u4e00\u884c\u52a0\u5165\uff1a#!\/usr\/bin\/php<\/p>\n<p>\u5728\u6700\u540e\u4e00\u884c\u52a0\u5165\uff1a?&gt;<\/p>\n<p>\u5173\u95ed\u8c03\u8bd5\uff1adefine(&#8216;DEBUG&#8217;,true);\u3000\u4e3a\u3000define(&#8216;DEBUG&#8217;,False);<\/p>\n<p>\u4fee\u6539\u65e5\u5fd7\u3001\u6570\u636e\u6587\u4ef6\u8def\u5f84\uff1a<\/p>\n<pre><ol><li>define('LOG',\"\/tmp\/zabbix_\".SYSTEM.\".log\");&nbsp; <li>&nbsp;<li>define('DAT',\"\/tmp\/zabbix_\".SYSTEM.\".dat\");&nbsp; <li>&nbsp;<li>define('UTIME',\"\/tmp\/.zabbix_\".SYSTEM.\".utime\");&nbsp; <li>&nbsp;<li>define('DTIME',\"\/tmp\/.zabbix_\".SYSTEM.\".dtime\");&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u4fee\u6539\uff1adefine(&#8216;SYSTEM&#8217;,&#8217;mysql&#8217;.(DEBUG ? &#8220;-debug&#8221; : &#8220;&#8221;)); \u4e3a\uff1adefine(&#8216;SYSTEM&#8217;,&#8217;mysql&#8217;);<\/p>\n<p>\u6253\u5f00\u7cfb\u7edf\u65e5\u5fd7\u529f\u80fd\uff1a\/\/system(&#8220;zabbix_sender -z $server -i &#8220;.DAT.&#8221; &gt;&gt; &#8220;.LOG);\u3000\u4e3a\uff1asystem(&#8220;zabbix_sender -z $server -i &#8220;.DAT.&#8221; &gt;&gt; &#8220;.LOG);<\/p>\n<p>\u5728$cmd = &#8220;zabbix_sender -z $server -p 10051 -s $host -k &#8220;.SYSTEM.&#8221;.$var -o $val&#8221;;<\/p>\n<p>\u4e0b\u9762\u589e\u52a0\u4e00\u884c\uff1aexec($cmd);<\/p>\n<p><strong>\u56db\u3001\u5728zabbix_agentd.conf\u914d\u7f6e\u6587\u4ef6\u4e2d\u52a0\u5165<\/strong><\/p>\n<p>UserParameter=mysql.daily,php \/etc\/zabbix\/mysql.php daily \u7528\u6237\u540d \u5bc6\u7801<\/p>\n<p>UserParameter=mysql.live,php \/etc\/zabbix\/mysql.php live \u7528\u6237\u540d\u3000\u5bc6\u7801<\/p>\n<p>daily:\u6bcf\u5929\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<p>live:\u6309\u6307\u5b9a\u65f6\u95f4\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<p>php :\u6267\u884cphp\u6587\u4ef6<\/p>\n<p>\/etc\/zabbix\/mysql.php:mysql.php\u6587\u4ef6\u6240\u5728\u7684\u6587\u4ef6\u8def\u5f84<\/p>\n<p>\u7528\u6237\u540d\u3000\u5bc6\u7801\uff1a\u767b\u5f55mysql\u6570\u636e\u5e93\u7684\u8d26\u6237\u4e0e\u5bc6\u7801<\/p>\n<p>\u91cd\u542fzabbix_agentd<\/p>\n<p><strong>\u4e94\u3001\u5728zabbix web\u7ba1\u7406\u754c\u9762\u5bfc\u5165xml\u6587\u4ef6<\/strong><\/p>\n<p>\u914d\u7f6e-\u5bfc\u5165\/\u5bfc\u51fa-\u6d4f\u89c8<\/p>\n<p><strong>\u516d\u3001\u5728\u4e3b\u673a\u5185\u589e\u52a0\u6307\u5b9a\u6a21\u677f<\/strong><\/p>\n<p>\u914d\u7f6e-\u4e3b\u673a-\u5177\u4f53\u4e3b\u673a\u540d-Link with Template-\u65b0\u589e-\u521a\u5bfc\u5165\u7684\u6a21\u677f\u3002<\/p>\n<p>\u6a21\u677f\u5206\u4e3a\u4e09\u79cd\uff1a<\/p>\n<p>template MYSQL_server:\u76d1\u63a7\u9879\u6700\u5168<\/p>\n<p>template MYSQL_Replication_Master:\u53ea\u76d1\u63a7\u4e3b\u8981\u53c2\u6570\uff0c\u76d1\u63a7\u529f\u80fd\u76f8\u5bf9\u6700\u5c11<\/p>\n<p>template MYSQL_Replication_Slave:\u4e3b\u8981\u9488\u5bf9\u6027\u80fd\u65b9\u9762\u7684\u76d1\u63a7\u3002<\/p>\n<p><strong>\u4e03\u3001\u6d4b\u8bd5\u76d1\u63a7\u662f\u5426\u6210\u529f<\/strong><\/p>\n<p>\u5220\u9664\u3000\u5b9a\u65f6\u6587\u4ef6<\/p>\n<pre><ol><li>rm \/tmp\/.zabbix_mysql-debug.dtime;&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u53d6\u7684\u6bcf\u5929\u7684\u76d1\u63a7\u6570\u636e<\/p>\n<pre><ol><li>php \/etc\/zabbix\/mysql.php daily root *****&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u53d6\u5373\u65f6\u6570\u636e<\/p>\n<pre><ol><li>php \/etc\/zabbix\/mysql.php live root *****&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u67e5\u770b\u65e5\u5fd7<\/p>\n<pre><ol><li>cat \/tmp\/zabbix_mysql.log&nbsp; <li>&nbsp;<li>Info from server: \"Processed 1 Failed 0 Total 1 Seconds spent 0.006261\" <li>&nbsp;<li>sent: 1; skipped: 0; total: 1&nbsp; <li>&nbsp;<li>Info from server: \"Processed 1 Failed 0 Total 1 Seconds spent 0.004047\" <li>&nbsp;<li>sent: 1; skipped: 0; total: 1&nbsp; <li>&nbsp;<li>Info from server: \"Processed 0 Failed 106 Total 106 Seconds spent 0.045790\" <li>&nbsp;<li>sent: 106; skipped: 0; total: 106&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u770b\u5230\u4e0a\u8ff0\u4e3a\u6210\u529f<\/p>\n<p>\u67e5\u770bDAT\u7684\u6587\u4ef6\u3002\u4e0a\u4f20\u7684\u6570\u636e<\/p>\n<pre><ol><li>cat \/tmp\/zabbix_mysql.dat&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p><strong>\u516b\u3001\u6700\u540e\u67e5\u770bzabbix\u3000\u7684\u6700\u65b0\u6570\u636e<\/strong><\/p>\n<p>\u8fd9\u65f6\u4f1a\u770b\u5230\u65b0\u589e\u52a0\u7684\u76d1\u63a7\u9879\u3002<\/p>\n<p>\u63a5\u4e0b\u53bb\u5c31\u662f\u7ed8\u5236\u56fe\u5f62\u3002<\/p>\n<p>\u4f60\u4eec\u9080\u6309\u4e0a\u9762\u7684\u4e00\u6b65\u4e00\u6b65\u8d70\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7528zabbix\u8fdb\u884c\u5168\u5168\u9762\u76d1\u63a7mysql\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6dfb\u52a0nginx<\/p>\n<p>\u53c2\u8003url\uff1a<a title=\"http:\/\/john88wang.blog.51cto.com\/2165294\/1577269\" href=\"http:\/\/john88wang.blog.51cto.com\/2165294\/1577269\">http:\/\/john88wang.blog.51cto.com\/2165294\/1577269<\/a><\/p>\n<p>Nginx\u81ea\u5e26\u76d1\u63a7\u6a21\u5757ngx_http_stub_status_module\u63d0\u4f9bNginx\u7684\u57fa\u672c\u4fe1\u606f  <\/p>\n<p>\u5728\u7f16\u8bd1\u5b89\u88c5Nginx\u65f6\u52a0\u53c2\u6570 &#8211;with-http_stub_status_module&nbsp; <\/p>\n<p>\u5b89\u88c5\u597d\u4ee5\u540e\u53ef\u4ee5\u901a\u8fc7nginx -V|grep http_stub_status_module \u67e5\u770b\u72b6\u6001\u6a21\u5757\u662f\u5426\u5df2\u5b89\u88c5  <\/p>\n<p>PHP-FPM\u4e5f\u81ea\u5e26\u76d1\u63a7\uff0c\u901a\u8fc7\u5728php-fpm.conf\u4e2d\u8bbe\u7f6e  <\/p>\n<p>pm.status_path = \/php-fpm_status  <\/p>\n<p>\u5c31\u53ef\u4ee5\u83b7\u53d6URL\u7684\u65b9\u5f0f\u83b7\u53d6PHP-FPM\u7684\u72b6\u6001  <\/p>\n<p>\u53c2\u8003\u6587\u7ae0  <\/p>\n<p><a href=\"https:\/\/rtcamp.com\/tutorials\/php\/fpm-status-page\/\">https:\/\/rtcamp.com\/tutorials\/php\/fpm-status-page\/<\/a>  <\/p>\n<ol>\n<li>\n<p>\u6dfb\u52a0nginx_status.conf<\/p>\n<\/li>\n<\/ol>\n<p><code>server {<\/code>  <\/p>\n<p><code><\/code><code>listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 88 ;<\/code>  <\/p>\n<p><code><\/code><code>location \/nginx_status {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code><code>stub_status on;<\/code>  <\/p>\n<p><code><\/code><code>access_log off;<\/code>  <\/p>\n<p><code><\/code><code>allow 127.0.0.1;<\/code>  <\/p>\n<p><code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; allow 10.4.1.125;<\/code>  <\/p>\n<p><code><\/code><code>deny all;<\/code>  <\/p>\n<p><code><\/code><code>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>location \/php-fpm_status {<\/code>  <\/p>\n<p><code><\/code><code>fastcgi_pass 127.0.0.1:9000;<\/code>  <\/p>\n<p><code><\/code><code>fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<\/code>  <\/p>\n<p><code><\/code><code>include fastcgi_params;<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>$ curl&nbsp; 127.0.0.1:88\/nginx_status<\/code>  <\/p>\n<p><code>Active connections: 1 <\/code> <\/p>\n<p><code>server accepts handled requests<\/code>  <\/p>\n<p><code><\/code><code>788163 788163 788163 <\/code> <\/p>\n<p><code>Reading: 0 Writing: 1 Waiting: 0<\/code>  <\/p>\n<p>Active connections&nbsp;&nbsp;&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The current number of active client connections including <code>Waiting<\/code> connections.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u6d3b\u8dc3\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\uff0c\u5305\u62ec\u5904\u4e8e\u7b49\u5f85\u72b6\u6001\u7684\u8fde\u63a5\u6570  <\/p>\n<p><code>accepts<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The total number of accepted client connections.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u63a5\u6536\u5230\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u603b\u6570  <\/p>\n<p><code>handled<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The total number of handled connections. Generally, the parameter value is the same as <code>accepts<\/code> unless some resource limits have been reached&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5904\u7406\u8bf7\u6c42\u7684\u603b\u6570\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u503c\u548caccepts\u7684\u503c\u76f8\u540c\u3002\u9664\u975e\u8fbe\u5230\u4e86\u4e00\u4e9b\u8d44\u6e90\u9650\u5236\u3002\u4f8b\u5982\u8bbe\u7f6e<strong>worker_connections<\/strong> <em>1024\uff1b&nbsp; \u8bbe\u7f6e\u4e00\u4e2aworker\u8fdb\u7a0b\u80fd\u591f\u6253\u5f00\u7684\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u6570\u3002<\/em>  <\/p>\n<p><code>requests<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The total number of client requests.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5ba2\u6237\u7aef\u8bf7\u6c42\u603b\u6570  <\/p>\n<p><code>Reading<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The current number of connections where nginx is reading the request header.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5f53\u524dNginx\u6b63\u5728\u8bfb\u53d6\u8bf7\u6c42\u5934\u7684\u8fde\u63a5\u6570\u91cf  <\/p>\n<p><code>Writing<\/code>  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The current number of connections where nginx is writing the response back to the client.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5f53\u524dNginx\u6b63\u5728\u5c06\u54cd\u5e94\u5199\u56de\u5230\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u6570\u91cf  <\/p>\n<p><code>Waiting<\/code>  <\/p>\n<p>The current number of idle client connections waiting for a request.  <\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5f53\u524d\u6b63\u5728\u7b49\u5f85\u8bf7\u6c42\u7684\u95f2\u7f6e\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\u91cf  <\/p>\n<p><code>$ curl&nbsp; 127.0.0.1:88\/php-fpm_status<\/code>  <\/p>\n<p><code>pool:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; www<\/code>  <\/p>\n<p><code>process manager:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dynamic<\/code>  <\/p>\n<p><code>start time:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16\/Nov\/2014:13:29:11 +0800<\/code>  <\/p>\n<p><code>start since:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 77844<\/code>  <\/p>\n<p><code>accepted conn:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 202788<\/code>  <\/p>\n<p><code>listen queue:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>max listen queue:&nbsp;&nbsp;&nbsp;&nbsp; 1<\/code>  <\/p>\n<p><code>listen queue len:&nbsp;&nbsp;&nbsp;&nbsp; 128<\/code>  <\/p>\n<p><code>idle processes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6<\/code>  <\/p>\n<p><code>active processes:&nbsp;&nbsp;&nbsp;&nbsp; 1<\/code>  <\/p>\n<p><code>total processes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<\/code>  <\/p>\n<p><code>max active processes: 4<\/code>  <\/p>\n<p><code>max children reached: 0<\/code>  <\/p>\n<p><code>slow requests:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p>pool&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pool\u540d\u79f0  <\/p>\n<p>process manager&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static or dynamic  <\/p>\n<p>start time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u542f\u52a8\u65f6\u95f4  <\/p>\n<p>start since&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u542f\u52a8\u4e86\u591a\u957f\u65f6\u95f4\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d  <\/p>\n<p>accepted conn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pool\u63a5\u6536\u5230\u7684\u8bf7\u6c42\u6570\u91cf  <\/p>\n<p><strong>listen queue<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of request in the queue of pending connections.\u8fd9\u4e2a\u503c\u5982\u679c\u4e0d\u4e3a0\uff0c\u6700\u597d\u589e\u52a0PHP-FPM\u7684\u8fdb\u7a0b\u6570\u91cf  <\/p>\n<p><strong>max listen queue<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the maximum number of requests in the queue of pending connections since FPM has started  <\/p>\n<p><strong>listen queue len<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the size of the socket queue of pending connections  <\/p>\n<p><strong>idle processes<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of idle processes  <\/p>\n<p><strong>active processes<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of active processes  <\/p>\n<p><strong>total processes<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the number of idle + active processes  <\/p>\n<p><strong>max active processes<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the maximum number of active processes since FPM has started  <\/p>\n<p><strong>max children reached&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/strong>number of times, the process limit has been reached, when pm tries to start more children. If that value is not zero, then you may need to increase max process limit for your PHP-FPM pool. Like this, you can find other useful information to tweak your pool better way.\u5982\u679c\u8fd9\u4e2a\u503c\u4e0d\u4e3a0\uff0c\u6700\u597d\u589e\u5927\u6700\u5927\u8fdb\u7a0b\u7684\u9650\u5236\u3002  <\/p>\n<p><strong>slow requests<\/strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5982\u679c\u8fd9\u4e2a\u503c\u4e0d\u4e3a0\uff0c\u8868\u793a\u6709\u5904\u7406\u6162\u7684\u7a0b\u5e8f  <\/p>\n<p>&nbsp; <\/p>\n<p><code>$ curl 127.0.0.1:88\/php-fpm_status?full<\/code>  <\/p>\n<p><code>pool:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; www<\/code>  <\/p>\n<p><code>process manager:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dynamic<\/code>  <\/p>\n<p><code>start time:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 17\/Nov\/2014:16:09:17 +0800<\/code>  <\/p>\n<p><code>start since:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1139<\/code>  <\/p>\n<p><code>accepted conn:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3354<\/code>  <\/p>\n<p><code>listen queue:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>max listen queue:&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>listen queue len:&nbsp;&nbsp;&nbsp;&nbsp; 128<\/code>  <\/p>\n<p><code>idle processes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5<\/code>  <\/p>\n<p><code>active processes:&nbsp;&nbsp;&nbsp;&nbsp; 1<\/code>  <\/p>\n<p><code>total processes:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6<\/code>  <\/p>\n<p><code>max active processes: 2<\/code>  <\/p>\n<p><code>max children reached: 0<\/code>  <\/p>\n<p><code>slow requests:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>************************<\/code>  <\/p>\n<p><code>pid:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19921<\/code>  <\/p>\n<p><code>state:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Idle<\/code>  <\/p>\n<p><code>start time:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 17\/Nov\/2014:16:09:17 +0800<\/code>  <\/p>\n<p><code>start since:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1139<\/code>  <\/p>\n<p><code>requests:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 563<\/code>  <\/p>\n<p><code>request duration:&nbsp;&nbsp;&nbsp;&nbsp; 223<\/code>  <\/p>\n<p><code>request method:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GET<\/code>  <\/p>\n<p><code>request URI:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/php-fpm_status<\/code>  <\/p>\n<p><code>content length:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0<\/code>  <\/p>\n<p><code>user:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<\/code>  <\/p>\n<p><code>script:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<\/code>  <\/p>\n<p><code>last request cpu:&nbsp;&nbsp;&nbsp;&nbsp; 0.00<\/code>  <\/p>\n<p><code>last request memory:&nbsp; 262144<\/code>  <\/p>\n<p>curl 127.0.0.1:88\/php-fpm_status?json  <\/p>\n<p>curl 127.0.0.1:88\/php-fpm_status?html  <\/p>\n<p>curl 127.0.0.1:88\/php-fpm_status?xml  <\/p>\n<p>2.\u7f16\u5199Nginx\u548cPHP-FPM\u72b6\u6001\u4fe1\u606f\u83b7\u53d6\u811a\u672c  <\/p>\n<p>nginx_status.sh  <\/p>\n<p><code>#!\/bin\/bash<\/code>  <\/p>\n<p><code>#check nginx status<\/code>  <\/p>\n<p><code>#ip=$(ifconfig eth0|grep \"inet addr\"|sed&nbsp; 's\/^.*addr:\/\/'|awk '{print $1}')<\/code>  <\/p>\n<p><code>#echo $ip<\/code>  <\/p>\n<p><code>ip=127.0.0.1<\/code>  <\/p>\n<p><code>port=88<\/code>  <\/p>\n<p><code>#echo $ip:$port<\/code>  <\/p>\n<p><code>function active()&nbsp; {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|grep \"Active\"|awk '{print $NF}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function reading() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|grep \"Reading\"|awk '{print $2}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function writing() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|grep \"Writing\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function waiting() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|grep \"Waiting\"|awk '{print $6}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function accepts() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|awk 'NR==3{print $1}'&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function handled() {<\/code>  <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|awk 'NR==3{print $2}'&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function requests(){<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/nginx_status 2&gt;\/dev\/null|awk 'NR==3{print $3}'&nbsp;&nbsp; <\/code> <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>case $1 in<\/code>  <\/p>\n<p><code><\/code><code>active)<\/code>  <\/p>\n<p><code><\/code><code>active<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>reading)<\/code>  <\/p>\n<p><code><\/code><code>reading<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>writing)<\/code>  <\/p>\n<p><code><\/code><code>writing<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>waiting)<\/code>  <\/p>\n<p><code><\/code><code>waiting<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>accepts)<\/code>  <\/p>\n<p><code><\/code><code>accepts<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>handled)<\/code>  <\/p>\n<p><code><\/code><code>handled<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>requests)<\/code>  <\/p>\n<p><code><\/code><code>requests<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code><\/code><code>*)<\/code>  <\/p>\n<p><code><\/code><code>exit 1<\/code>  <\/p>\n<p><code><\/code><code>;;<\/code>  <\/p>\n<p><code>esac<\/code>  <\/p>\n<p>php-fpm_status.sh  <\/p>\n<p><code>#!\/bin\/bash<\/code>  <\/p>\n<p><code>#check php-fpm status<\/code>  <\/p>\n<p><code>ip=127.0.0.1<\/code>  <\/p>\n<p><code>port=88<\/code>  <\/p>\n<p><code>function idle()&nbsp; {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"idle processes\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function active() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"active processes\"|awk '{print $3}'|grep -v \"processes\"<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function total() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"total processes\"|awk '{print $3}'|grep -v \"processes\"<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function mactive() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"max active processes\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function conn()&nbsp;&nbsp;&nbsp; {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"accepted conn\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function since() {<\/code>  <\/p>\n<p><code><\/code> <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"start since\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function slow()&nbsp;&nbsp; {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"slow requests\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function listenqueue() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"listen queue:\"|grep -v \"max\"|awk '{print $3}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function maxlistenqueue() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"max listen queue:\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function listenqueuelen() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"listen queue len:\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>function maxchildren() {<\/code>  <\/p>\n<p><code><\/code><code>\/usr\/bin\/curl http:\/\/$ip:$port\/php-fpm_status 2&gt;\/dev\/null|grep \"max children reached:\"|awk '{print $4}'<\/code>  <\/p>\n<p><code><\/code><code>}<\/code>  <\/p>\n<p><code>$1<\/code>  <\/p>\n<p>3.\u6dfb\u52a0zabbix\u7684\u5b50\u914d\u7f6e\u6587\u4ef6  <\/p>\n<p>nginx_status_zabbix.conf  <\/p>\n<p><code>### Option: UserParameter<\/code>  <\/p>\n<p><code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; User-defined parameter to monitor. There can be several user-defined parameters.<\/code>  <\/p>\n<p><code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Format: UserParameter=&lt;key&gt;,&lt;shell command&gt;<\/code>  <\/p>\n<p><code>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; See 'zabbix_agentd' directory for examples.<\/code>  <\/p>\n<p><code>#<\/code>  <\/p>\n<p><code># Mandatory: no<\/code>  <\/p>\n<p><code># Default:<\/code>  <\/p>\n<p><code># UserParameter=<\/code>  <\/p>\n<p><code># \/usr\/local\/zabbix\/bin\/nginx_status.sh<\/code>  <\/p>\n<p><code>UserParameter=nginx.accepts,\/usr\/local\/zabbix\/bin\/nginx_status.sh accepts<\/code>  <\/p>\n<p><code>UserParameter=nginx.handled,\/usr\/local\/zabbix\/bin\/nginx_status.sh handled<\/code>  <\/p>\n<p><code>UserParameter=nginx.requests,\/usr\/local\/zabbix\/bin\/nginx_status.sh requests<\/code>  <\/p>\n<p><code>UserParameter=nginx.connections.active,\/usr\/local\/zabbix\/bin\/nginx_status.sh active<\/code>  <\/p>\n<p><code>UserParameter=nginx.connections.reading,\/usr\/local\/zabbix\/bin\/nginx_status.sh reading<\/code>  <\/p>\n<p><code>UserParameter=nginx.connections.writing,\/usr\/local\/zabbix\/bin\/nginx_status.sh writing<\/code>  <\/p>\n<p><code>UserParameter=nginx.connections.waiting,\/usr\/local\/zabbix\/bin\/nginx_status.sh waiting<\/code>  <\/p>\n<p>php-fpm_status.conf  <\/p>\n<p><code>UserParameter=php-fpm.idle.processes,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh idle<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.total.processes,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh total<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.active.processes,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh active<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.max.active.processes,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh mactive<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.listen.queue.len,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh listenqueuelen<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.listen.queue,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh listenqueue<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.start.since,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh since<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.accepted.conn,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh conn<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.slow.requests,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh slow<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.max.listen.queue,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh maxlistenqueue<\/code>  <\/p>\n<p><code>UserParameter=php-fpm.max.children,\/usr\/local\/zabbix\/bin\/php-fpm_status.sh maxchildren<\/code>  <\/p>\n<p>4.\u6dfb\u52a0zabbix\u76d1\u63a7\u6a21\u677f  <\/p>\n<p>\u6a21\u677f\u53c2\u89c1\u9644\u4ef6<\/p>\n<p>&nbsp;<\/p>\n<p>mysql \u7684\u6a21\u677f \u5728<a title=\"https:\/\/github.com\/zbal\/zabbix\/tree\/master\/server_template\" href=\"https:\/\/github.com\/zbal\/zabbix\/tree\/master\/server_template\">https:\/\/github.com\/zbal\/zabbix\/tree\/master\/server_template<\/a><\/p>\n<p>\u4ee5\u524d\u7684\u6211\u8bb0\u5f97\u662f\u901a\u8fc7php\u83b7\u53d6\u7684\uff0c\u627e\u4e0d\u5230\u4e86\u8fd9\u4e2a\u76f4\u63a5\u901a\u8fc7mysql \u5ba2\u6237\u7aef\u83b7\u53d6\u7684<\/p>\n<p>\u540e\u6765\u53d1\u73b0\u627e\u4e0d\u5230 \u539f\u6765\u662f\u56e0\u4e3a\u5b98\u7f51 \u5220\u9664\u4e86\u7f51\u9875\u4e86 \u6211\u65e5\u554a<\/p>\n<p><a title=\"http:\/\/os.51cto.com\/art\/201104\/253006_all.htm\" href=\"http:\/\/os.51cto.com\/art\/201104\/253006_all.htm\">http:\/\/os.51cto.com\/art\/201104\/253006_all.htm<\/a>&nbsp; \u539f\u6765\u7684\u5b89\u88c5\u65b9\u6cd5\u3002<\/p>\n<p><strong>zabbix<\/strong>\u5168\u9762\u76d1\u63a7<strong>mysql<\/strong>\u5b9e\u65bd\u8d77\u6765\u8fd8\u662f\u6bd4\u8f83\u7ed9\u529b\u7684\uff01 <\/p>\n<p><strong>\u4e00\u3001\u4ece\u7f51\u4e0a\u4e0b\u8f7d\u76f8\u5e94\u811a\u672c\u4e0eXML\u5b9a\u4e49\u6587\u4ef6\u3002<\/strong> <\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1ahttp:\/\/www.zabbix.com\/wiki\/doku.php?id=extensive_mysql_monitoring_including_replication<\/p>\n<pre><ol><li>Template_MySQL_Server.xml&nbsp; <li>&nbsp;<li>Template_MySQL_Replication_Master.xml&nbsp; <li>&nbsp;<li>Template_MySQL_Replication_Slave.xml&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u548c\u6267\u884c\u811a\u672c\uff1amysql.php<\/p>\n<p><strong>\u4e8c\u3001\u628amysql.php\u4e0a\u4f20\u81f3\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55\/etc\/zabbix\/<\/strong><\/p>\n<pre><ol><li>chmod 755 mysql.php&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p><strong>\u4e09\u3001\u4fee\u6539mysql.php\u6587\u4ef6<\/strong><\/p>\n<p>\u6839\u636e\u672c\u673a\u73af\u5883\u3002<\/p>\n<p>\u7b2c\u4e00\u884c\u52a0\u5165\uff1a#!\/usr\/bin\/php<\/p>\n<p>\u5728\u6700\u540e\u4e00\u884c\u52a0\u5165\uff1a?&gt;<\/p>\n<p>\u5173\u95ed\u8c03\u8bd5\uff1adefine(&#8216;DEBUG&#8217;,true);\u3000\u4e3a\u3000define(&#8216;DEBUG&#8217;,False);<\/p>\n<p>\u4fee\u6539\u65e5\u5fd7\u3001\u6570\u636e\u6587\u4ef6\u8def\u5f84\uff1a<\/p>\n<pre><ol><li>define('LOG',\"\/tmp\/zabbix_\".SYSTEM.\".log\");&nbsp; <li>&nbsp;<li>define('DAT',\"\/tmp\/zabbix_\".SYSTEM.\".dat\");&nbsp; <li>&nbsp;<li>define('UTIME',\"\/tmp\/.zabbix_\".SYSTEM.\".utime\");&nbsp; <li>&nbsp;<li>define('DTIME',\"\/tmp\/.zabbix_\".SYSTEM.\".dtime\");&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u4fee\u6539\uff1adefine(&#8216;SYSTEM&#8217;,&#8217;mysql&#8217;.(DEBUG ? &#8220;-debug&#8221; : &#8220;&#8221;)); \u4e3a\uff1adefine(&#8216;SYSTEM&#8217;,&#8217;mysql&#8217;);<\/p>\n<p>\u6253\u5f00\u7cfb\u7edf\u65e5\u5fd7\u529f\u80fd\uff1a\/\/system(&#8220;zabbix_sender -z $server -i &#8220;.DAT.&#8221; &gt;&gt; &#8220;.LOG);\u3000\u4e3a\uff1asystem(&#8220;zabbix_sender -z $server -i &#8220;.DAT.&#8221; &gt;&gt; &#8220;.LOG);<\/p>\n<p>\u5728$cmd = &#8220;zabbix_sender -z $server -p 10051 -s $host -k &#8220;.SYSTEM.&#8221;.$var -o $val&#8221;;<\/p>\n<p>\u4e0b\u9762\u589e\u52a0\u4e00\u884c\uff1aexec($cmd);<\/p>\n<p><strong>\u56db\u3001\u5728zabbix_agentd.conf\u914d\u7f6e\u6587\u4ef6\u4e2d\u52a0\u5165<\/strong><\/p>\n<p>UserParameter=mysql.daily,php \/etc\/zabbix\/mysql.php daily \u7528\u6237\u540d \u5bc6\u7801<\/p>\n<p>UserParameter=mysql.live,php \/etc\/zabbix\/mysql.php live \u7528\u6237\u540d\u3000\u5bc6\u7801<\/p>\n<p>daily:\u6bcf\u5929\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<p>live:\u6309\u6307\u5b9a\u65f6\u95f4\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<p>php :\u6267\u884cphp\u6587\u4ef6<\/p>\n<p>\/etc\/zabbix\/mysql.php:mysql.php\u6587\u4ef6\u6240\u5728\u7684\u6587\u4ef6\u8def\u5f84<\/p>\n<p>\u7528\u6237\u540d\u3000\u5bc6\u7801\uff1a\u767b\u5f55mysql\u6570\u636e\u5e93\u7684\u8d26\u6237\u4e0e\u5bc6\u7801<\/p>\n<p>\u91cd\u542fzabbix_agentd<\/p>\n<p><strong>\u4e94\u3001\u5728zabbix web\u7ba1\u7406\u754c\u9762\u5bfc\u5165xml\u6587\u4ef6<\/strong><\/p>\n<p>\u914d\u7f6e-\u5bfc\u5165\/\u5bfc\u51fa-\u6d4f\u89c8<\/p>\n<p><strong>\u516d\u3001\u5728\u4e3b\u673a\u5185\u589e\u52a0\u6307\u5b9a\u6a21\u677f<\/strong><\/p>\n<p>\u914d\u7f6e-\u4e3b\u673a-\u5177\u4f53\u4e3b\u673a\u540d-Link with Template-\u65b0\u589e-\u521a\u5bfc\u5165\u7684\u6a21\u677f\u3002<\/p>\n<p>\u6a21\u677f\u5206\u4e3a\u4e09\u79cd\uff1a<\/p>\n<p>template MYSQL_server:\u76d1\u63a7\u9879\u6700\u5168<\/p>\n<p>template MYSQL_Replication_Master:\u53ea\u76d1\u63a7\u4e3b\u8981\u53c2\u6570\uff0c\u76d1\u63a7\u529f\u80fd\u76f8\u5bf9\u6700\u5c11<\/p>\n<p>template MYSQL_Replication_Slave:\u4e3b\u8981\u9488\u5bf9\u6027\u80fd\u65b9\u9762\u7684\u76d1\u63a7\u3002<\/p>\n<p><strong>\u4e03\u3001\u6d4b\u8bd5\u76d1\u63a7\u662f\u5426\u6210\u529f<\/strong><\/p>\n<p>\u5220\u9664\u3000\u5b9a\u65f6\u6587\u4ef6<\/p>\n<pre><ol><li>rm \/tmp\/.zabbix_mysql-debug.dtime;&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u53d6\u7684\u6bcf\u5929\u7684\u76d1\u63a7\u6570\u636e<\/p>\n<pre><ol><li>php \/etc\/zabbix\/mysql.php daily root *****&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u53d6\u5373\u65f6\u6570\u636e<\/p>\n<pre><ol><li>php \/etc\/zabbix\/mysql.php live root *****&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u67e5\u770b\u65e5\u5fd7<\/p>\n<pre><ol><li>cat \/tmp\/zabbix_mysql.log&nbsp; <li>&nbsp;<li>Info from server: \"Processed 1 Failed 0 Total 1 Seconds spent 0.006261\" <li>&nbsp;<li>sent: 1; skipped: 0; total: 1&nbsp; <li>&nbsp;<li>Info from server: \"Processed 1 Failed 0 Total 1 Seconds spent 0.004047\" <li>&nbsp;<li>sent: 1; skipped: 0; total: 1&nbsp; <li>&nbsp;<li>Info from server: \"Processed 0 Failed 106 Total 106 Seconds spent 0.045790\" <li>&nbsp;<li>sent: 106; skipped: 0; total: 106&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p>\u770b\u5230\u4e0a\u8ff0\u4e3a\u6210\u529f<\/p>\n<p>\u67e5\u770bDAT\u7684\u6587\u4ef6\u3002\u4e0a\u4f20\u7684\u6570\u636e<\/p>\n<pre><ol><li>cat \/tmp\/zabbix_mysql.dat&nbsp; <li>&nbsp;<\/li><\/ol><\/pre>\n<p><strong>\u516b\u3001\u6700\u540e\u67e5\u770bzabbix\u3000\u7684\u6700\u65b0\u6570\u636e<\/strong><\/p>\n<p>\u8fd9\u65f6\u4f1a\u770b\u5230\u65b0\u589e\u52a0\u7684\u76d1\u63a7\u9879\u3002<\/p>\n<p>\u63a5\u4e0b\u53bb\u5c31\u662f\u7ed8\u5236\u56fe\u5f62\u3002<\/p>\n<p>\u4f60\u4eec\u9080\u6309\u4e0a\u9762\u7684\u4e00\u6b65\u4e00\u6b65\u8d70\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7528zabbix\u8fdb\u884c\u5168\u5168\u9762\u76d1\u63a7mysql\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[90,91],"class_list":["post-4343","post","type-post","status-publish","format-standard","hentry","category-5","tag-mysql","tag-nginx","category-5-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4343"}],"version-history":[{"count":5,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4343\/revisions"}],"predecessor-version":[{"id":4352,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4343\/revisions\/4352"}],"wp:attachment":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}