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

[add] ondemand hot pools

This commit is contained in:
Ramil Valitov 2020-07-07 01:05:11 +03:00
parent ad9435ee39
commit 5b7f642e49
No known key found for this signature in database
GPG Key ID: 2AB186DABDFE1914
2 changed files with 26 additions and 0 deletions

View File

@ -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)

View File

@ -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")