Last active
August 29, 2015 14:13
-
-
Save WJDigby/66ecf64a748dcf76293a to your computer and use it in GitHub Desktop.
Get average signal quality and power level from /proc/net/wireless.
This file contains 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
#!/bin/bash | |
#The War Room Blog | |
#http://warroom.securestate.com/index.php/cya-cover-your-alfa-part-ii/ | |
x=1 # set the variables | |
HIGH_QUAL=$(cat /proc/net/wireless | awk 'END { print $3 }' | sed 's/\.$//') # parse the output of /proc/net/wireless to get integers only | |
LOW_QUAL=$(cat /proc/net/wireless | awk 'END { print $3 }' | sed 's/\.$//') | |
AVG_QUAL=$(cat /proc/net/wireless | awk 'END { print $3 }' | sed 's/\.$//') | |
HIGH_LVL=$(cat /proc/net/wireless | awk 'END { print $4 }'| sed 's/\.$//') | |
LOW_LVL=$(cat /proc/net/wireless | awk 'END { print $4 }'| sed 's/\.$//') | |
AVG_LVL=$(cat /proc/net/wireless | awk 'END { print $4 }'| sed 's/\.$//') | |
echo "working..." | |
while [ $x -le 600 ] # populate the array for 600 seconds | |
do | |
QUAL_ARRAY[$x]=$(cat /proc/net/wireless | awk 'END { print $3 }' | sed 's/\.$//') # populate arrays with the values from /proc/net/wireless | |
LVL_ARRAY[$x]=$(cat /proc/net/wireless | awk 'END { print $4 }' | sed 's/\.$//') | |
x=$(( $x + 1)) | |
sleep 1 | |
done | |
for i in "${QUAL_ARRAY[@]}" | |
do | |
if [[ "$i" -gt "$HIGH_QUAL" ]]; then # set the high quality | |
HIGH_QUAL="$i" | |
fi | |
if [[ "$i" -lt "$LOW_QUAL" ]]; then # set the low quality | |
LOW_QUAL="$i" | |
fi | |
AVG_QUAL=$(($AVG_QUAL + $i)) # this isn't the actual average, just a running sum | |
done | |
for i in "${LVL_ARRAY[@]}" | |
do | |
if [[ "$i" -gt "$HIGH_LVL" ]]; then | |
HIGH_LVL="$i" | |
fi | |
if [[ "$i" -lt "$LOW_LVL" ]]; then | |
LOW_LVL="$i" | |
fi | |
AVG_LVL=$(($AVG_LVL + $i)) | |
done | |
AVG_QUAL=$(($AVG_QUAL/600)) # divide the running sum from line 29 by the number of seconds from line 13 | |
AVG_LVL=$(($AVG_LVL/600)) | |
echo "Highest Quality:" $HIGH_QUAL | |
echo "Lowest Quality:" $LOW_QUAL | |
echo "Average Quality (integer):" $AVG_QUAL | |
echo "Highest Level:" $HIGH_LVL | |
echo "Lowest Level:" $LOW_LVL | |
echo "Average Level (integer):" $AVG_LVL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment