PDA

Bekijk de volledige versie : Updated signal measurement script



Miki
21-12-2005, 05:11
Based on the scripts by pekr and Quoing.

Added: list WDS peers as well
Added: IP address lookup in ARP cache if not in DHCP log (shows '*' after IP)
Added: DNS lookup (disable with -n option or in script if it causes too much load)
Changed: Configurable signal strength bar size
Some tidying up, clear screen now works for me (output starts from the top of the screen).
Tested on our small community network (WDS, 1x WL-500gx, 3x WL-500g, several clients).

Sample output:

rate is 24 Mbps

assoclist
xx:xx:xx:xx:xx:xx |***** | -71 | 192.168.1.135* MikiM.xxxxxxxxx.xxx

wds
xx:xx:xx:xx:xx:xx | | N/A |
xx:xx:xx:xx:xx:xx |**** | -77 | 192.168.1.1* router.xxxxxxxxx.xxx

As you can see, a client (my PDA) is connected to my box at home, one of our other backbone links is down (antenna problems), but link to the main router/gateway is still up :-)

Enjoy :-)


#/bin/sh

dns=y # Enable DNS lookup
sl=10 # length of signal bar
d=5 # signal scaling
# range=$(($l * $d))

set -f # No globbing
if [ "$1" = "-n" ]; then dns=n; shift; fi
while true; do
echo -ne "\f" #clear screen
wl rate #write wifi rate

types="assoclist wds"
for t in $types; do
echo
echo $t
macs=`wl $t | sed s/$t\ //`
for m in $macs; do
sig=`wl rssi $m | sed s/rssi\ is\ //`
if [ "$sig" -eq "0" ]; then s=-100; sig="N/A"; else s=$sig; fi
s=$(( ($s + 100) / $d))
if [ "$s" -gt "$sl" ]; then s=$sl; fi
e=$(($sl - $s))
sb=`printf "%${s}s" "" | sed -e "s/ /*/g"; printf "%${e}s" ""`

ip=""; h=""; x=""
#get IP from dnsmasq dhcp log, field 3
li=`cat /tmp/dnsmasq.log 2>/dev/null | grep -i $m`
if [ "$li" != "" ]; then
ip=`echo $li | while read f1 f2 f3 rest; do echo $f3; done`
else
#get IP from ARP cache, field 1
li=`cat /proc/net/arp | grep -i $m`
if [ "$li" != "" ]; then
ip=`echo $li | while read f1 rest; do echo $f1; done`
x="*"
fi
fi
if [ "$dns" = "y" ]; then
if [ "$ip" != "" ]; then
#lookup hostname
h=`nslookup $ip | grep Name: | while read f1 f2; do echo $f2; done`
fi
fi
ip="$ip$x"

echo "$m |$sb| $sig | $ip $h"
done
done
sleep 1
done

Miki
21-12-2005, 09:58
Here's an updated version.

Added: Optional persistent (pimped out?) display, updates without clearing the screen
Added: Update interval setting
Added: Usage info


Usage: rssimon [-h] [-i interval] [-n] [-p]
Options:
-h Show usage information
-i Interval between updates (in seconds)
-n No DNS lookups
-p Persistent display


Note: Persistent mode might not work properly with all terminal programs (works ok with PuTTY and Windows telnet), so it's not the default for now.

Enjoy :-)