mirror of
https://github.com/rvalitov/zabbix-php-fpm.git
synced 2023-11-05 03:30:27 +01:00
[fix] sleep config
This commit is contained in:
parent
619599f692
commit
3d91f05820
53
tests/all.sh
53
tests/all.sh
@ -133,17 +133,6 @@ function restoreUserParameters() {
|
|||||||
sudo cp "$TRAVIS_BUILD_DIR/zabbix/userparameter_php_fpm.conf" "$(sudo find /etc/zabbix/ -name 'zabbix_agentd*.d' -type d 2>/dev/null | sort | head -n1)"
|
sudo cp "$TRAVIS_BUILD_DIR/zabbix/userparameter_php_fpm.conf" "$(sudo find /etc/zabbix/ -name 'zabbix_agentd*.d' -type d 2>/dev/null | sort | head -n1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddSleepToConfig() {
|
|
||||||
local PARAMS_FILE
|
|
||||||
PARAMS_FILE=$(getUserParameters)
|
|
||||||
sudo sed -i 's#.*zabbix_php_fpm_discovery.*#UserParameter=php-fpm.discover[*],sudo /etc/zabbix/zabbix_php_fpm_discovery.sh sleep $1#' "$PARAMS_FILE"
|
|
||||||
travis_fold_start "AddSleepToConfig" "ⓘ New UserParameter file"
|
|
||||||
sudo cat "$PARAMS_FILE"
|
|
||||||
travis_fold_end
|
|
||||||
restartService "zabbix-agent"
|
|
||||||
sleep 2
|
|
||||||
}
|
|
||||||
|
|
||||||
function StartTimer() {
|
function StartTimer() {
|
||||||
START_TIME=$(date +%s%N)
|
START_TIME=$(date +%s%N)
|
||||||
}
|
}
|
||||||
@ -500,7 +489,7 @@ getAnySocket() {
|
|||||||
assertEquals "Failed to find PHP configuration directory" "0" "$EXIT_CODE"
|
assertEquals "Failed to find PHP configuration directory" "0" "$EXIT_CODE"
|
||||||
assertTrue "PHP configuration directory '$PHP_DIR' is not a directory" "[ -d $PHP_DIR ]"
|
assertTrue "PHP configuration directory '$PHP_DIR' is not a directory" "[ -d $PHP_DIR ]"
|
||||||
|
|
||||||
local PHP_RUN_DIR
|
local PHP_RUN_DIR
|
||||||
PHP_RUN_DIR=$(getRunPHPDirectory)
|
PHP_RUN_DIR=$(getRunPHPDirectory)
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
assertEquals "Failed to find PHP run directory" "0" "$EXIT_CODE"
|
assertEquals "Failed to find PHP run directory" "0" "$EXIT_CODE"
|
||||||
@ -700,6 +689,7 @@ testZabbixStatusSocket() {
|
|||||||
local DATA
|
local DATA
|
||||||
local IS_OK
|
local IS_OK
|
||||||
|
|
||||||
|
# shellcheck disable=SC2140
|
||||||
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.status["$TEST_SOCKET","/php-fpm-status"])
|
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.status["$TEST_SOCKET","/php-fpm-status"])
|
||||||
IS_OK=$(echo "$DATA" | grep -F '{"pool":"')
|
IS_OK=$(echo "$DATA" | grep -F '{"pool":"')
|
||||||
printElapsedTime
|
printElapsedTime
|
||||||
@ -717,6 +707,7 @@ testZabbixStatusPort() {
|
|||||||
PHP_PORT=$(getAnyPort)
|
PHP_PORT=$(getAnyPort)
|
||||||
local PHP_POOL="127.0.0.1:$PHP_PORT"
|
local PHP_POOL="127.0.0.1:$PHP_PORT"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2140
|
||||||
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.status["$PHP_POOL","/php-fpm-status"])
|
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.status["$PHP_POOL","/php-fpm-status"])
|
||||||
IS_OK=$(echo "$DATA" | grep -F '{"pool":"')
|
IS_OK=$(echo "$DATA" | grep -F '{"pool":"')
|
||||||
printElapsedTime
|
printElapsedTime
|
||||||
@ -783,7 +774,16 @@ testDiscoverScriptTimeout() {
|
|||||||
function runZabbixDiscoverReturnsData() {
|
function runZabbixDiscoverReturnsData() {
|
||||||
local DATA
|
local DATA
|
||||||
local IS_OK
|
local IS_OK
|
||||||
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
|
local OPTIONS='"/php-fpm-status"'
|
||||||
|
|
||||||
|
local ARG_ID=1
|
||||||
|
local ARGS_COUNT=$#
|
||||||
|
|
||||||
|
while [ $ARG_ID -le $ARGS_COUNT ]; do
|
||||||
|
OPTIONS="$OPTIONS,\"$1\""
|
||||||
|
done
|
||||||
|
|
||||||
|
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover[$OPTIONS])
|
||||||
IS_OK=$(echo "$DATA" | grep -F '{"data":[{"{#POOLNAME}"')
|
IS_OK=$(echo "$DATA" | grep -F '{"data":[{"{#POOLNAME}"')
|
||||||
printElapsedTime
|
printElapsedTime
|
||||||
assertNotNull "Discover script failed: $DATA" "$IS_OK"
|
assertNotNull "Discover script failed: $DATA" "$IS_OK"
|
||||||
@ -820,11 +820,8 @@ testDiscoverScriptSleep() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testZabbixDiscoverSleep() {
|
testZabbixDiscoverSleep() {
|
||||||
#Add sleep
|
|
||||||
AddSleepToConfig
|
|
||||||
|
|
||||||
StartTimer
|
StartTimer
|
||||||
testZabbixDiscoverReturnsData
|
runZabbixDiscoverReturnsData "sleep"
|
||||||
printSuccess "${FUNCNAME[0]}"
|
printSuccess "${FUNCNAME[0]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,11 +843,8 @@ testDiscoverScriptRunDuration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testZabbixDiscoverRunDuration() {
|
testZabbixDiscoverRunDuration() {
|
||||||
#Add sleep
|
|
||||||
AddSleepToConfig
|
|
||||||
|
|
||||||
StartTimer
|
StartTimer
|
||||||
runZabbixDiscoverReturnsData
|
runZabbixDiscoverReturnsData "sleep"
|
||||||
printSuccess "${FUNCNAME[0]}"
|
printSuccess "${FUNCNAME[0]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,11 +864,10 @@ testZabbixDiscoverDoubleRun() {
|
|||||||
local DATA_FIRST
|
local DATA_FIRST
|
||||||
local DATA_SECOND
|
local DATA_SECOND
|
||||||
|
|
||||||
#Add sleep
|
# shellcheck disable=SC2140
|
||||||
AddSleepToConfig
|
DATA_FIRST=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["sleep","/php-fpm-status"])
|
||||||
|
# shellcheck disable=SC2140
|
||||||
DATA_FIRST=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
|
DATA_SECOND=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["sleep","/php-fpm-status"])
|
||||||
DATA_SECOND=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
|
|
||||||
|
|
||||||
printElapsedTime
|
printElapsedTime
|
||||||
assertNotEquals "Multiple discovery routines provide the same results: $DATA_FIRST" "$DATA_FIRST" "$DATA_SECOND"
|
assertNotEquals "Multiple discovery routines provide the same results: $DATA_FIRST" "$DATA_FIRST" "$DATA_SECOND"
|
||||||
@ -923,9 +916,9 @@ checkNumberOfPools() {
|
|||||||
fi
|
fi
|
||||||
assertEquals "Failed to discover all data when checking pools '$POOL_TYPE'" "0" "$STATUS"
|
assertEquals "Failed to discover all data when checking pools '$POOL_TYPE'" "0" "$STATUS"
|
||||||
|
|
||||||
local NUMBER_OF_POOLS
|
local NUMBER_OF_POOLS
|
||||||
local PHP_COUNT
|
local PHP_COUNT
|
||||||
local POOLS_BY_DESIGN
|
local POOLS_BY_DESIGN
|
||||||
NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F "{\"{#POOLNAME}\":\"$POOL_TYPE" | wc -l)
|
NUMBER_OF_POOLS=$(echo "$DATA" | grep -o -F "{\"{#POOLNAME}\":\"$POOL_TYPE" | wc -l)
|
||||||
PHP_COUNT=$(getNumberOfPHPVersions)
|
PHP_COUNT=$(getNumberOfPHPVersions)
|
||||||
if [[ -n "$CHECK_COUNT" ]] && [[ "$CHECK_COUNT" -ge 0 ]]; then
|
if [[ -n "$CHECK_COUNT" ]] && [[ "$CHECK_COUNT" -ge 0 ]]; then
|
||||||
@ -990,7 +983,7 @@ testZabbixDiscoverNumberOfOndemandPoolsCache() {
|
|||||||
echo "$INITIAL_DATA"
|
echo "$INITIAL_DATA"
|
||||||
travis_fold_end
|
travis_fold_end
|
||||||
|
|
||||||
local WAIT_TIMEOUT
|
local WAIT_TIMEOUT
|
||||||
WAIT_TIMEOUT=$(echo "$ONDEMAND_TIMEOUT * 2" | bc)
|
WAIT_TIMEOUT=$(echo "$ONDEMAND_TIMEOUT * 2" | bc)
|
||||||
sleep "$WAIT_TIMEOUT"
|
sleep "$WAIT_TIMEOUT"
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ testMissingPackagesDiscoveryScript() {
|
|||||||
testMissingPackagesStatusScript() {
|
testMissingPackagesStatusScript() {
|
||||||
local DATA
|
local DATA
|
||||||
local IS_OK
|
local IS_OK
|
||||||
|
|
||||||
DATA=$(sudo bash "/etc/zabbix/zabbix_php_fpm_status.sh" "localhost:9000" "/php-fpm-status")
|
DATA=$(sudo bash "/etc/zabbix/zabbix_php_fpm_status.sh" "localhost:9000" "/php-fpm-status")
|
||||||
IS_OK=$(echo "$DATA" | grep -F ' not found.')
|
IS_OK=$(echo "$DATA" | grep -F ' not found.')
|
||||||
assertNotNull "Status script didn't report error on missing utilities $DATA" "$IS_OK"
|
assertNotNull "Status script didn't report error on missing utilities $DATA" "$IS_OK"
|
||||||
|
@ -198,7 +198,7 @@ function PrintDebug() {
|
|||||||
|
|
||||||
function getPoolManagerByCode() {
|
function getPoolManagerByCode() {
|
||||||
local MANAGER_CODE=$1
|
local MANAGER_CODE=$1
|
||||||
local $PROCESS_MANAGER
|
local PROCESS_MANAGER
|
||||||
|
|
||||||
if [[ $MANAGER_CODE -eq 1 ]]; then
|
if [[ $MANAGER_CODE -eq 1 ]]; then
|
||||||
PROCESS_MANAGER="dynamic"
|
PROCESS_MANAGER="dynamic"
|
||||||
@ -696,7 +696,7 @@ function ProcessPool() {
|
|||||||
if [[ $POOL_STATUS -gt 0 ]]; then
|
if [[ $POOL_STATUS -gt 0 ]]; then
|
||||||
PrintDebug "Success: socket $POOL_SOCKET returned valid status data"
|
PrintDebug "Success: socket $POOL_SOCKET returned valid status data"
|
||||||
else
|
else
|
||||||
PrintDebug "Error: socket $POOL_SOCKET didn't return valid data"
|
PrintDebug "Warning: socket $POOL_SOCKET didn't return valid data"
|
||||||
fi
|
fi
|
||||||
return $POOL_STATUS
|
return $POOL_STATUS
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user