From 63899f7c79be151af5bec621f18d5dac4da7b82f Mon Sep 17 00:00:00 2001 From: William Solichin Date: Fri, 13 Sep 2024 16:40:05 +0100 Subject: [PATCH] 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 --- net/mwan3/Makefile | 2 +- net/mwan3/files/usr/sbin/mwan3track | 30 +++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile index 0108d178fe24b3..1763b2ea86ab68 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwan3 -PKG_VERSION:=2.11.15 +PKG_VERSION:=2.11.16 PKG_RELEASE:=3 PKG_MAINTAINER:=Florian Eckert , \ Aaron Goodman diff --git a/net/mwan3/files/usr/sbin/mwan3track b/net/mwan3/files/usr/sbin/mwan3track index c3c06717b09f41..478f4f0e35f9bb 100755 --- a/net/mwan3/files/usr/sbin/mwan3track +++ b/net/mwan3/files/usr/sbin/mwan3track @@ -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 &