diff --git a/templates/l3_agent_stop_ping.sh.j2 b/templates/l3_agent_stop_ping.sh.j2 index d18a9564..a9275dc0 100644 --- a/templates/l3_agent_stop_ping.sh.j2 +++ b/templates/l3_agent_stop_ping.sh.j2 @@ -11,8 +11,8 @@ PING_RESULT_LOG=$(find ~ -iname 'ping_results*' | sort | tail -1) tail -2 $PING_RESULT_LOG # check results -PING_RESULT=$( awk '/[[:digit:]]+% packet loss/' $PING_RESULT_LOG | grep -Eo '[[:digit:]]+%' | sed s/\%// ) -if [[ $PING_RESULT -gt {{ loss_threshold|default(1)|int }} ]]; then +PING_RESULT=$( grep 'packet loss' $PING_RESULT_LOG | sed 's/.*,\s\(.*\)%.*$/\1/' ) +if [ $(echo "$PING_RESULT > {{ loss_threshold|default(1)|int }}" | bc ) -ne 0 ]; then echo "Ping loss higher than {{ loss_threshold|default(1)|int }}% detected" exit 1 fi