* added double-pinging to avoid unnecessary notifications
parent
8406cbedf8
commit
e861c8b3db
13
code/ping.sh
13
code/ping.sh
|
@ -12,14 +12,21 @@ for i in $json; do
|
|||
res="$(ping -c 1 $addr > >(grep icmp_seq | sed -E 's/.*icmp_seq=.//'))"
|
||||
status=$?
|
||||
|
||||
if [[ "$status" == 0 ]]; then
|
||||
if [[ "$res" == *"time"* ]]; then
|
||||
res_parsed="$(grep -Eoh "time=.*ms" <<< "$res" | sed -E 's/time=//g;s/ms//g' | tr -d ' ')"
|
||||
else
|
||||
res_parsed='#'
|
||||
fi
|
||||
|
||||
# trying to ping for the 2nd time, as the interwebs may be flaky on the other side
|
||||
|
||||
if [[ "$res_parsed" == "#" ]]; then
|
||||
res="$(ping -c 1 $addr > >(grep icmp_seq | sed -E 's/.*icmp_seq=.//'))"
|
||||
if [[ "$res" == *"time"* ]]; then
|
||||
res_parsed="$(grep -Eoh "time=.*ms" <<< "$res" | sed -E 's/time=//g;s/ms//g' | tr -d ' ')"
|
||||
else
|
||||
res_parsed='#'
|
||||
fi
|
||||
else
|
||||
res_parsed='#'
|
||||
fi
|
||||
|
||||
unset json_res
|
||||
|
|
Loading…
Reference in New Issue