3
0
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:
Ramil Valitov 2020-09-21 20:09:07 +03:00
parent 619599f692
commit 3d91f05820
No known key found for this signature in database
GPG Key ID: 2AB186DABDFE1914
3 changed files with 26 additions and 33 deletions

View File

@ -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)"
}
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() {
START_TIME=$(date +%s%N)
}
@ -700,6 +689,7 @@ testZabbixStatusSocket() {
local DATA
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"])
IS_OK=$(echo "$DATA" | grep -F '{"pool":"')
printElapsedTime
@ -717,6 +707,7 @@ testZabbixStatusPort() {
PHP_PORT=$(getAnyPort)
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"])
IS_OK=$(echo "$DATA" | grep -F '{"pool":"')
printElapsedTime
@ -783,7 +774,16 @@ testDiscoverScriptTimeout() {
function runZabbixDiscoverReturnsData() {
local DATA
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}"')
printElapsedTime
assertNotNull "Discover script failed: $DATA" "$IS_OK"
@ -820,11 +820,8 @@ testDiscoverScriptSleep() {
}
testZabbixDiscoverSleep() {
#Add sleep
AddSleepToConfig
StartTimer
testZabbixDiscoverReturnsData
runZabbixDiscoverReturnsData "sleep"
printSuccess "${FUNCNAME[0]}"
}
@ -846,11 +843,8 @@ testDiscoverScriptRunDuration() {
}
testZabbixDiscoverRunDuration() {
#Add sleep
AddSleepToConfig
StartTimer
runZabbixDiscoverReturnsData
runZabbixDiscoverReturnsData "sleep"
printSuccess "${FUNCNAME[0]}"
}
@ -870,11 +864,10 @@ testZabbixDiscoverDoubleRun() {
local DATA_FIRST
local DATA_SECOND
#Add sleep
AddSleepToConfig
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["/php-fpm-status"])
# shellcheck disable=SC2140
DATA_FIRST=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["sleep","/php-fpm-status"])
# shellcheck disable=SC2140
DATA_SECOND=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["sleep","/php-fpm-status"])
printElapsedTime
assertNotEquals "Multiple discovery routines provide the same results: $DATA_FIRST" "$DATA_FIRST" "$DATA_SECOND"

View File

@ -198,7 +198,7 @@ function PrintDebug() {
function getPoolManagerByCode() {
local MANAGER_CODE=$1
local $PROCESS_MANAGER
local PROCESS_MANAGER
if [[ $MANAGER_CODE -eq 1 ]]; then
PROCESS_MANAGER="dynamic"
@ -696,7 +696,7 @@ function ProcessPool() {
if [[ $POOL_STATUS -gt 0 ]]; then
PrintDebug "Success: socket $POOL_SOCKET returned valid status data"
else
PrintDebug "Error: socket $POOL_SOCKET didn't return valid data"
PrintDebug "Warning: socket $POOL_SOCKET didn't return valid data"
fi
return $POOL_STATUS
}