Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix awk issue #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions php-fpm/php-fpm-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 '^total processes:' | cut -f2 -d ':' | sed 's/\s//g';;
*) echo $ERROR_WRONG_PARAM; exit 1;;
esac

exit 0