diff --git a/tests/all.sh b/tests/all.sh index 414df01..399e40b 100644 --- a/tests/all.sh +++ b/tests/all.sh @@ -227,6 +227,27 @@ testZabbixDiscoverNumberOfOndemandPoolsCold() { testZabbixDiscoverNumberOfOndemandPoolsHot() { # We must start all the pools + POOL_URL="/" + PHP_COUNT=$(getNumberOfPHPVersions) + + PHP_LIST=$(find /etc/php/ -name 'www.conf' -type f) + while IFS= read -r pool; do + if [[ -n $pool ]]; then + POOL_DIR=$(dirname "$pool") + PHP_VERSION=$(echo "$POOL_DIR" | grep -oP "(\d\.\d)") + + for ((c = 1; c <= MAX_POOLS; c++)); do + POOL_NAME="ondemand$c" + POOL_SOCKET="/run/php/php${PHP_VERSION}-fpm-${POOL_NAME}.sock" + + SCRIPT_NAME=$POOL_SOCKET \ + SCRIPT_FILENAME=$POOL_SOCKET \ + QUERY_STRING=json \ + REQUEST_METHOD=GET \ + cgi-fcgi -bind -connect "$POOL_URL" 2>/dev/null + done + fi + done <<<"$PHP_LIST" DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"]) NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F '{"{#POOLNAME}":"ondemand' | wc -l) diff --git a/zabbix/zabbix_php_fpm_discovery.sh b/zabbix/zabbix_php_fpm_discovery.sh index 243f0df..ae085f0 100644 --- a/zabbix/zabbix_php_fpm_discovery.sh +++ b/zabbix/zabbix_php_fpm_discovery.sh @@ -42,6 +42,7 @@ S_WHOAMI=$(type -P whoami) S_DATE=$(type -P date) S_BC=$(type -P bc) S_SLEEP=$(type -P sleep) +S_FCGI=$(type -P cgi-fcgi) if [[ ! -x $S_PS ]]; then echo "Utility 'ps' not found. Please, install it first." @@ -107,6 +108,10 @@ if [[ ! -x $S_SLEEP ]]; then echo "Utility 'sleep' not found. Please, install it first." exit 1 fi +if [[ ! -x $S_FCGI ]]; then + echo "Utility 'cgi-fcgi' not found. Please, install it first." + exit 1 +fi #Local directory LOCAL_DIR=$(${S_DIRNAME} "$0")