jablonka.czprosek.czf

wifimon

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

 

Line No. Rev Author Line
12simandl#!/bin/bash
23simandl# authors : Petr Simandl www.simandl.cz
322simandl# : Fyzik, Covex, Tydyt, Thunder.m
4# release date : 16/03/2006
52simandl# name : wifimon
621simandl# description : hostap and madwifi powered card monitoring
72simandl# license : GPL
821simandl######################################################################
92simandl 
1023simandlwl_version="0.5.6" #+ifrename support
1111simandl 
1221simandl######################################################################
13#custom settings
14 
1513simandlPATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin
16 
1714simandlwl_iwccmd=`which iwconfig`
1821simandlwl_iwlcmd=`which iwlist`
1914simandlwl_ifccmd=`which ifconfig`
20wl_hnmcmd=`which hostname`
21wl_awkcmd=`which awk`
22 
23wl_tptcmde=""
24wl_clrcmde=""
25 
2619simandlwl_sysdev="/proc/sys/dev/"
2714simandlwl_hostap="/proc/net/hostap/"
28wl_wireless="/proc/net/wireless"
29wl_arp="/proc/net/arp"
30wl_dhcpcnf="/etc/dhcpd.conf"
31wl_dhcplss="/var/lib/dhcp/dhcpd.leases"
3217simandl# wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
33# wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
3414simandl 
3521simandlwl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
36wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
37wl_footer="</pre></body></html>"
3814simandl 
3921simandlwlm_no_managed_or_master=" neni ani Master ani Managed..."
40wlm_number_of_clients="Pocet asociovanych klientu : "
41wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "
42#wlm_no_managed_or_master=" is not Master or Managed..."
43#wlm_number_of_clients="Number of associated clients : "
44 
45wlch_signal="="
46wlch_noise="*"
47 
4823simandlw_realiface()
49{
50 wl_realiface="$wl_iface"
51 
52 # ifrename support: this must be set regarding to /etc/iftab
53 #if [ "$wl_iface" = "ath0" ]; then
54 # wl_realiface="wlan0"
55 #fi
56 #if [ "$wl_iface" = "wlan0" ]; then
57 # wl_realiface="wlan1"
58 #fi
59}
60 
6121simandl######################################################################
62#testing basic setings
63 
6412simandlif [ "$wl_iwccmd x" = " x" ]
65 then
66 echo "iwconfig not found"
67 exit 1
68fi
692simandl 
7021simandlif [ "$wl_iwlcmd x" = " x" ]
71 then
72 echo "iwlist not found"
73 exit 1
74fi
75 
7614simandlif [ "$wl_ifccmd x" = " x" ]
77 then
78 echo "ifconfig not found"
79 exit 1
80fi
814simandl 
8214simandlif [ "$wl_hnmcmd x" = " x" ]
83 then
84 echo "hostname not found"
85 exit 1
86fi
87 
88if [ "$wl_awkcmd x" = " x" ]
89 then
90 echo "awk not found"
91 exit 1
92fi
93 
94if [ -e $wl_wireless ]
95 then
96 wl_nop=1
97 else
98 echo "$wl_wireless not found"
99 exit 1
100fi
101 
102if [ -e $wl_arp ]
103 then
104 wl_nop=1
105 else
106 echo "$wl_arp not found"
107 exit 1
108fi
109 
11022simandl#dhcp support
111#if not found trying to set alternative location
112if [ ! -f $wl_dhcpcnf ]; then
113 wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
114fi
115 
116if [ ! -f $wl_dhcplss ]; then
117 wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
118fi
119 
120#if not found a message is printed and /dev/null is used instead
12114simandlif [ -e $wl_dhcpcnf ]
122 then
123 wl_nop=1
124 else
125 echo "$wl_dhcpcnf not found"
126 wl_dhcpcnf="/dev/null"
127fi
128 
129if [ -e $wl_dhcplss ]
130 then
131 wl_nop=1
132 else
133 echo "$wl_dhcplss not found"
134 wl_dhcplss="/dev/null"
135fi
13621simandl######################################################################
13714simandl 
13823simandlif [ -d ${wl_hostap} ]
13921simandl then
140 wlf_hostap=1
141 else
142# echo "${wl_hostap}wlan0 not found"
143 wlf_hostap=0
144fi
1457simandl 
14623simandlif [ -d ${wl_sysdev}ath ]
14721simandl then
148 wlf_madwifi=1
149 else
150# echo "${wl_sysdev}ath0 not found"
151 wlf_madwifi=0
152fi
1537simandl 
15421simandlif [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ]
155 then
15623simandl echo "${wl_hostap} not found"
157 echo "${wl_sysdev}ath not found"
15821simandl exit 1
159fi
16011simandl 
1612simandl######################################################################
16221simandl# procedures
163######################################################################
16411simandlw_col()
16510simandl{
16615simandlwlc_red=`tput setaf 1` # ruda (Red)
167wlc_green=`tput setaf 2` # zelena (Lime)
168wlc_brown=`tput setaf 3` # zluta (Yellow)
169wlc_blue=`tput setaf 4` # modra (Blue)
170wlc_magenta=`tput setaf 5` # fialova (Fuchsia)
171wlc_lblue=`tput setaf 6` # svetle modra (Aqua)
172wlc_grey=`tput setaf 7` # bila (White)
17311simandlwlc_std=`tput sgr0`
174 
17515simandlwlc_pkts=$wlc_red # Rx,Tx info color
17611simandlwlc_ip=$wlc_lblue # ip address color
177wlc_mac=$wlc_magenta # mac address color
17815simandlwlc_name=$wlc_magenta # host name color
17911simandlwlc_sig=$wlc_red # signal number color
180wlc_bar=$wlc_green # signal bar color
18115simandlwlc_noise=$wlc_red # Signal noise color
18210simandl}
183######################################################################
18415simandlw_colh()
185{
186 wlh_pkts="Olive" # signal number color html
187 wlh_ip="Blue" # ip address color html
188 wlh_mac="Fuchsia" # mac address color html
189 wlh_name="Fuchsia" # Host name color html
190 wlh_sig="Red" # signal number color html
191 wlh_bar="Lime" # signal bar color html
192 wlh_noise="Red" # Signal noise color html
193 
194 wlc_pkts="<font color=\"$wlh_pkts\">"
195 wlc_ip="<font color=\"$wlh_ip\">"
196 wlc_mac="<font color=\"$wlh_mac\">"
197 wlc_name="<font color=\"$wlh_name\">"
198 wlc_sig="<font color=\"$wlh_sig\">"
199 wlc_bar="<font color=\"$wlh_bar\">"
200 wlc_noise="<font color=\"$wlh_noise\">"
201 wlc_std="</font>"
202}
203######################################################################
2044simandlw_bw()
205{
20615simandl wlc_pkts=""
2076simandl wlc_ip=""
208 wlc_mac=""
209 wlc_sig=""
210 wlc_bar=""
21115simandl wlc_noise=""
2126simandl wlc_std=""
2134simandl}
214######################################################################
2152simandlw_bar()
216{
21711simandl wl_neg=`expr $wl_cnt \< 0 `
218 if [ "$wl_neg" -eq 1 ]
219 then
22015simandl echo -n "${wlc_noise}"
22111simandl wl_cnt=$(($wl_cnt * -1 ))
222 wl_bar=$wlch_noise
223 else
22415simandl echo -n "${wlc_bar}"
22511simandl wl_bar=$wlch_signal
226 fi
2272simandl until [ "$wl_cnt" -eq -1 ]
228 do
22911simandl echo -n "$wl_bar"
2302simandl wl_cnt=$(($wl_cnt - 1 ))
231 done
232 printf " \n"
2336simandl echo -n "${wlc_std}"
23411simandl# tput sgr0
2352simandl} # w_bar
236 
237######################################################################
23813simandlw_pkts()
239{
240 wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'`
24114simandl wl_nt1=`echo $wl_macpkts | $wl_awkcmd '{print $2}'`
242 wl_nt2=`echo $wl_macpkts | $wl_awkcmd '{print $4}'`
243 wl_nt5=`echo $wl_macpkts | $wl_awkcmd '{print $6}'`
244 wl_nt11=`echo $wl_macpkts | $wl_awkcmd '{print $8}'`
245 wl_nr1=`echo $wl_macpkts | $wl_awkcmd '{print $10}'`
246 wl_nr2=`echo $wl_macpkts | $wl_awkcmd '{print $12}'`
247 wl_nr5=`echo $wl_macpkts | $wl_awkcmd '{print $14}'`
248 wl_nr11=`echo $wl_macpkts | $wl_awkcmd '{print $16}'`
24913simandl 
250 if [ $wcm_ppkts -eq 1 ]
251 then
252 wl_pksize=$((98))
253 wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11))
254 if [ "$wl_nt1" -eq 0 ]
255 then
256 wl_nt1n="00"
257 else
258 wl_nt1n=$(($wl_pksize * $wl_nt1 / $wl_nt + 1))
259 [ "$wl_nt1n" -lt 10 ] && wl_nt1n="0"$wl_nt1n
260 fi
261 if [ "$wl_nt2" -eq 0 ]
262 then
263 wl_nt2n="00"
264 else
265 wl_nt2n=$(($wl_pksize * $wl_nt2 / $wl_nt + 1))
266 [ "$wl_nt2n" -lt 10 ] && wl_nt2n="0"$wl_nt2n
267 fi
268 if [ "$wl_nt5" -eq 0 ]
269 then
270 wl_nt5n="00"
271 else
272 wl_nt5n=$(($wl_pksize * $wl_nt5 / $wl_nt + 1))
273 [ "$wl_nt5n" -lt 10 ] && wl_nt5n="0"$wl_nt5n
274 fi
275 if [ "$wl_nt11" -eq 0 ]
276 then
277 wl_nt11n="00"
278 else
279 wl_nt11n=$(($wl_pksize * $wl_nt11 / $wl_nt + 1))
280 [ "$wl_nt11n" -lt 10 ] && wl_nt11n="0"$wl_nt11n
281 fi
282 wl_nr=$((1 + $wl_nr1 + $wl_nr2 + wl_nr5 + wl_nr11))
283 if [ "$wl_nr1" -eq 0 ]
284 then
285 wl_nr1n="00"
286 else
287 wl_nr1n=$(($wl_pksize * $wl_nr1 / $wl_nr + 1))
288 [ "$wl_nr1n" -lt 10 ] && wl_nr1n="0"$wl_nr1n
289 fi
290 if [ "$wl_nr2" -eq 0 ]
291 then
292 wl_nr2n="00"
293 else
294 wl_nr2n=$(($wl_pksize * $wl_nr2 / $wl_nr + 1))
295 [ "$wl_nr2n" -lt 10 ] && wl_nr2n="0"$wl_nr2n
296 fi
297 if [ "$wl_nr5" -eq 0 ]
298 then
299 wl_nr5n="00"
300 else
301 wl_nr5n=$(($wl_pksize * $wl_nr5 / $wl_nr + 1))
302 [ "$wl_nr5n" -lt 10 ] && wl_nr5n="0"$wl_nr5n
303 fi
304 if [ "$wl_nr11" -eq 0 ]
305 then
306 wl_nr11n="00"
307 else
308 wl_nr11n=$(($wl_pksize * $wl_nr11 / $wl_nr + 1))
309 [ "$wl_nr11n" -lt 10 ] && wl_nr11n="0"$wl_nr11n
310 fi
31115simandl echo -n "Tx"${wlc_pkts} $wl_nt1n $wl_nt2n $wl_nt5n $wl_nt11n ${wlc_std}""
312 echo -n "Rx"${wlc_pkts} $wl_nr1n $wl_nr2n $wl_nr5n $wl_nr11n ${wlc_std}""
31313simandl fi
314 
315 [ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 ""
316 
317} # w_pkts
318######################################################################
31917simandlw_managed()
320{ echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
32123simandl echo -n `$wl_ifccmd $wl_realiface | grep -E "inet addr|inet adr" | $wl_awkcmd '{print $2}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfig
32215simandl 
32318simandl if [ $wcm_macoff -eq 0 ]
32415simandl then
32522simandl wl_mac=`echo -n $wl_iwctxt | $wl_awkcmd '{print $8}'`
32618simandl echo -n "${wlc_mac}$wl_mac${wlc_std} "
32715simandl fi
32822simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$10,$11,$12" "}'
32915simandl 
33023simandl wl_wtxt=`cat $wl_wireless | grep $wl_realiface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'`
33114simandl wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'`
332 wl_signal=`echo $wl_wtxt | $wl_awkcmd '{print $2}'`
3332simandl wl_signal=$(($wl_signal - 256))
33414simandl wl_noise=`echo $wl_wtxt | $wl_awkcmd '{print $3}'`
3352simandl wl_noise=$(($wl_noise - 256))
3365simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
3372simandl wl_cnt=$wl_quality
338 w_bar
339 echo
340} # w_managed
341 
342######################################################################
343w_master()
34417simandl{ if [ $wcm_oneline -eq 0 ]
34521simandl then
346 echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
347 if [ $wcm_macoff -eq 1 ]
348 then
34922simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$11,$12" "}'
35021simandl else
35122simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$8,$11,$12" "}'
35221simandl fi
353 else
35422simandl echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11,$12" "}' | sed 's/ [^": ]*:/ /g'
35521simandl fi
356 
357 if [ -d $wl_hostap$wl_iface ]
35815simandl then
35921simandl wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
360 wl_macs=`ls $wl_hostap$wl_iface | grep 00`
3615simandl fi
36221simandl 
363 if [ -d $wl_sysdev$wl_iface ]
364 then
36523simandl wl_numcl=`$wl_iwlcmd $wl_realiface peers | grep -c 00`
366 wl_macs=`iwlist $wl_realiface peers | grep 00 | awk '{print $1}'`
36721simandl fi
368 
3692simandl echo $wlm_number_of_clients $wl_numcl
37013simandl 
3715simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
37213simandl 
37321simandl for wl_mac in $wl_macs
3742simandl do
37521simandl if [ -d $wl_hostap$wl_iface ]
376 then
377 wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'`
37822simandl wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal[=|:]//g'`
379 wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence[=|:]//g'`
38021simandl fi
381 
382 if [ -d $wl_sysdev$wl_iface ]
383 then
38423simandl wl_macparam=`$wl_iwlcmd $wl_realiface peers | grep $wl_mac`
38522simandl wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $5}' | sed 's/level[=|:]//g'`
386 wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $8}' | sed 's/level[=|:]//g'`
38721simandl fi
388 
38911simandl wl_cnt=$(($wl_signal - $wl_silence))
39014simandl wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky
39113simandl 
39214simandl wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'`
393 if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ]
394 then
395 wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac -B 1 | $wl_awkcmd '{print$2,$3}' | grep -i $wl_mac -v | $wl_awkcmd '{print$1}'`
396 if [ "$wl_name" = "" ]
397 then
39817simandl wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'`
39914simandl wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' `
400 fi
401 fi
40221simandl if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] && [ -d $wl_hostap$wl_iface ]
40313simandl then
404 w_pkts
405 fi
406 
4075simandl if [ $wcm_oneline -eq 0 ]
408 then
40915simandl echo -n "${wlc_name}$wl_name${wlc_std} "
4105simandl echo -n "${wlc_ip}$wl_ipc${wlc_std} "
41115simandl if [ $wcm_macoff -eq 0 ]
412 then
413 echo -n "${wlc_mac}$wl_mac${wlc_std} "
414 fi
415 if [ $wcm_threeline -eq 1 ]
416 then
417 echo ""
418 echo -n " "
419 fi
420 echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} "
421 if [ $wcm_rxtx -eq 0 ]
422 then
423 echo ""
424 else
42521simandl if [ -d $wl_hostap$wl_iface ]
426 then
427 echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}'
428 else
429 echo ""
430 fi
43115simandl fi
4325simandl w_bar
433 else
43415simandl if [ $wcm_macoff -eq 0 ]
435 then
436 echo -n "${wlc_mac}$wl_mac${wlc_std} "
437 fi
438 echo -n "${wlc_sig}$wl_cnt${wlc_std} "
43917simandl echo -n "$wl_name "
4405simandl w_bar
441 fi
4424simandl done
44311simandl 
444 echo
4452simandl} # w_master
446 
447######################################################################
448w_iface()
44923simandl{ wl_iwctxt=`$wl_iwccmd $wl_realiface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ dBm/dBm/' | sed 's/ GHz/GHz/' | sed 's/ Mb/Mb/' | sed 's/ Nick/_Nick/' | sed 's/Access Point/Access_Point/'`
45014simandl wl_mode=`echo $wl_iwctxt | $wl_awkcmd '{print $5}' | sed 's/Mode://g'`
4512simandl if [ "a$wl_mode" = "aManaged" ]
452 then
453 w_managed
4548simandl elif [ "a$wl_mode" = "aAd-Hoc" ]
455 then
456 w_managed
4572simandl elif [ "a$wl_mode" = "aMaster" ]
458 then
459 w_master
460 else
46123simandl echo $wl_realiface $wlm_no_managed_or_master
4622simandl echo
463 fi
464}
465 
466######################################################################
46711simandlw_version()
468{
469 echo wifimon $wl_version
470 exit 0
471}
472######################################################################
4735simandlw_help()
474{
47521simandl echo Monitorovani wifi karet pouzivajicich hostap nebo madwifi ovladace
4763simandl echo Pouziti: wifimon [param]
477 echo param:
47811simandl echo -v vypise verzi
4795simandl echo -html generovani html stranky
48013simandl echo -col barevny vypis na obrazovku
4815simandl echo -once vypsani jen jednoho vypisu a pak program skonci
482 echo -oneline vypsani klientu na jednu linku
48315simandl echo -threeline vypsani klienta na trech radcich
48421simandl echo -macoff vypnuti zobrazeni MAC adres
485 echo -wlan0 -ath0 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
486 echo nasledujici parametry ovlivnuji jen karty s hostap:
48715simandl echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta
48813simandl echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
489 echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
4903simandl echo bez parametru cyklicky vypis na obrazovku
4915simandl exit 0
492}
493######################################################################
494######################################################################
4952simandl 
4965simandlwl_unknown=""
497wl_cnt=1
498wcm_clear=1
499wcm_once=0
50023simandlwcm_col=1
5015simandlwcm_oneline=0
50215simandlwcm_threeline=0
5035simandlwcm_html=0
50415simandlwcm_rxtx=1
50513simandlwcm_ppkts=0
506wcm_pkts=0
5075simandlwcm_ifc=""
50823simandlwcm_realifc=""
50915simandlwcm_macoff=0
5105simandl 
5116simandl# parsing input parameters
5125simandlwhile [ "a$1" != "a" ]
513do
514 case $1 in
51511simandl -v)
516 w_version
517 ;;
5185simandl -help)
519 w_help
520 ;;
521 -once)
522 wcm_once=1
523 shift
524 ;;
525 -oneline)
526 wcm_oneline=1
527 shift
528 ;;
52915simandl -threeline)
530 wcm_threeline=1
531 shift
532 ;;
53311simandl -col)
53423simandl wcm_col=0
5355simandl shift
536 ;;
537 -html)
538 wcm_html=1
539 shift
540 ;;
54115simandl -rxtxoff)
542 wcm_rxtx=0
543 shift
544 ;;
54513simandl -ppkts)
546 wcm_ppkts=1
547 shift
548 ;;
549 -pkts)
550 wcm_pkts=1
551 shift
552 ;;
55315simandl -macoff)
554 wcm_macoff=1
555 shift
556 ;;
5575simandl *)
558 wl_flg=0
55919simandl#wlan check
56021simandl if [ $wlf_hostap -eq 1 ]
5615simandl then
56221simandl for wl_iface in `ls $wl_hostap`
563 do
56423simandl w_realiface
565 if [ "a-$wl_realiface" = "a$1" ]
56621simandl then
567 wcm_ifc="$wcm_ifc $wl_iface"
568 wl_flg=1
569 fi
570 done
571 fi
57219simandl# ath check
57321simandl if [ $wlf_madwifi -eq 1 ]
57419simandl then
57521simandl for wl_iface in `ls $wl_sysdev | grep "ath[0-9]"`
576 do
57723simandl w_realiface
578 if [ "a-$wl_realiface" = "a$1" ]
57921simandl then
580 wcm_ifc="$wcm_ifc $wl_iface"
581 wl_flg=1
582 fi
583 done
584 fi
5855simandl if [ $wl_flg -eq 0 ]
58621simandl then
587 wl_unknown="$wl_unknown$1 "
5885simandl fi
589 shift
590 esac
591done
592 
5936simandl# printing the list of bad parameters (if there are some)
5945simandlif [ "a$wl_unknown" != "a" ]
595then
596 echo "$wlm_unknown $wl_unknown"
597 w_help
598fi
5996simandl# if no interface is selected then all available are choosen
6005simandlif [ "a$wcm_ifc" = "a" ]
601then
60221simandl if [ $wlf_hostap -eq 1 ]
603 then
604 wcm_ifc=`ls $wl_hostap `
605 fi
606 if [ $wlf_madwifi -eq 1 ]
607 then
608 wcm_ifc=`echo $wcm_ifc ; ls $wl_sysdev | grep "ath[0-9]"`
609 fi
6105simandlfi
611 
61223simandl# sort ifaces by name - if you want to do it smarter, just go ahead :)
613for wl_iface in $wcm_ifc
614do
615 w_realiface
616 wcm_realifc="$wcm_realifc $wl_realiface"
617done
618 
619wcm_realifc="`echo $wcm_realifc | fmt -1 -s | sort -t' '`"
620for wl_realifc in $wcm_realifc
621do
622 for wl_iface in $wcm_ifc
623 do
624 w_realiface
625 if [ "a$wl_realiface" = "a$wl_realifc" ]
626 then
627 wcm_ifc_sorted="$wcm_ifc_sorted $wl_iface"
628 fi
629 done
630done
631wcm_ifc="$wcm_ifc_sorted"
632 
6336simandl# setting for old and last same value to avoid double clear after start
634wl_numcllast=0
635wl_numclold=0
636for wl_iface in $wcm_ifc
637do
63823simandl w_realiface
63921simandl if [ -d $wl_hostap$wl_iface ]
640 then
641 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
642 wl_numcllast=$(($wl_numcllast + $wl_numcl))
643 fi
644 if [ -d $wl_sysdev$wl_iface ]
645 then
64623simandl wl_mode=`$wl_iwccmd $wl_realiface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'`
64721simandl if [ "a$wl_mode" = "aMaster" ]
648 then
64923simandl wl_numcl=`$wl_iwlcmd $wl_realiface peers | grep -c 00`
65021simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
651 fi
652 fi
6536simandldone
654wl_numclold=$wl_numcllast
655 
65611simandlif [ $wcm_col -eq 0 ]
6576simandlthen
658 w_bw
65911simandlelse
66015simandl if [ $wcm_html -eq 1 ]
661 then
662 w_colh
663 else
664 w_col
665 fi
6666simandlfi
667 
66813simandlif [ $wcm_html -eq 1 ]
669then
670 [ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh
671 for wl_iface in $wcm_ifc
672 do
67323simandl w_realiface
67413simandl w_iface
675 done
676 echo $wl_footer
677 exit 0
678fi
679 
68015simandl#this is main loop and it will be executed forever
6816simandlwhile [ 1 ]
6825simandl do
68314simandl 
684 # when the number of associated klients has changed we will set for clear screen
6855simandl if [ $wl_numcllast -ne $wl_numclold ]
686 then
687 wl_numclold=$wl_numcllast
688 wcm_clear=1
689 fi
69014simandl 
691 #if it is set for clear screen we will do it except we produce single report
692 if [ $wcm_clear -eq 1 -a $wcm_once -eq 0 ]
6935simandl then
69414simandl echo -n $wl_clrcmde
6955simandl wcm_clear=0
696 fi
697 wl_numcllast=0
69811simandl 
69914simandl #for cyclic report we are trying to set cursor to the top left screen corner
700 if [ $wcm_once -eq 0 ]
701 then
702 echo -n $wl_tptcmde
703 fi
704 
705 #make report for all desired interfaces
70613simandl for wl_iface in $wcm_ifc
707 do
70823simandl w_realiface
70913simandl w_iface
710 done
711 
71214simandl #when a single report is needed than we are exiting
7135simandl if [ $wcm_once -eq 1 ]
714 then
715 exit 0
716 fi
717 sleep 1
7186simandldone
7195simandl 
720exit 0
721 

Powered by WebSVN 2.2.1