Created
March 27, 2016 23:45
-
-
Save professorjamesmoriarty/f495e76af03cfdffe02a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
U5ER=something | |
PA55="" | |
MERU=127.0.0.1 | |
DataCache=.CurrentAPlist | |
DevList=.DevList | |
TIM3R=20m | |
function search() { | |
local s=0; | |
for str in "${$array[@]}"; do ##array=zone;search | |
if [ "$str" = "$1" ]; then | |
echo $s | |
return | |
else | |
if [ "$LineNUM" -gt $s ]; then | |
((s++)) | |
else | |
return | |
fi | |
fi | |
done | |
echo "-1" | |
} | |
function contains() { | |
local n=$# | |
local value=${!n} | |
for ((i=1;i < $#;i++)) { | |
if [ "${!i}" == "${value}" ]; then | |
echo "y" | |
return 0 | |
fi | |
} | |
echo "n" | |
return 1 | |
} | |
function pulldata() { | |
clear | |
if [ -z $PA55 ]; then | |
echo Password for $USER ? | |
read -r -s PA55 | |
fi | |
sshpass -p"$PA55" ssh $U5ER@$MERU 'sh stations' > $DataCache | |
} | |
zone1=( "AP01" "AP02" ) | |
zone2=( "AP03" "AP04" ) | |
##do stuff here in a loop | |
while true | |
do | |
clear | |
pulldata | |
awk 'NR>2' $DataCache | |
LineNUM=$(cat $DataCache | wc -l) | |
CurrentMACS=($(awk '{ print $1 }' $DataCache )) | |
CurrentAPS=($(awk '{ print $3 }' $DataCache )) | |
MACS=($(awk '{ print $1 }' $DevList )) | |
ZONES=($(awk '{ print $2 }' $DevList )) | |
## compare arrays [ CurrentMACS + MACS ] for matched values | |
## search matched values with search function for index numbers in MACS | |
## search matched values with search function for index numbers in CurrentMACS | |
## search for resulted MACS index numbers to ZONES to get zone number | |
## search for resulted CurrentMACS index numbers to match with CurrentAPs to see what APs they are on | |
## use contains to see if zone number array contains CurrentAPs value | |
## if zone number contains CurrentAPs value then MAC == good else == log to file | |
## if this works add a timer on the logged daya to give an alert for being out of zone to long | |
## grep $DataCache to compare alert to staff devices if == true cancel alert | |
#if [ $(contains "${zone1[@]}" "AP01") == "y" ]; then | |
# echo "contains AP01" | |
#fi | |
#if [ $(contains "${zone2[@]}" "AP05") == "y" ]; then | |
# echo "contains AP05" | |
#else | |
# echo "doesnt contain AP05" | |
#fi | |
sleep $TIM3R | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment