3
0
mirror of https://github.com/rvalitov/zabbix-php-fpm.git synced 2023-11-05 03:30:27 +01:00
zabbix-php-fpm/zabbix/zabbix_php_fpm_status.sh

47 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2019-08-13 10:32:59 +02:00
#!/bin/bash
#Ramil Valitov ramilvalitov@gmail.com
#https://github.com/rvalitov/zabbix-php-fpm
#Script gets status of PHP-FPM pool
2019-08-13 10:32:59 +02:00
S_FCGI=$(type -P cgi-fcgi)
S_GREP=$(type -P grep)
2019-08-13 10:32:59 +02:00
Feature/timeout (#42) * WIP timeout * [add] zabbix discover test * decrease number of pools * [add] similar pool names test * [fix] pools check * [add] discovery debug errors * [add] extra output * [add] full output * [add] json * [del] localhost * [add] tests for localhost * [fix] #35 analyze all pools * [fix] port pools test * [add] show host info * [fix] localhost name resolution * display full log * [add] info for IP processing * [fix] IP processing * [add] timeout test * [fix] sudo delete pools * [add] test missing packages * [add] timeout checks * [add] pm checks * [fix] pools count in tests * [fix] move missing packages to seperate checks * [fix] testZabbixDiscoverNumberOfIPPools * [fix] explicitly remove packages * [fix] testMissingPackagesDiscoveryScript * [fix] status * [add] more info on error * [fix] testMissingPackagesDiscoveryScript * [add] run scripts as zabbix user * WIP tests for commands * [del] update echo * [fix] bash zabbix * [fix] socket test * [fix] discover pools errors * [add] ondemand hot pools * [fix] discover script errors * [fix] recache of ondemand pools * [add] continous checks * [fix] discover checks * [add] more details * [add] sort cache and results * [add] sleep tests * WIP checks * [fix] sleep timeout * [fix] ondemand calls * [add] more info * [add] script timeout test * [add] time execution print * [add] double run tests * [add] more timeout for ondemand pools * [fix] userparameters sleep * [add] display pools * [add] clear cache in tests * [fix] delete cache * [fix] max recursive checks * [add] run duration test * [add] more duration tests * [fix] execution time is measured in ms * [add] ondemand cache test * [add] enrease Zabbix timeout * [fix] zabbix timeout checks * [add] multiple run steps * [fix] stop PHP-FPM before modifications * [fix] port checks and port range * [fix] port calculation * [fix] increase timeout * [fix] order of tests * [fix] run PHP directory ending slash * [add, fix] cache of PHP run directory * [fix] PHP locations * Intermediate fix for timeout feature (#48) * [add] more asserts and checks * [fix] PHP sockets detection in tests * [fix] improved socket dir detection * [fix] improved service name detection, code simplification * [fix] socket pools check * [fix] mapfile -d * [add] local vars * [add] Travis CI folds * [add] color output * [add] extra sleep for service actions * Feature/cache location (#50)
2020-09-14 10:59:05 +02:00
if [[ ! -x $S_FCGI ]]; then
echo "Utility 'cgi-fcgi' not found. Please, install it first."
exit 1
2019-08-13 10:32:59 +02:00
fi
Feature/timeout (#42) * WIP timeout * [add] zabbix discover test * decrease number of pools * [add] similar pool names test * [fix] pools check * [add] discovery debug errors * [add] extra output * [add] full output * [add] json * [del] localhost * [add] tests for localhost * [fix] #35 analyze all pools * [fix] port pools test * [add] show host info * [fix] localhost name resolution * display full log * [add] info for IP processing * [fix] IP processing * [add] timeout test * [fix] sudo delete pools * [add] test missing packages * [add] timeout checks * [add] pm checks * [fix] pools count in tests * [fix] move missing packages to seperate checks * [fix] testZabbixDiscoverNumberOfIPPools * [fix] explicitly remove packages * [fix] testMissingPackagesDiscoveryScript * [fix] status * [add] more info on error * [fix] testMissingPackagesDiscoveryScript * [add] run scripts as zabbix user * WIP tests for commands * [del] update echo * [fix] bash zabbix * [fix] socket test * [fix] discover pools errors * [add] ondemand hot pools * [fix] discover script errors * [fix] recache of ondemand pools * [add] continous checks * [fix] discover checks * [add] more details * [add] sort cache and results * [add] sleep tests * WIP checks * [fix] sleep timeout * [fix] ondemand calls * [add] more info * [add] script timeout test * [add] time execution print * [add] double run tests * [add] more timeout for ondemand pools * [fix] userparameters sleep * [add] display pools * [add] clear cache in tests * [fix] delete cache * [fix] max recursive checks * [add] run duration test * [add] more duration tests * [fix] execution time is measured in ms * [add] ondemand cache test * [add] enrease Zabbix timeout * [fix] zabbix timeout checks * [add] multiple run steps * [fix] stop PHP-FPM before modifications * [fix] port checks and port range * [fix] port calculation * [fix] increase timeout * [fix] order of tests * [fix] run PHP directory ending slash * [add, fix] cache of PHP run directory * [fix] PHP locations * Intermediate fix for timeout feature (#48) * [add] more asserts and checks * [fix] PHP sockets detection in tests * [fix] improved socket dir detection * [fix] improved service name detection, code simplification * [fix] socket pools check * [fix] mapfile -d * [add] local vars * [add] Travis CI folds * [add] color output * [add] extra sleep for service actions * Feature/cache location (#50)
2020-09-14 10:59:05 +02:00
if [[ ! -x $S_GREP ]]; then
echo "Utility 'grep' not found. Please, install it first."
exit 1
2019-08-13 10:32:59 +02:00
fi
2020-09-14 17:39:58 +02:00
USER_ID=$(id -u)
if [[ $USER_ID -ne 0 ]]; then
echo "Insufficient privileges. This script must be run under 'root' user or with 'sudo'."
exit 1
fi
2019-08-13 10:32:59 +02:00
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
2019-08-13 10:32:59 +02:00
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 "{"
exit 0