|
|
@ -24,6 +24,30 @@ if_down() { |
|
|
|
IFDOWN_EVENT=1 |
|
|
|
} |
|
|
|
|
|
|
|
validate_track_method() { |
|
|
|
case "$1" in |
|
|
|
ping) |
|
|
|
# Assume that ping is installed |
|
|
|
;; |
|
|
|
arping) |
|
|
|
which arping 1>/dev/null 2>&1 || { |
|
|
|
$LOG warn "Missing arping. Please install iputils-arping package." |
|
|
|
return 1 |
|
|
|
} |
|
|
|
;; |
|
|
|
httping) |
|
|
|
which httping 1>/dev/null 2>&1 || { |
|
|
|
$LOG warn "Missing httping. Please install httping package." |
|
|
|
return 1 |
|
|
|
} |
|
|
|
;; |
|
|
|
*) |
|
|
|
$LOG warn "Unsupported tracking method: $track_method" |
|
|
|
return 2 |
|
|
|
;; |
|
|
|
esac |
|
|
|
} |
|
|
|
|
|
|
|
main() { |
|
|
|
local reliability count timeout interval failure_interval |
|
|
|
local recovery_interval down up size |
|
|
@ -37,6 +61,11 @@ main() { |
|
|
|
trap if_down SIGUSR1 |
|
|
|
|
|
|
|
config_load mwan3 |
|
|
|
config_get track_method $1 track_method ping |
|
|
|
validate_track_method $track_method || { |
|
|
|
$LOG warn "Using ping to track interface $INTERFACE avaliability" |
|
|
|
track_method=ping |
|
|
|
} |
|
|
|
config_get reliability $1 reliability 1 |
|
|
|
config_get count $1 count 1 |
|
|
|
config_get timeout $1 timeout 4 |
|
|
@ -48,7 +77,7 @@ main() { |
|
|
|
config_get recovery_interval $1 recovery_interval $interval |
|
|
|
|
|
|
|
local score=$(($down+$up)) |
|
|
|
local track_ips=$(echo $* | cut -d ' ' -f 3-99) |
|
|
|
local track_ips=$(echo $* | cut -d ' ' -f 4-99) |
|
|
|
local host_up_count=0 |
|
|
|
local lost=0 |
|
|
|
local sleep_time=0 |
|
|
@ -60,7 +89,14 @@ main() { |
|
|
|
sleep_time=$interval |
|
|
|
|
|
|
|
for track_ip in $track_ips; do |
|
|
|
ping -I $2 -c $count -W $timeout -s $size -q $track_ip &> /dev/null |
|
|
|
case "$track_method" in |
|
|
|
ping) |
|
|
|
ping -I $2 -c $count -W $timeout -s $size -q $track_ip &> /dev/null ;; |
|
|
|
arping) |
|
|
|
arping -I $2 -c $count -w $timeout -q $track_ip &> /dev/null ;; |
|
|
|
httping) |
|
|
|
httping -y $3 -c $count -t $timeout -q $track_ip &> /dev/null ;; |
|
|
|
esac |
|
|
|
if [ $? -eq 0 ]; then |
|
|
|
let host_up_count++ |
|
|
|
echo "up" > /var/run/mwan3track/$1/TRACK_${track_ip} |
|
|
|