mwan3: add check_quality for httping
authorWilliam Solichin <william.r.solichin@protonmail.com>
Fri, 13 Sep 2024 15:40:05 +0000 (16:40 +0100)
committerFlorian Eckert <Eckert.Florian@googlemail.com>
Mon, 7 Oct 2024 06:18:07 +0000 (08:18 +0200)
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>
net/mwan3/Makefile
net/mwan3/files/usr/sbin/mwan3track

index 92dce30a7aa460933319e1cf1c545f1a835f31ae..5657e497c270adf5d5c4f396523777ed7307a87b 100644 (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>
index c3c06717b09f4112d628d5e13de927f51922c302..478f4f0e35f9bbf95b9a6dfa7c165a02fa0de662 100755 (executable)
@@ -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 &