Commit e861c8b3 authored by Dominika Liberda's avatar Dominika Liberda 💽
Browse files

* added double-pinging to avoid unnecessary notifications

parent 8406cbed
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment