2019-08-13 10:32:59 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#Ramil Valitov ramilvalitov@gmail.com
|
|
|
|
#https://github.com/rvalitov/zabbix-php-fpm
|
2019-12-19 12:02:16 +01:00
|
|
|
#Script gets status of PHP-FPM pool
|
2019-08-13 10:32:59 +02:00
|
|
|
|
2019-11-26 16:15:39 +01:00
|
|
|
S_FCGI=`type -P cgi-fcgi`
|
|
|
|
S_GREP=`type -P grep`
|
2020-01-17 19:47:39 +01:00
|
|
|
S_ECHO=`type -P echo`
|
2019-08-13 10:32:59 +02:00
|
|
|
|
|
|
|
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"
|
2019-11-26 16:26:21 +01:00
|
|
|
echo "Usage: $0 php-path status"
|
2019-08-13 10:32:59 +02:00
|
|
|
echo "where:"
|
2019-11-26 16:26:21 +01:00
|
|
|
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"
|
2019-08-13 10:32:59 +02:00
|
|
|
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`
|
2020-01-17 19:47:39 +01:00
|
|
|
$S_ECHO "$PHP_STATUS" | $S_GREP "{"
|
|
|
|
exit 0
|