wifimon |
Subversion Repositories: |
Rev 12 | Rev 13 | |
---|---|---|
Line 2... | Line 2... | |
# authors : Petr Simandl www.simandl.cz |
# authors : Petr Simandl www.simandl.cz | |
# : Fyzik, Covex |
# : Fyzik, Covex | |
# release date : 1/8/2003 |
# release date : 14/8/2003 | |
# name : wifimon |
# name : wifimon | |
# description : hostap powered wifi card monitoring |
# description : hostap powered wifi card monitoring | |
# license : GPL |
# license : GPL | |
|
| |
wl_version="0.4beta7" |
wl_version="0.4beta8" | |
|
| |
wl_iwccmd=`which iwconfig` |
PATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin | |
| ||
wl_iwccmd=`/usr/bin/which iwconfig` | ||
if [ "$wl_iwccmd x" = " x" ] |
if [ "$wl_iwccmd x" = " x" ] | |
then |
then | |
echo "iwconfig not found" |
echo "iwconfig not found" | |
exit 1 |
exit 1 | |
fi |
fi | |
Line 20... | Line 22... | |
wl_wireless="/proc/net/wireless" |
wl_wireless="/proc/net/wireless" | |
wl_arp="/proc/net/arp" |
wl_arp="/proc/net/arp" | |
wl_dhcpcnf="/etc/dhcpd.conf" |
wl_dhcpcnf="/etc/dhcpd.conf" | |
|
| |
|
| |
wl_webpage="/tmp/wifimon.htm" |
wl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" | |
wl_header="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" |
wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" | |
wl_footer="</pre></body></html>" |
wl_footer="</pre></body></html>" | |
|
| |
wlm_no_managed_or_master=" neni ani Master ani Managed..." |
wlm_no_managed_or_master=" neni ani Master ani Managed..." | |
wlm_number_of_clients="Pocet asociovanych klientu : " |
wlm_number_of_clients="Pocet asociovanych klientu : " | |
wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : " |
wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : " | |
#wlm_no_managed_or_master=" is not Master or Managed..." |
#wlm_no_managed_or_master=" is not Master or Managed..." | |
#wlm_number_of_clients="Number of associated clients : " |
#wlm_number_of_clients="Number of associated clients : " | |
|
||
|
| |
wlch_signal="=" |
wlch_signal="=" | |
wlch_noise="*" |
wlch_noise="*" | |
|
| |
###################################################################### |
###################################################################### | |
Line 82... | Line 83... | |
printf " \n" |
printf " \n" | |
echo -n "${wlc_std}" |
echo -n "${wlc_std}" | |
# tput sgr0 |
# tput sgr0 | |
} # w_bar |
} # w_bar | |
|
| |
###################################################################### | ||
w_pkts() | ||
{ | ||
wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'` | ||
wl_nt1=`echo $wl_macpkts | awk '{print $2}'` | ||
wl_nt2=`echo $wl_macpkts | awk '{print $4}'` | ||
wl_nt5=`echo $wl_macpkts | awk '{print $6}'` | ||
wl_nt11=`echo $wl_macpkts | awk '{print $8}'` | ||
wl_nr1=`echo $wl_macpkts | awk '{print $10}'` | ||
wl_nr2=`echo $wl_macpkts | awk '{print $12}'` | ||
wl_nr5=`echo $wl_macpkts | awk '{print $14}'` | ||
wl_nr11=`echo $wl_macpkts | awk '{print $16}'` | ||
| ||
if [ $wcm_ppkts -eq 1 ] | ||
then | ||
wl_pksize=$((98)) | ||
wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11)) | ||
if [ "$wl_nt1" -eq 0 ] | ||
then | ||
wl_nt1n="00" | ||
else | ||
wl_nt1n=$(($wl_pksize * $wl_nt1 / $wl_nt + 1)) | ||
[ "$wl_nt1n" -lt 10 ] && wl_nt1n="0"$wl_nt1n | ||
fi | ||
if [ "$wl_nt2" -eq 0 ] | ||
then | ||
wl_nt2n="00" | ||
else | ||
wl_nt2n=$(($wl_pksize * $wl_nt2 / $wl_nt + 1)) | ||
[ "$wl_nt2n" -lt 10 ] && wl_nt2n="0"$wl_nt2n | ||
fi | ||
if [ "$wl_nt5" -eq 0 ] | ||
then | ||
wl_nt5n="00" | ||
else | ||
wl_nt5n=$(($wl_pksize * $wl_nt5 / $wl_nt + 1)) | ||
[ "$wl_nt5n" -lt 10 ] && wl_nt5n="0"$wl_nt5n | ||
fi | ||
if [ "$wl_nt11" -eq 0 ] | ||
then | ||
wl_nt11n="00" | ||
else | ||
wl_nt11n=$(($wl_pksize * $wl_nt11 / $wl_nt + 1)) | ||
[ "$wl_nt11n" -lt 10 ] && wl_nt11n="0"$wl_nt11n | ||
fi | ||
wl_nr=$((1 + $wl_nr1 + $wl_nr2 + wl_nr5 + wl_nr11)) | ||
if [ "$wl_nr1" -eq 0 ] | ||
then | ||
wl_nr1n="00" | ||
else | ||
wl_nr1n=$(($wl_pksize * $wl_nr1 / $wl_nr + 1)) | ||
[ "$wl_nr1n" -lt 10 ] && wl_nr1n="0"$wl_nr1n | ||
fi | ||
if [ "$wl_nr2" -eq 0 ] | ||
then | ||
wl_nr2n="00" | ||
else | ||
wl_nr2n=$(($wl_pksize * $wl_nr2 / $wl_nr + 1)) | ||
[ "$wl_nr2n" -lt 10 ] && wl_nr2n="0"$wl_nr2n | ||
fi | ||
if [ "$wl_nr5" -eq 0 ] | ||
then | ||
wl_nr5n="00" | ||
else | ||
wl_nr5n=$(($wl_pksize * $wl_nr5 / $wl_nr + 1)) | ||
[ "$wl_nr5n" -lt 10 ] && wl_nr5n="0"$wl_nr5n | ||
fi | ||
if [ "$wl_nr11" -eq 0 ] | ||
then | ||
wl_nr11n="00" | ||
else | ||
wl_nr11n=$(($wl_pksize * $wl_nr11 / $wl_nr + 1)) | ||
[ "$wl_nr11n" -lt 10 ] && wl_nr11n="0"$wl_nr11n | ||
fi | ||
echo -n "Tx" $wl_nt1n $wl_nt2n $wl_nt5n $wl_nt11n "Rx" $wl_nr1n $wl_nr2n $wl_nr5n $wl_nr11n "" | ||
fi | ||
| ||
[ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 "" | ||
| ||
} # w_pkts | ||
###################################################################### |
###################################################################### | |
w_managed() |
w_managed() | |
{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}' |
{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}' | |
echo -n `$wl_ifccmd $wl_iface | grep -E "inet addr|inet adr" | awk '{print $2" "}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfig |
echo -n `$wl_ifccmd $wl_iface | grep -E "inet addr|inet adr" | awk '{print $2" "}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfig | |
echo $wl_iwctxt | awk '{print $9,$6,$11" "}' |
echo $wl_iwctxt | awk '{print $9,$6,$11" "}' | |
#echo $wl_iwctxt | awk '{print $27,$28,$29,$31,$32" "}' |
||
#cat $wl_wireless | grep $wl_iface |
||
wl_wtxt=`cat $wl_wireless | grep $wl_iface | awk '{print $3,$4,$5}' | sed 's/\.//g'` |
wl_wtxt=`cat $wl_wireless | grep $wl_iface | awk '{print $3,$4,$5}' | sed 's/\.//g'` | |
wl_quality=`echo $wl_wtxt | awk '{print $1}'` |
wl_quality=`echo $wl_wtxt | awk '{print $1}'` | |
wl_signal=`echo $wl_wtxt | awk '{print $2}'` |
wl_signal=`echo $wl_wtxt | awk '{print $2}'` | |
wl_signal=$(($wl_signal - 256)) |
wl_signal=$(($wl_signal - 256)) | |
wl_noise=`echo $wl_wtxt | awk '{print $3}'` |
wl_noise=`echo $wl_wtxt | awk '{print $3}'` | |
wl_noise=$(($wl_noise - 256)) |
wl_noise=$(($wl_noise - 256)) | |
echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise " |
echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise " | |
wl_cnt=$wl_quality |
wl_cnt=$wl_quality | |
w_bar |
w_bar | |
#wl_cnt=$(($wl_cnt + 100)) |
||
#w_bar |
||
echo |
echo | |
} # w_managed |
} # w_managed | |
|
| |
###################################################################### |
###################################################################### | |
w_master() |
w_master() | |
Line 115... | Line 192... | |
echo $wl_iwctxt | awk '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g' |
echo $wl_iwctxt | awk '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g' | |
fi |
fi | |
|
| |
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` |
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` | |
echo $wlm_number_of_clients $wl_numcl |
echo $wlm_number_of_clients $wl_numcl | |
| ||
wl_numcllast=$(($wl_numcllast + $wl_numcl)) |
wl_numcllast=$(($wl_numcllast + $wl_numcl)) | |
| ||
for wl_mac in `ls $wl_hostap$wl_iface | grep 00 ` |
for wl_mac in `ls $wl_hostap$wl_iface | grep 00 ` | |
do |
do | |
wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'` |
wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'` | |
wl_signal=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'` |
wl_signal=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'` | |
wl_silence=`echo $wl_macparam | awk '{print $4}' | sed 's/silence=//g'` |
wl_silence=`echo $wl_macparam | awk '{print $4}' | sed 's/silence=//g'` | |
wl_cnt=$(($wl_signal - $wl_silence)) |
wl_cnt=$(($wl_signal - $wl_silence)) | |
wl_ipc=`cat $wl_arp | grep -i $wl_mac | awk '{print $1}'` # IP adresa peeru z arp tabulky |
wl_ipc=`cat $wl_arp | grep -i $wl_mac | awk '{print $1}'` # IP adresa peeru z arp tabulky | |
wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | awk '{print $2}'` |
wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | awk '{print $2}'` | |
| ||
if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] | ||
then | ||
w_pkts | ||
fi | ||
| ||
if [ $wcm_oneline -eq 0 ] |
if [ $wcm_oneline -eq 0 ] | |
then |
then | |
echo -n "$wl_name " |
echo -n "$wl_name " | |
echo -n "${wlc_ip}$wl_ipc${wlc_std} " |
echo -n "${wlc_ip}$wl_ipc${wlc_std} " | |
echo -n "${wlc_mac}$wl_mac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} " |
echo -n "${wlc_mac}$wl_mac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} " | |
echo $wl_macparam | awk '{print $1,$2" "}' |
echo $wl_macparam | awk '{print $1,$2" "}' | |
w_bar |
w_bar | |
else |
else | |
echo -n "$wl_name " |
echo -n "$wl_name " | |
#echo -n "${wlc_ip}$wl_ipc${wlc_std} " |
||
echo -n "${wlc_mac}$wl_mac${wlc_std} ${wlc_sig}$wl_cnt${wlc_std} " |
echo -n "${wlc_mac}$wl_mac${wlc_std} ${wlc_sig}$wl_cnt${wlc_std} " | |
#echo -n $wl_macparam | awk '{print $1,$2" "}' |
||
w_bar |
w_bar | |
fi |
fi | |
done |
done | |
|
| |
echo |
echo | |
} # w_master |
} # w_master | |
|
| |
###################################################################### |
###################################################################### | |
w_iface() |
w_iface() | |
{ wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/g'` |
{ wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/'` | |
wl_mode=`echo $wl_iwctxt | awk '{print $5}' | sed 's/Mode://g'` |
wl_mode=`echo $wl_iwctxt | awk '{print $5}' | sed 's/Mode://g'` | |
if [ "a$wl_mode" = "aManaged" ] |
if [ "a$wl_mode" = "aManaged" ] | |
then |
then | |
w_managed |
w_managed | |
elif [ "a$wl_mode" = "aAd-Hoc" ] |
elif [ "a$wl_mode" = "aAd-Hoc" ] | |
Line 175... | Line 258... | |
{ |
{ | |
echo Pouziti: wifimon [param] |
echo Pouziti: wifimon [param] | |
echo param: |
echo param: | |
echo -v vypise verzi |
echo -v vypise verzi | |
echo -html generovani html stranky |
echo -html generovani html stranky | |
echo -col barevny cyklicky vypis na obrazovku |
echo -col barevny vypis na obrazovku | |
echo -once vypsani jen jednoho vypisu a pak program skonci |
echo -once vypsani jen jednoho vypisu a pak program skonci | |
echo -oneline vypsani klientu na jednu linku |
echo -oneline vypsani klientu na jednu linku | |
echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty | ||
echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty | ||
echo -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi |
echo -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi | |
echo bez parametru cyklicky vypis na obrazovku |
echo bez parametru cyklicky vypis na obrazovku | |
exit 0 |
exit 0 | |
} |
} | |
###################################################################### |
###################################################################### | |
Line 192... | Line 277... | |
wcm_clear=1 |
wcm_clear=1 | |
wcm_once=0 |
wcm_once=0 | |
wcm_col=0 |
wcm_col=0 | |
wcm_oneline=0 |
wcm_oneline=0 | |
wcm_html=0 |
wcm_html=0 | |
wcm_ppkts=0 | ||
wcm_pkts=0 | ||
wcm_ifc="" |
wcm_ifc="" | |
|
| |
# parsing input parameters |
# parsing input parameters | |
while [ "a$1" != "a" ] |
while [ "a$1" != "a" ] | |
do |
do | |
Line 218... | Line 305... | |
wcm_col=1 |
wcm_col=1 | |
shift |
shift | |
;; |
;; | |
-html) |
-html) | |
wcm_html=1 |
wcm_html=1 | |
shift | ||
;; | ||
-ppkts) | ||
wcm_ppkts=1 | ||
shift | ||
;; | ||
-pkts) | ||
wcm_pkts=1 | ||
shift |
shift | |
;; |
;; | |
*) |
*) | |
wl_flg=0 |
wl_flg=0 | |
for wl_iface in `ls $wl_hostap` |
for wl_iface in `ls $wl_hostap` | |
Line 266... | Line 361... | |
if [ $wcm_col -eq 0 ] |
if [ $wcm_col -eq 0 ] | |
then |
then | |
w_bw |
w_bw | |
else |
else | |
w_col |
w_col | |
fi | ||
| ||
if [ $wcm_html -eq 1 ] | ||
then | ||
w_bw | ||
[ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh | ||
for wl_iface in $wcm_ifc | ||
do | ||
w_iface | ||
done | ||
echo $wl_footer | ||
exit 0 | ||
fi |
fi | |
|
| |
while [ 1 ] |
while [ 1 ] | |
do |
do | |
if [ $wl_numcllast -ne $wl_numclold ] |
if [ $wl_numcllast -ne $wl_numclold ] | |
Line 281... | Line 388... | |
then |
then | |
clear |
clear | |
wcm_clear=0 |
wcm_clear=0 | |
fi |
fi | |
wl_numcllast=0 |
wl_numcllast=0 | |
if [ $wcm_html -eq 1 ] |
| |
then |
[ -e /usr/bin/tput ] && tput cup 0 0 || clear | |
w_bw |
for wl_iface in $wcm_ifc | |
echo $wl_header |
do | |
for wl_iface in $wcm_ifc |
w_iface | |
do |
done | |
w_iface |
||
done |
||
echo $wl_footer |
||
else |
||
[ -e /usr/bin/tput ] && tput cup 0 0 || clear |
||
for wl_iface in $wcm_ifc |
||
do |
||
w_iface |
||
done |
||
fi |
||
|
| |
if [ $wcm_once -eq 1 ] |
if [ $wcm_once -eq 1 ] | |
then |
then | |
exit 0 |
exit 0 | |
fi |
fi |