diff --git a/nginx/default.conf b/nginx/default.conf index 20e807a..fd5d5aa 100644 --- a/nginx/default.conf +++ b/nginx/default.conf @@ -16,7 +16,7 @@ server { root /usr/share/nginx/html; } - location /status { + location /stub_status { stub_status on; access_log off; allow 127.0.0.1; diff --git a/nginx/nginx.sh b/nginx/nginx.sh index e60d964..9d5417e 100644 --- a/nginx/nginx.sh +++ b/nginx/nginx.sh @@ -9,31 +9,32 @@ HOST="localhost" PORT="80" +stub_status=stub_status function check() { /sbin/pidof nginx | wc -l } function active() { - /usr/bin/curl -s "http://$HOST:$PORT/status/" 2>/dev/null| grep 'Active' | awk '{print $NF}' + /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Active' | awk '{print $NF}' } function accepts() { - /usr/bin/curl -s "http://$HOST:$PORT/status/" 2>/dev/null| awk NR==3 | awk '{print $1}' + /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $1}' } function handled() { - /usr/bin/curl -s "http://$HOST:$PORT/status/" 2>/dev/null| awk NR==3 | awk '{print $2}' + /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $2}' } function requests() { - /usr/bin/curl -s "http://$HOST:$PORT/status/" 2>/dev/null| awk NR==3 | awk '{print $3}' + /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $3}' } function reading() { - /usr/bin/curl -s "http://$HOST:$PORT/status/" 2>/dev/null| grep 'Reading' | awk '{print $2}' + /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Reading' | awk '{print $2}' } function writing() { - /usr/bin/curl -s "http://$HOST:$PORT/status/" 2>/dev/null| grep 'Writing' | awk '{print $4}' + /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Writing' | awk '{print $4}' } function waiting() { - /usr/bin/curl -s "http://$HOST:$PORT/status/" 2>/dev/null| grep 'Waiting' | awk '{print $6}' + /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Waiting' | awk '{print $6}' } case "$1" in diff --git a/nginx/userparameter_nginx.conf b/nginx/userparameter_nginx.conf index 63c63e6..13f64d7 100644 --- a/nginx/userparameter_nginx.conf +++ b/nginx/userparameter_nginx.conf @@ -1,5 +1,5 @@ ############################################################ -# Nginx - statistics +# Netkiller Nginx - statistics # # Author: Neo Chen # Website: http://www.netkiller.cn @@ -7,5 +7,5 @@ # Discovery -# Return Redis statistics +# Return statistics UserParameter=nginx.status[*],/srv/zabbix/libexec/nginx.sh $1 \ No newline at end of file diff --git a/php-fpm/default.conf b/php-fpm/default.conf new file mode 100644 index 0000000..eab2ddf --- /dev/null +++ b/php-fpm/default.conf @@ -0,0 +1,33 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + location /stub_status { + stub_status on; + access_log off; + allow 127.0.0.1; + deny all; + } + location ~ ^/(status|ping)$ { + access_log off; + allow 127.0.0.1; + deny all; + fastcgi_pass 127.0.0.1:9000; + fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/php-fpm/php-fpm.sh b/php-fpm/php-fpm.sh new file mode 100644 index 0000000..60989fa --- /dev/null +++ b/php-fpm/php-fpm.sh @@ -0,0 +1,23 @@ +#!/bin/bash +################################################## +# AUTHOR: Neo +# WEBSITE: http://www.netkiller.cn +# Description:zabbix 通过 status 模块监控 php-fpm +# Note:Zabbix 3.2 +# DateTime: 2016-11-22 +################################################## + +HOST="localhost" +PORT="80" +status="status" + +function query() { + curl -s http://${HOST}:${PORT}/${status} | grep "$1" | cut -d : -f 2 | awk '{print $1}' +} + +if [ $# == 0 ]; then + echo $"Usage $0 {check|active|accepts|handled|requests|reading|writing|waiting}" + exit +else + query "$1" +fi \ No newline at end of file diff --git a/php-fpm/userparameter_php-fpm.conf b/php-fpm/userparameter_php-fpm.conf new file mode 100644 index 0000000..b69f32c --- /dev/null +++ b/php-fpm/userparameter_php-fpm.conf @@ -0,0 +1,11 @@ +############################################################ +# Netkiller PHP-FPM - statistics +# +# Author: Neo Chen +# Website: http://www.netkiller.cn +############################################################ + +# Discovery + +# Return statistics +UserParameter=php-fpm.status[*],/srv/zabbix/libexec/php-fpm.sh $1 \ No newline at end of file diff --git a/php-fpm/zbx_export_templates.xml b/php-fpm/zbx_export_templates.xml new file mode 100644 index 0000000..bd61923 --- /dev/null +++ b/php-fpm/zbx_export_templates.xml @@ -0,0 +1,727 @@ + + + 3.2 + 2016-11-25T09:30:00Z + + + Templates + + + + + + + + {Template App PHP-FPM:proc.num[php-fpm,,,].last()}=0 + php-fpm was down! + + 0 + 4 + PHP-FPM process count: 0 + 0 + + 0 + + 0 + + 0 + + + + + + php-fpm processes + 900 + 200 + 0.0000 + 100.0000 + 1 + 1 + 0 + 1 + 0 + 0.0000 + 0.0000 + 0 + 0 + 0 + 0 + + + 0 + 0 + 00C800 + 0 + 2 + 0 + + Template App PHP-FPM + php-fpm.status[active-processes] + + + + 1 + 0 + C80000 + 0 + 2 + 0 + + Template App PHP-FPM + php-fpm.status[idle-processes] + + + + 2 + 0 + 0000C8 + 0 + 2 + 0 + + Template App PHP-FPM + php-fpm.status[max-active-processes] + + + + 3 + 0 + C800C8 + 0 + 2 + 0 + + Template App PHP-FPM + php-fpm.status[total-processes] + + + + + + php-fpm slow requests + 900 + 200 + 0.0000 + 100.0000 + 1 + 1 + 0 + 1 + 0 + 0.0000 + 0.0000 + 0 + 0 + 0 + 0 + + + 0 + 0 + 00C800 + 0 + 2 + 0 + + Template App PHP-FPM + php-fpm.status[slow-requests] + + + + + + php listen queue + 900 + 200 + 0.0000 + 100.0000 + 1 + 1 + 0 + 1 + 0 + 0.0000 + 0.0000 + 0 + 0 + 0 + 0 + + + 0 + 0 + 00C800 + 0 + 2 + 0 + + Template App PHP-FPM + php-fpm.status[listen-queue] + + + + 1 + 0 + C80000 + 0 + 2 + 0 + + Template App PHP-FPM + php-fpm.status[listen-queue-len] + + + + 2 + 0 + 0000C8 + 0 + 2 + 0 + + Template App PHP-FPM + php-fpm.status[max-listen-queue] + + + + + +