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