jablonka.czprosek.czf

wifimon

Subversion Repositories:
[/] [trunk/] [wifimon] - Blame information for rev 7

 

Line No. Rev Author Line
12simandl#!/bin/bash
23simandl# authors : Petr Simandl www.simandl.cz
37simandl# : Fyzik
4# release date : 10/2/2003
52simandl# name : wifimon
67simandl# version : 0.4beta2
72simandl# description : hostap powered wifi card monitoring
8# license : GPL
9 
107simandlwl_iwccmd="/usr/local/sbin/iwconfig"
11wl_ifccmd="/sbin/ifconfig"
12wl_hnmcmd="/bin/hostname"
132simandlwl_hostap="/proc/net/hostap/"
14wl_wireless="/proc/net/wireless"
153simandlwl_arp="/proc/net/arp"
162simandl 
174simandlwlc_red=`tput setaf 1`
18wlc_green=`tput setaf 2`
19wlc_brown=`tput setaf 3`
20wlc_blue=`tput setaf 4`
21wlc_magenta=`tput setaf 5`
22wlc_lblue=`tput setaf 6`
23wlc_grey=`tput setaf 7`
24wlc_std=`tput sgr0`
25 
26wlc_ip=$wlc_lblue # ip address color
27wlc_mac=$wlc_magenta # mac address color
28wlc_sig=$wlc_red # signal number color
29wlc_bar=$wlc_green # signal bar color
307simandl 
31wl_webpage="/tmp/wifimon.htm"
32wl_header="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
33wl_header_static="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
34wl_footer="</pre></body></html>"
35 
36wlm_no_managed_or_master=" neni ani Master ani Managed..."
37wlm_number_of_clients="Pocet asociovanych klientu : "
38wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "
39#wlm_no_managed_or_master=" is not Master or Managed..."
40#wlm_number_of_clients="Number of associated clients : "
41 
422simandl######################################################################
434simandlw_bw()
44{
456simandl wlc_ip=""
46 wlc_mac=""
47 wlc_sig=""
48 wlc_bar=""
49 wlc_std=""
504simandl}
51######################################################################
522simandlw_bar()
53{
544simandl echo -n "${wlc_bar}"
552simandl until [ "$wl_cnt" -eq -1 ]
56 do
577simandl printf "="
582simandl wl_cnt=$(($wl_cnt - 1 ))
59 done
60 printf " \n"
616simandl echo -n "${wlc_std}"
62# tput sgr0
632simandl} # w_bar
64 
65######################################################################
66w_managed()
677simandl{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'
68 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
69 echo $wl_iwctxt | awk '{print $9,$6,$11" "}'
70 #echo $wl_iwctxt | awk '{print $27,$28,$29,$31,$32" "}'
71 #cat $wl_wireless | grep $wl_iface
72 wl_wtxt=`cat $wl_wireless | grep $wl_iface | awk '{print $3,$4,$5}' | sed 's/\.//g'`
73 wl_quality=`echo $wl_wtxt | awk '{print $1}'`
74 wl_signal=`echo $wl_wtxt | awk '{print $2}'`
752simandl wl_signal=$(($wl_signal - 256))
767simandl wl_noise=`echo $wl_wtxt | awk '{print $3}'`
772simandl wl_noise=$(($wl_noise - 256))
785simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
792simandl wl_cnt=$wl_quality
80 w_bar
817simandl #wl_cnt=$(($wl_cnt + 100))
82 #w_bar
832simandl echo
84} # w_managed
85 
86######################################################################
87w_master()
885simandl{ if [ $wcm_oneline -eq 0 ]
89 then
907simandl echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'
91 echo $wl_iwctxt | awk '{print $6,$9,$11" "}'
925simandl else
937simandl echo $wl_iwctxt | awk '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g'
945simandl fi
952simandl 
96 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
97 echo $wlm_number_of_clients $wl_numcl
985simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
993simandl for wl_mac in `ls $wl_hostap$wl_iface | grep 00 `
1002simandl do
1017simandl wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx'`
102 wl_cnt=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'`
103 wl_umac=`echo $wl_mac | tr abcdef ABCDEF`
104 wl_ipc=`cat $wl_arp | grep $wl_umac | awk '{print $1}'` # IP adresa peeru z arp tabulky
1055simandl if [ $wcm_oneline -eq 0 ]
106 then
107 echo -n "${wlc_ip}$wl_ipc${wlc_std} "
1087simandl echo -n "${wlc_mac}$wl_umac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} "
109 echo $wl_macparam | awk '{print $1,$2" "}'
1105simandl w_bar
111 else
1127simandl #echo -n "${wlc_ip}$wl_ipc${wlc_std} "
113 echo -n "${wlc_mac}$wl_umac${wlc_std} ${wlc_sig}$wl_cnt${wlc_std} "
114 #echo -n $wl_macparam | awk '{print $1,$2" "}'
1155simandl w_bar
116 fi
1174simandl done
1182simandl 
119 echo
120} # w_master
121 
122######################################################################
123w_iface()
1247simandl{ wl_iwctxt=`$wl_iwccmd $wl_iface | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/g'`
125 wl_mode=`echo $wl_iwctxt | awk '{print $5}' | sed 's/Mode://g'`
1262simandl if [ "a$wl_mode" = "aManaged" ]
127 then
128 w_managed
129 elif [ "a$wl_mode" = "aMaster" ]
130 then
131 w_master
132 else
133 echo $wl_iface $wlm_no_managed_or_master
134 echo
135 fi
136}
137 
138######################################################################
1395simandlw_help()
140{
1413simandl echo Pouziti: wifimon [param]
142 echo param:
1435simandl echo -html generovani html stranky
1447simandl echo -col barevny cyklicky vypis na obrazovku
1455simandl echo -once vypsani jen jednoho vypisu a pak program skonci
146 echo -oneline vypsani klientu na jednu linku
147 echo -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
1483simandl echo bez parametru cyklicky vypis na obrazovku
1495simandl exit 0
150}
151######################################################################
152######################################################################
1532simandl 
1545simandlwl_unknown=""
155wl_cnt=1
156wcm_clear=1
157wcm_once=0
158wcm_col=0
159wcm_oneline=0
160wcm_html=0
161wcm_ifc=""
162 
1636simandl# parsing input parameters
1645simandlwhile [ "a$1" != "a" ]
165do
166 case $1 in
167 -help)
168 w_help
169 ;;
170 -once)
171 wcm_once=1
172 shift
173 ;;
174 -oneline)
175 wcm_oneline=1
176 shift
177 ;;
178 -col)
179 wcm_col=1
180 shift
181 ;;
182 -html)
183 wcm_html=1
184 shift
185 ;;
186 *)
187 wl_flg=0
188 for wl_iface in `ls $wl_hostap`
189 do
190 if [ "a-$wl_iface" = "a$1" ]
191 then
192 wcm_ifc="$wcm_ifc $wl_iface"
193 wl_flg=1
194 fi
195 done
196 if [ $wl_flg -eq 0 ]
197 then
198 wl_unknown="$wl_unknown$1 "
199 fi
200 shift
201 esac
202done
203 
2046simandl# printing the list of bad parameters (if there are some)
2055simandlif [ "a$wl_unknown" != "a" ]
206then
207 echo "$wlm_unknown $wl_unknown"
208 w_help
209fi
210 
2116simandl# if no interface is selected then all available are choosen
2125simandlif [ "a$wcm_ifc" = "a" ]
213then
214 wcm_ifc=`ls $wl_hostap`
215fi
216 
2176simandl# setting for old and last same value to avoid double clear after start
218wl_numcllast=0
219wl_numclold=0
220for wl_iface in $wcm_ifc
221do
222 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
223 wl_numcllast=$(($wl_numcllast + $wl_numcl))
224done
225wl_numclold=$wl_numcllast
226 
227if [ $wcm_col -eq 0 ]
228then
229 w_bw
230fi
231 
232while [ 1 ]
2335simandl do
234 if [ $wl_numcllast -ne $wl_numclold ]
235 then
236 wl_numclold=$wl_numcllast
237 wcm_clear=1
238 fi
2397simandl if [ $wcm_clear -eq 1 ]
2405simandl then
2417simandl clear
2425simandl wcm_clear=0
243 fi
244 wl_numcllast=0
2457simandl if [ $wcm_html -eq 1 ]
2465simandl then
2477simandl w_bw
248 echo $wl_header
249 for wl_iface in $wcm_ifc
250 do
251 w_iface
252 done
253 echo $wl_footer
254 else
255 tput cup 0 0
256 for wl_iface in $wcm_ifc
257 do
258 w_iface
259 done
2605simandl fi
261 
262 if [ $wcm_once -eq 1 ]
263 then
264 exit 0
265 fi
266 sleep 1
2676simandldone
2685simandl 
269exit 0
270 

Powered by WebSVN 2.2.1