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
43
tests/all.sh
43
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)
|
||||||
}
|
}
|
||||||
@ -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"
|
||||||
|
@ -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