mwan3: add check_quality for httping

Example output of TRACK_OUTPUT (httping -c 1 -t 1 'http://www.google.co.uk'):

PING www.google.co.uk:80 (/):
connected to 142.250.200.35:80 (654 bytes), seq=0 time=136.58 ms
--- http://www.google.co.uk/ ping statistics ---
1 connects, 1 ok, 0.00% failed, time 1137 ms
round-trip min/avg/max = 136.6/136.6/136.6 ms

Signed-off-by: William Solichin <william.r.solichin@protonmail.com>
This commit is contained in:
William Solichin 2024-09-13 16:40:05 +01:00 committed by Florian Eckert
parent 1501f15b26
commit 40b84a3ce7
2 changed files with 25 additions and 7 deletions

View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3
PKG_VERSION:=2.11.15
PKG_VERSION:=2.11.16
PKG_RELEASE:=4
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>, \
Aaron Goodman <aaronjg@alumni.stanford.edu>

View File

@ -294,14 +294,32 @@ main() {
result=$?
;;
httping)
if [ "$httping_ssl" -eq 1 ]; then
WRAP httping -c $count -t $timeout -q "https://$track_ip" &> /dev/null &
if [ $check_quality -eq 0 ]; then
if [ "$httping_ssl" -eq 1 ]; then
WRAP httping -c $count -t $timeout -q "https://$track_ip" &> /dev/null &
else
WRAP httping -c $count -t $timeout -q "http://$track_ip" &> /dev/null &
fi
TRACK_PID=$!
wait $TRACK_PID
result=$?
else
WRAP httping -c $count -t $timeout -q "http://$track_ip" &> /dev/null &
if [ "$httping_ssl" -eq 1 ]; then
WRAP httping -c $count -t $timeout "https://$track_ip" 2> /dev/null > $TRACK_OUTPUT &
else
WRAP httping -c $count -t $timeout "http://$track_ip" 2> /dev/null > $TRACK_OUTPUT &
fi
TRACK_PID=$!
wait $TRACK_PID
ping_status=$?
loss="$(sed $TRACK_OUTPUT -ne 's/.* \([0-9]\+\).*% failed.*/\1/p')"
if [ "$ping_status" -ne 0 ] || [ "$loss" -eq 100 ]; then
latency=999999
loss=100
else
latency="$(sed $TRACK_OUTPUT -ne 's%\(rtt\|round-trip\).* = [^/]*/\([0-9]\+\).*%\2%p')"
fi
fi
TRACK_PID=$!
wait $TRACK_PID
result=$?
;;
nping-*)
WRAP nping -c $count $track_ip --${FAMILY#nping-} > $TRACK_OUTPUT &