Skip to content

Instantly share code, notes, and snippets.

@kapb14
Created July 2, 2018 15:04
Show Gist options
  • Select an option

  • Save kapb14/2c254f65dc5b39b167330270665d5df4 to your computer and use it in GitHub Desktop.

Select an option

Save kapb14/2c254f65dc5b39b167330270665d5df4 to your computer and use it in GitHub Desktop.
php fpm status commandline script with pool name as argument
#!/bin/bash
if [[ -z $1 ]]; then
pool_name="www"
elif [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] || [[ "$1" == "help" ]]; then
echo "Usage: $(basename $0) [FPM_POOL_NAME]"
exit 1
elif [[ "$1" == "--list" ]] || [[ "$1" == "-l" ]] || [[ "$1" == "list" ]]; then
for p in $(grep -h "^\[" /etc/php/7.1/fpm/pool.d/*.conf | tr -d '[|]'); do
echo " ${p}"
done
exit 1
else
pool_name="$1"
fi
pool_config=$(grep -l "^\[${pool_name}" /etc/php/7.1/fpm/pool.d/*.conf)
pool_listener=$(grep -h '^listen =' ${pool_config} | awk $'{print $3}')
cat <<EOF
pool name: ${pool_name}
pool config: ${pool_config}
pool listener: ${pool_listener}
EOF
SCRIPT_NAME=/status SCRIPT_FILENAME=/status REQUEST_METHOD=GET QUERY_STRING="" /usr/bin/cgi-fcgi -bind -connect ${pool_listener}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment