From 562f90bb6d4319c60ba18de0a218d316ce026a10 Mon Sep 17 00:00:00 2001 From: eBuildy Date: Mon, 2 Jun 2014 22:52:25 +0200 Subject: [PATCH 1/2] Fix awk issue the awk match method doesnt not work on my debian. --- php-fpm/php-fpm-check.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/php-fpm/php-fpm-check.sh b/php-fpm/php-fpm-check.sh index 62faa91..a796e19 100755 --- a/php-fpm/php-fpm-check.sh +++ b/php-fpm/php-fpm-check.sh @@ -50,12 +50,17 @@ fi # # Extract data from nginx stats # -RESULT=$(echo "$NGINX_STATS" | awk 'match($0, "^'"$ZBX_REQ_DATA"':[[:space:]]+(.*)", a) { print a[1] }') -if [ $? -ne 0 -o -z "$RESULT" ]; then - echo $ERROR_WRONG_PARAM - exit 1 -fi - -echo $RESULT +case $ZBX_REQ_DATA in +'accepted conn') echo "$NGINX_STATS" | grep '^accepted conn:' | cut -f2 -d ':' | sed 's/\s//g';; +'active processes') echo "$NGINX_STATS" | grep '^active processes:' | cut -f2 -d ':' | sed 's/\s//g';; +'idle processes') echo "$NGINX_STATS" | grep '^idle processes:' | cut -f2 -d ':' | sed 's/\s//g';; +'listen queue len') echo "$NGINX_STATS" | grep '^listen queue len:' | cut -f2 -d ':' | sed 's/\s//g';; +'listen queue') echo "$NGINX_STATS" | grep '^listen queue:' | cut -f2 -d ':' | sed 's/\s//g';; +'max active processes') echo "$NGINX_STATS" | grep '^max active processes:' | cut -f2 -d ':' | sed 's/\s//g';; +'max children reached') echo "$NGINX_STATS" | grep '^max children reached:' | cut -f2 -d ':' | sed 's/\s//g';; +'max listen queue') echo "$NGINX_STATS" | grep '^max listen queue:' | cut -f2 -d ':' | sed 's/\s//g';; +'total processes') echo "$NGINX_STATS" | grep '^active processes:' | cut -f2 -d ':' | sed 's/\s//g';; +*) echo $ERROR_WRONG_PARAM; exit 1;; +esac exit 0 From 79c8de837d4e62ba09cecd4f998dc3c6b61eb55f Mon Sep 17 00:00:00 2001 From: eBuildy Date: Tue, 3 Jun 2014 13:29:51 +0200 Subject: [PATCH 2/2] Fix wrong copy/paste ^^ --- php-fpm/php-fpm-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-fpm/php-fpm-check.sh b/php-fpm/php-fpm-check.sh index a796e19..95b30c7 100755 --- a/php-fpm/php-fpm-check.sh +++ b/php-fpm/php-fpm-check.sh @@ -59,7 +59,7 @@ case $ZBX_REQ_DATA in 'max active processes') echo "$NGINX_STATS" | grep '^max active processes:' | cut -f2 -d ':' | sed 's/\s//g';; 'max children reached') echo "$NGINX_STATS" | grep '^max children reached:' | cut -f2 -d ':' | sed 's/\s//g';; 'max listen queue') echo "$NGINX_STATS" | grep '^max listen queue:' | cut -f2 -d ':' | sed 's/\s//g';; -'total processes') echo "$NGINX_STATS" | grep '^active processes:' | cut -f2 -d ':' | sed 's/\s//g';; +'total processes') echo "$NGINX_STATS" | grep '^total processes:' | cut -f2 -d ':' | sed 's/\s//g';; *) echo $ERROR_WRONG_PARAM; exit 1;; esac