mirror of
https://github.com/rvalitov/zabbix-php-fpm.git
synced 2023-11-05 03:30:27 +01:00
2210d3bbd5
## Fix (all problems specified in issue #12) - **More robust method to discover sockets** (when PHP pool uses sockets). Script performs automatic checks of socket files (the file exists and is really a socket). - **More robust method to discover host and port** (when PHP pool uses TCP connection). - **Support of pools when PHP daemon listens on any network interface**. This mode is activated when in PHP pool configuration the `listen` command specifies only a port, without a host IP, for example: ``` listen = 9000 ``` - **Correct discovery of pools in some cases.** The script performs analysis of all processes that belong to the pool. Previously, we checked only the first process, as a result if a pool somehow had multiple processes (for example Memcached, Redis, PostgreSQL) then discovery could capture wrong data. Now this problem is fixed. - **Improved detection of pools**. We use better expressions in `grep` now. Previously special characters in pool names could lead to script failures. Besides such approach is a more robust method to fix #10. ## New functionality - **Debug mode** of the discovery script helps to investigate problems that may happen
37 lines
1.0 KiB
Bash
37 lines
1.0 KiB
Bash
#!/bin/bash
|
|
#Ramil Valitov ramilvalitov@gmail.com
|
|
#https://github.com/rvalitov/zabbix-php-fpm
|
|
#Script gets status of PHP-FPM pool
|
|
|
|
S_FCGI=`type -P cgi-fcgi`
|
|
S_GREP=`type -P grep`
|
|
|
|
if [[ ! -f $S_FCGI ]]; then
|
|
echo "Utility 'cgi-fcgi' not found. Please, install it first."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f $S_GREP ]]; then
|
|
echo "Utility 'grep' not found. Please, install it first."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z $1 ]] || [[ -z $2 ]]; then
|
|
echo "No input data specified"
|
|
echo "Usage: $0 php-path status"
|
|
echo "where:"
|
|
echo "php-path - path to socket file, for example, /var/lib/php7.3-fpm/web1.sock"
|
|
echo "or IP and port of the PHP-FPM, for example, 127.0.0.1:9000"
|
|
echo "status - path configured in pm.status of PHP-FPM"
|
|
exit 1
|
|
fi
|
|
|
|
POOL_URL=$1
|
|
POOL_PATH=$2
|
|
#connecting to socket or address, https://easyengine.io/tutorials/php/directly-connect-php-fpm/
|
|
PHP_STATUS=`SCRIPT_NAME=$POOL_PATH \
|
|
SCRIPT_FILENAME=$POOL_PATH \
|
|
QUERY_STRING=json \
|
|
REQUEST_METHOD=GET \
|
|
$S_FCGI -bind -connect $POOL_URL 2>/dev/null`
|
|
echo "$PHP_STATUS" | $S_GREP "{" |