From dcd4191fbebe2b3ebc9a56deb014aa0ec61e7af5 Mon Sep 17 00:00:00 2001 From: Johannes Truschnigg Date: Sat, 12 Mar 2022 15:06:44 +0100 Subject: [PATCH] Improve wrapper script --- lagdetect.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/lagdetect.sh b/lagdetect.sh index 45224c3..268b24f 100755 --- a/lagdetect.sh +++ b/lagdetect.sh @@ -14,18 +14,27 @@ PING_INTERVAL=500 # DO NOT EDIT BELOW # ##################### -set -u -for t in traceroute fping +for p in traceroute fping awk do -type "$t" || exit 1 + type "${p}" || { printf 'FATAL: Required program "%s" not installed.\n' "${p}" >&2; exit 1; } done -_def_gw_v4=$(traceroute -n -m 1 1.1.1.1 | awk '{if("1" == $1){print $2}}') +if [ x"${PING_GW_IPV6}" = xyes ] +then + PING_PEERS="$(traceroute -6 -n -m 2001:4860:4860::8888 | awk '{if("1" == $1){print $2}}') ${PING_PEERS}" +fi + +if [ x"${PING_GW_IPV4}" = xyes ] +then + PING_PEERS="$(traceroute -4 -n -m 1 1.1.1.1 | awk '{if("1" == $1){print $2}}') ${PING_PEERS}" +fi + +set -u -fping --loop --retry=1 --size=1280 --period="${PING_INTERVAL}" --random "${_def_gw_v4}" ${PING_PEERS} 2>/dev/null \ +fping --loop --retry=1 --size=1280 --period="${PING_INTERVAL}" --random ${PING_PEERS} 2>/dev/null \ | awk \ - -v THRESHOLD="${THRESHOLD}" \ - -v PINGSLOTS="${PING_SLOTS_PER_PEER}" \ - -v FUDGE="${FUDGE_MS}" \ - -v PING_PEERS="${_def_gw_v4} ${PING_PEERS}" \ - -f __lagdetect.awk + -v THRESHOLD="${THRESHOLD}" \ + -v PINGSLOTS="${PING_SLOTS_PER_PEER}" \ + -v FUDGE="${FUDGE_MS}" \ + -v PING_PEERS="${PING_PEERS}" \ + -f __lagdetect.awk -- 2.39.5