From 104e20928df5a9205ddaa82a0e270f90c9c0d3f8 Mon Sep 17 00:00:00 2001 From: Johnny Hughes Date: Oct 04 2022 13:34:48 +0000 Subject: fix tests/p_mtr/mtr_test.sh to work if blocked at the default GW --- diff --git a/tests/p_mtr/mtr_test.sh b/tests/p_mtr/mtr_test.sh index 620d77f..bf6e3fa 100755 --- a/tests/p_mtr/mtr_test.sh +++ b/tests/p_mtr/mtr_test.sh @@ -21,14 +21,22 @@ FILE=/var/tmp/mtr_result IP=$(dig +short ${HOST} A ${HOST} AAAA) +# getting IP-address of default gateway as a fall back +defgw=$(ip route list | grep default | cut -d' ' -f3) + if [[ ! -z "$IP" ]] then mtr -nr -c1 ${HOST} > ${FILE} COUNT=$(echo "$IP" | grep -cf - ${FILE}) + GW=$(grep -c ${defgw} ${FILE}) if [ $COUNT = 1 ] then t_Log "${TEST} reached ${HOST}" ret_val=0 + elif ([ $COUNT = 0 ] && [ $GW -gt 0 ]) + then + t_Log "${TEST} didn't reach ${HOST} (maybe because of ACLs on the network), but at least the Default Gateway ${defgw} was reached. Treating as SUCCESS." + ret_val=0 else t_Log "${TEST} didn't reach ${HOST}" ret_val=1