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
2020-02-06 23:11:57 +01:00
S_FCGI = $( type -P cgi-fcgi)
S_GREP = $( type -P grep)
2020-09-21 00:49:37 +02:00
S_CAT = $( type -P cat)
2019-08-13 10:32:59 +02:00
2020-09-21 00:49:37 +02:00
if [ [ ! -x $S_CAT ] ] ; then
echo "Utility 'cat' not found. Please, install it first."
exit 1
fi
2020-07-06 23:22:29 +02:00
if [ [ ! -x $S_FCGI ] ] ; then
2020-09-20 20:10:42 +02:00
echo "Utility 'cgi-fcgi' not found. Please, install it first. The required package's name depends on your OS type and version and can be 'libfcgi-bin' or 'libfcgi0ldbl' or 'fcgi'."
2020-02-06 23:11:57 +01:00
exit 1
2019-08-13 10:32:59 +02:00
fi
2020-07-06 23:22:29 +02:00
if [ [ ! -x $S_GREP ] ] ; then
2020-02-06 23:11:57 +01:00
echo "Utility 'grep' not found. Please, install it first."
exit 1
2019-08-13 10:32:59 +02:00
fi
if [ [ -z $1 ] ] || [ [ -z $2 ] ] ; then
2020-09-21 00:49:37 +02:00
$S_CAT <<EOF
No input data specified
NAME: status script for zabbix-php-fpm
USAGE: $0 <SOCKET_IP> <STATUS_PATH>
OPTIONS:
<SOCKET_IP> - either path to socket file, for example, "/var/lib/php7.3-fpm/web1.sock" , or IP and port of the PHP-FPM, for example, "127.0.0.1:9000"
<STATUS_PATH> - path configured in "pm.status" option of the PHP-FPM pool
AUTHOR: Ramil Valitov ramilvalitov@gmail.com
PROJECT PAGE: https://github.com/rvalitov/zabbix-php-fpm
WIKI & DOCS: https://github.com/rvalitov/zabbix-php-fpm/wiki
EOF
2020-02-06 23:11:57 +01:00
exit 1
2019-08-13 10:32:59 +02:00
fi
POOL_URL = $1
POOL_PATH = $2
2020-02-06 23:11:57 +01:00
#connecting to socket or address, https://easyengine.io/tutorials/php/directly-connect-php-fpm/
PHP_STATUS = $(
SCRIPT_NAME = $POOL_PATH \
2020-09-21 00:49:37 +02:00
SCRIPT_FILENAME = $POOL_PATH \
QUERY_STRING = json \
REQUEST_METHOD = GET \
$S_FCGI -bind -connect " $POOL_URL " 2>/dev/null
2020-02-06 23:11:57 +01:00
)
2020-06-28 23:43:33 +02:00
echo " $PHP_STATUS " | $S_GREP "{"
2020-01-17 19:47:39 +01:00
exit 0