net/mwan3: add failure and recovery interval

If mwan3track detects a failure the interval check will change to
"failure_interval" value until this interface is declared "offline".
After interface gets "offline" normal "interval" value is used again.
If interface ping is successful again "recovery_interval" value is used until
interface is declared "online" again.

Using the different intervals will accelerate the wan line detections on
failure and recovery.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert
2017-03-24 15:21:23 +01:00
parent e90b775740
commit ae335e7384
3 changed files with 23 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
#!/bin/sh
[ -z "$10" ] && echo "Error: should not be started manually" && exit 0
[ -z "$12" ] && echo "Error: should not be started manually" && exit 0
if [ -e /var/run/mwan3track-$1.pid ] ; then
kill $(cat /var/run/mwan3track-$1.pid) &> /dev/null
@@ -10,12 +10,15 @@ fi
echo "$$" > /var/run/mwan3track-$1.pid
score=$(($7+$8))
track_ips=$(echo $* | cut -d ' ' -f 10-99)
track_ips=$(echo $* | cut -d ' ' -f 12-99)
host_up_count=0
lost=0
sleep_time=0
while true; do
sleep_time=$6
for track_ip in $track_ips; do
ping -I $2 -c $4 -W $5 -s $9 -q $track_ip &> /dev/null
if [ $? -eq 0 ]; then
@@ -28,7 +31,12 @@ while true; do
if [ $host_up_count -lt $3 ]; then
let score--
if [ $score -lt $8 ]; then score=0 ; fi
if [ $score -lt $8 ]; then
score=0
else
sleep_time=$10
fi
if [ $score -eq $8 ]; then
logger -t mwan3track -p notice "Interface $1 ($2) is offline"
@@ -48,7 +56,12 @@ while true; do
let score++
lost=0
if [ $score -gt $8 ]; then score=$(($7+$8)); fi
if [ $score -gt $8 ]; then
score=$(($7+$8))
elif [ $score -le $8 ]; then
sleep_time=$11
fi
if [ $score -eq $8 ]; then
logger -t mwan3track -p notice "Interface $1 ($2) is online"
@@ -59,7 +72,7 @@ while true; do
fi
host_up_count=0
sleep $6
sleep $sleep_time
done
exit 1