Another fix for zone owner detection
This commit is contained in:
parent
f1b8a206c5
commit
3f31ede396
51
aircon.sh
51
aircon.sh
|
@ -122,6 +122,7 @@ function getzoneaction() { # populates zproblem[] and zaction[]
|
||||||
idx=$1
|
idx=$1
|
||||||
|
|
||||||
profile "getzoneaction for idx ${zname[$idx]}"
|
profile "getzoneaction for idx ${zname[$idx]}"
|
||||||
|
[[ $robtest -eq 1 ]] && echo "getzoneaction zone ${zname[$idx]}"
|
||||||
thisaction="n/a"
|
thisaction="n/a"
|
||||||
if [[ ${zignore[$idx]} -eq 1 ]]; then
|
if [[ ${zignore[$idx]} -eq 1 ]]; then
|
||||||
problem="n/a"
|
problem="n/a"
|
||||||
|
@ -129,17 +130,17 @@ function getzoneaction() { # populates zproblem[] and zaction[]
|
||||||
else
|
else
|
||||||
if [[ -z ${zowner[$idx]} ]]; then
|
if [[ -z ${zowner[$idx]} ]]; then
|
||||||
pingok=1
|
pingok=1
|
||||||
|
#[[ $robtest -eq 1 ]] && echo " empty owner so no ping "
|
||||||
elif canping ${zowner[$idx]}; then
|
elif canping ${zowner[$idx]}; then
|
||||||
|
#[[ $robtest -eq 1 ]] && echo " canping returned ok"
|
||||||
pingok=1
|
pingok=1
|
||||||
else
|
else
|
||||||
|
#[[ $robtest -eq 1 ]] && echo " canping returned fail"
|
||||||
pingok=0
|
pingok=0
|
||||||
thisperfect=1
|
thisperfect=0
|
||||||
fi
|
fi
|
||||||
fv=$(getforcevent ${zname[$idx]})
|
fv=$(getforcevent ${zname[$idx]})
|
||||||
|
[[ $robtest -eq 1 ]] && echo " canping zone ${zname[$idx]} is: $pingok"
|
||||||
if [[ $robtest -eq 1 ]]; then
|
|
||||||
echo "canping zone ${zname[$idx]} is: $pingok"
|
|
||||||
fi
|
|
||||||
|
|
||||||
donearby=0
|
donearby=0
|
||||||
|
|
||||||
|
@ -1323,7 +1324,13 @@ function canping() {
|
||||||
local n hname ip db host success=0 mac
|
local n hname ip db host success=0 mac
|
||||||
local os arprv arpres
|
local os arprv arpres
|
||||||
os=$(uname -s)
|
os=$(uname -s)
|
||||||
db=0
|
db=1
|
||||||
|
if [[ $db -eq 1 ]]; then
|
||||||
|
info "canping() for:"
|
||||||
|
for host in $*; do
|
||||||
|
info " - '${host}'"
|
||||||
|
done
|
||||||
|
fi
|
||||||
# get ip and clear arp
|
# get ip and clear arp
|
||||||
n=0
|
n=0
|
||||||
for host in $*; do
|
for host in $*; do
|
||||||
|
@ -1336,16 +1343,17 @@ function canping() {
|
||||||
if [[ -n ${ip[$n]} ]]; then
|
if [[ -n ${ip[$n]} ]]; then
|
||||||
arp -d ${ip[$n]} >/dev/null 2>&1
|
arp -d ${ip[$n]} >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
n=$((n + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
# send new arp req
|
# send new arp req
|
||||||
for n in ${!ip[@]}; do
|
for n in ${!ip[@]}; do
|
||||||
if [[ -n ${ip[$n]} ]]; then
|
if [[ -n ${ip[$n]} ]]; then
|
||||||
if [[ -e $ARPING ]]; then
|
if [[ -e $ARPING ]]; then
|
||||||
${ARPING} -c10 -W0.2 -w4 -C1 -q ${ip[$n]} 2>/dev/null &
|
${ARPING} -c10 -W0.2 -w4 -C1 -q ${ip[$n]} 2>/dev/null &
|
||||||
else
|
else
|
||||||
ping -c 1 -w 1 -q ${ip[$n]} 2>/dev/null &
|
ping -c 1 -w 1 -q ${ip[$n]} 2>/dev/null &
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1355,13 +1363,16 @@ function canping() {
|
||||||
|
|
||||||
# now check entries
|
# now check entries
|
||||||
for n in ${!ip[@]}; do
|
for n in ${!ip[@]}; do
|
||||||
|
[[ $db -eq 1 ]] && info " recheck ${hname[$n]} (${ip[$n]})"
|
||||||
if [[ -n ${ip[$n]} ]]; then
|
if [[ -n ${ip[$n]} ]]; then
|
||||||
arpres=$(arp -n ${ip[$n]} 2>/dev/null)
|
arpres=$(arp -n ${ip[$n]} 2>/dev/null)
|
||||||
arprv=$?
|
arprv=$?
|
||||||
mac=$(echo "$arpres" | egrep -v "Host|xpired" | awk '{print $2}')
|
mac=$(echo "$arpres" | egrep -v "Host|xpired" | awk '{print $2}')
|
||||||
[[ $mac == *:* ]] && success=1
|
[[ $mac == *:* ]] && success=1
|
||||||
fi
|
fi
|
||||||
[[ $db -eq 1 ]] && info "canping() ${hname[$n]} (${ip[$n]}) is $success - mac=$mac"
|
[[ $db -eq 1 ]] && info " ${hname[$n]} (${ip[$n]}) mac is mac=$mac"
|
||||||
|
[[ $db -eq 1 ]] && info "canping() ${hname[$n]} (${ip[$n]}) is $success"
|
||||||
|
|
||||||
if [[ $success -eq 1 ]]; then
|
if [[ $success -eq 1 ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -1947,12 +1958,12 @@ fi
|
||||||
#done
|
#done
|
||||||
#wait
|
#wait
|
||||||
|
|
||||||
if [[ $robtest -eq 1 ]]; then
|
#if [[ $robtest -eq 1 ]]; then
|
||||||
for x in ${!zname[@]}; do
|
# for x in ${!zname[@]}; do
|
||||||
echo "zone ${zname[$x]} owner is [${zowner[$x]}]"
|
# echo "zone ${zname[$x]} owner is [${zowner[$x]}]"
|
||||||
done
|
# done
|
||||||
exit 1
|
# exit 1
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
if [[ $showwho -eq 1 ]]; then
|
if [[ $showwho -eq 1 ]]; then
|
||||||
# get max phone name length
|
# get max phone name length
|
||||||
|
@ -1994,7 +2005,7 @@ elif [[ $showwho -eq 2 ]]; then
|
||||||
|
|
||||||
n=0
|
n=0
|
||||||
for x in $alldevs; do
|
for x in $alldevs; do
|
||||||
canping ${x} >/dev/null 2>&1
|
canping ${x} 2>&1
|
||||||
pingres[$n]=$?
|
pingres[$n]=$?
|
||||||
n=$((n + 1))
|
n=$((n + 1))
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue