mirror of
https://github.com/rvalitov/zabbix-php-fpm.git
synced 2023-11-05 03:30:27 +01:00
[add] parallel and non parallel tasks are independent
This commit is contained in:
parent
44f3f5d567
commit
8423a7a1a1
14
tests/all.sh
14
tests/all.sh
@ -134,7 +134,7 @@ function restoreUserParameters() {
|
|||||||
|
|
||||||
function AddSleepToConfig() {
|
function AddSleepToConfig() {
|
||||||
PARAMS_FILE=$(getUserParameters)
|
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"
|
sudo sed -i 's#.*zabbix_php_fpm_discovery.*#UserParameter=php-fpm.discover[*],sudo /etc/zabbix/zabbix_php_fpm_discovery.sh sleep max_tasks 1 $1#' "$PARAMS_FILE"
|
||||||
travis_fold_start "AddSleepToConfig" "ⓘ New UserParameter file"
|
travis_fold_start "AddSleepToConfig" "ⓘ New UserParameter file"
|
||||||
sudo cat "$PARAMS_FILE"
|
sudo cat "$PARAMS_FILE"
|
||||||
travis_fold_end
|
travis_fold_end
|
||||||
@ -733,6 +733,7 @@ testZabbixDiscoverSleep() {
|
|||||||
#Add sleep
|
#Add sleep
|
||||||
AddSleepToConfig
|
AddSleepToConfig
|
||||||
|
|
||||||
|
StartTimer
|
||||||
testZabbixDiscoverReturnsData
|
testZabbixDiscoverReturnsData
|
||||||
printSuccess "${FUNCNAME[0]}"
|
printSuccess "${FUNCNAME[0]}"
|
||||||
}
|
}
|
||||||
@ -750,17 +751,6 @@ testDiscoverScriptRunDuration() {
|
|||||||
printSuccess "${FUNCNAME[0]}"
|
printSuccess "${FUNCNAME[0]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
testZabbixDiscoverRunDuration() {
|
|
||||||
#Add sleep
|
|
||||||
AddSleepToConfig
|
|
||||||
|
|
||||||
DATA=$(zabbix_get -s 127.0.0.1 -p 10050 -k php-fpm.discover["/php-fpm-status"])
|
|
||||||
|
|
||||||
printElapsedTime
|
|
||||||
assertExecutionTime
|
|
||||||
printSuccess "${FUNCNAME[0]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
testDiscoverScriptDoubleRun() {
|
testDiscoverScriptDoubleRun() {
|
||||||
DATA_FIRST=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
|
DATA_FIRST=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
|
||||||
DATA_SECOND=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
|
DATA_SECOND=$(sudo -u zabbix sudo "/etc/zabbix/zabbix_php_fpm_discovery.sh" "debug" "sleep" "/php-fpm-status")
|
||||||
|
@ -196,6 +196,22 @@ function PrintDebug() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPoolManagerByCode() {
|
||||||
|
local MANAGER_CODE=$1
|
||||||
|
local $PROCESS_MANAGER
|
||||||
|
|
||||||
|
if [[ $MANAGER_CODE -eq 1 ]]; then
|
||||||
|
PROCESS_MANAGER="dynamic"
|
||||||
|
elif [[ $MANAGER_CODE -eq 2 ]]; then
|
||||||
|
PROCESS_MANAGER="static"
|
||||||
|
elif [[ $MANAGER_CODE -eq 3 ]]; then
|
||||||
|
PROCESS_MANAGER="ondemand"
|
||||||
|
else
|
||||||
|
PROCESS_MANAGER=""
|
||||||
|
fi
|
||||||
|
echo $PROCESS_MANAGER
|
||||||
|
}
|
||||||
|
|
||||||
# Encodes input data to JSON and saves it to result string
|
# Encodes input data to JSON and saves it to result string
|
||||||
# Input arguments:
|
# Input arguments:
|
||||||
# - pool name
|
# - pool name
|
||||||
@ -812,6 +828,18 @@ for POOL_ITEM in "${PENDING_LIST[@]}"; do
|
|||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
POOL_SOCKET=$(echo "$POOL_ITEM" | $S_AWK -F "$ARRAY_SEPARATOR" '{print $2}')
|
POOL_SOCKET=$(echo "$POOL_ITEM" | $S_AWK -F "$ARRAY_SEPARATOR" '{print $2}')
|
||||||
if [[ -n "$POOL_NAME" ]] && [[ -n "$POOL_SOCKET" ]]; then
|
if [[ -n "$POOL_NAME" ]] && [[ -n "$POOL_SOCKET" ]]; then
|
||||||
|
if [[ $MAX_PARALLEL_TASKS -eq 1 ]]; then
|
||||||
|
#We work in standard mode (non-parallel)
|
||||||
|
ProcessPool "$POOL_NAME" "$POOL_SOCKET"
|
||||||
|
EXIT_CODE=$?
|
||||||
|
DeletePoolFromPendingList "$POOL_NAME" "$POOL_SOCKET"
|
||||||
|
|
||||||
|
PROCESS_MANAGER=$(getPoolManagerByCode $EXIT_CODE)
|
||||||
|
if [[ -n $PROCESS_MANAGER ]]; then
|
||||||
|
UpdatePoolInCache "$POOL_NAME" "$POOL_SOCKET" "$PROCESS_MANAGER"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
#We work in parallel mode
|
||||||
PARALLEL_TASKS=$((PARALLEL_TASKS + 1))
|
PARALLEL_TASKS=$((PARALLEL_TASKS + 1))
|
||||||
if [[ $PARALLEL_TASKS -le $MAX_PARALLEL_TASKS ]]; then
|
if [[ $PARALLEL_TASKS -le $MAX_PARALLEL_TASKS ]]; then
|
||||||
PrintDebug "Starting processing task for pool $POOL_NAME $POOL_SOCKET, subprocess #$PARALLEL_TASKS..."
|
PrintDebug "Starting processing task for pool $POOL_NAME $POOL_SOCKET, subprocess #$PARALLEL_TASKS..."
|
||||||
@ -839,14 +867,8 @@ for POOL_ITEM in "${PENDING_LIST[@]}"; do
|
|||||||
PrintDebug "Finished parallel task PID $TASK_PID for pool \"$POOL_NAME\" at $POOL_SOCKET"
|
PrintDebug "Finished parallel task PID $TASK_PID for pool \"$POOL_NAME\" at $POOL_SOCKET"
|
||||||
DeletePoolFromPendingList "$POOL_NAME" "$POOL_SOCKET"
|
DeletePoolFromPendingList "$POOL_NAME" "$POOL_SOCKET"
|
||||||
|
|
||||||
if [[ $EXIT_CODE -ge 1 ]] && [[ $EXIT_CODE -le 3 ]]; then
|
PROCESS_MANAGER=$(getPoolManagerByCode $EXIT_CODE)
|
||||||
if [[ $EXIT_CODE -eq 1 ]]; then
|
if [[ -n $PROCESS_MANAGER ]]; then
|
||||||
PROCESS_MANAGER="dynamic"
|
|
||||||
elif [[ $EXIT_CODE -eq 2 ]]; then
|
|
||||||
PROCESS_MANAGER="static"
|
|
||||||
else
|
|
||||||
PROCESS_MANAGER="ondemand"
|
|
||||||
fi
|
|
||||||
UpdatePoolInCache "$POOL_NAME" "$POOL_SOCKET" "$PROCESS_MANAGER"
|
UpdatePoolInCache "$POOL_NAME" "$POOL_SOCKET" "$PROCESS_MANAGER"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -854,6 +876,8 @@ for POOL_ITEM in "${PENDING_LIST[@]}"; do
|
|||||||
PARALLEL_TASKS=0
|
PARALLEL_TASKS=0
|
||||||
TASK_LIST=()
|
TASK_LIST=()
|
||||||
fi
|
fi
|
||||||
|
#End of parallel mode
|
||||||
|
fi
|
||||||
|
|
||||||
#Confirm that we run not too much time
|
#Confirm that we run not too much time
|
||||||
CheckExecutionTime
|
CheckExecutionTime
|
||||||
|
Loading…
Reference in New Issue
Block a user