arpcheck/arp-timing.sh

36 lines
715 B
Bash
Executable File

IP="$1"
OUTFILE="$2"
TIME_LENGTH_TIL_AWAY=60
startedTimeout="n"
away="n"
alertedHome="n"
alertedAway="n"
#IP="172.16.1.66" #64
counter=0
#stdbuf -oL arping "$IP" | while read line
while read line
do
echo "$line"
if [ "$line" = "Timeout" ]; then
if [ "$startedTimeout" = "n" ]; then
startedTimeout="y"
counter=1
else
let "counter += 1"
fi
else
if [ "$startedTimeout" = "y" ]; then
startedTimeout="n"
if [ $counter -ge 100 ]; then
echo "$(date +%H:%M:%S) -- $counter" >> "$OUTFILE"
fi
counter=0
fi
fi
done < <(stdbuf -oL arping "$IP")
# if != Timeout then here; reset timer to 0
# if == Timeout for more than x minutes then not here