jablonka.czprosek.czf

wifimon

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

 

Line No. Rev Author Line
12simandl#!/bin/bash
23simandl# authors : Petr Simandl www.simandl.cz
322simandl# : Fyzik, Covex, Tydyt, Thunder.m
428simandl# release date : 20/03/2006
52simandl# name : wifimon
621simandl# description : hostap and madwifi powered card monitoring
72simandl# license : GPL
821simandl######################################################################
92simandl 
1028simandlwl_version="0.5.7pre2"
1111simandl 
1221simandl######################################################################
13#custom settings
14 
1513simandlPATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin
16 
1728simandlwl_wlancf=`which wlanconfig`
1814simandlwl_iwccmd=`which iwconfig`
1921simandlwl_iwlcmd=`which iwlist`
2014simandlwl_ifccmd=`which ifconfig`
21wl_hnmcmd=`which hostname`
22wl_awkcmd=`which awk`
23 
24wl_tptcmde=""
25wl_clrcmde=""
26 
2719simandlwl_sysdev="/proc/sys/dev/"
2814simandlwl_hostap="/proc/net/hostap/"
2927simandlwl_madwifi="/proc/net/madwifi/"
3014simandlwl_wireless="/proc/net/wireless"
31wl_arp="/proc/net/arp"
32wl_dhcpcnf="/etc/dhcpd.conf"
33wl_dhcplss="/var/lib/dhcp/dhcpd.leases"
3417simandl# wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
35# wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
3614simandl 
3721simandlwl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
38wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
39wl_footer="</pre></body></html>"
4014simandl 
4121simandlwlm_no_managed_or_master=" neni ani Master ani Managed..."
42wlm_number_of_clients="Pocet asociovanych klientu : "
43wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "
44#wlm_no_managed_or_master=" is not Master or Managed..."
45#wlm_number_of_clients="Number of associated clients : "
46 
47wlch_signal="="
48wlch_noise="*"
49 
50######################################################################
51#testing basic setings
52 
5312simandlif [ "$wl_iwccmd x" = " x" ]
54 then
55 echo "iwconfig not found"
56 exit 1
57fi
582simandl 
5921simandlif [ "$wl_iwlcmd x" = " x" ]
60 then
61 echo "iwlist not found"
62 exit 1
63fi
64 
6514simandlif [ "$wl_ifccmd x" = " x" ]
66 then
67 echo "ifconfig not found"
68 exit 1
69fi
704simandl 
7114simandlif [ "$wl_hnmcmd x" = " x" ]
72 then
73 echo "hostname not found"
74 exit 1
75fi
76 
77if [ "$wl_awkcmd x" = " x" ]
78 then
79 echo "awk not found"
80 exit 1
81fi
82 
83if [ -e $wl_wireless ]
84 then
85 wl_nop=1
86 else
87 echo "$wl_wireless not found"
88 exit 1
89fi
90 
91if [ -e $wl_arp ]
92 then
93 wl_nop=1
94 else
95 echo "$wl_arp not found"
96 exit 1
97fi
98 
9922simandl#dhcp support
100#if not found trying to set alternative location
101if [ ! -f $wl_dhcpcnf ]; then
102 wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
103fi
104 
105if [ ! -f $wl_dhcplss ]; then
106 wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
107fi
108 
109#if not found a message is printed and /dev/null is used instead
11014simandlif [ -e $wl_dhcpcnf ]
111 then
112 wl_nop=1
113 else
114 echo "$wl_dhcpcnf not found"
115 wl_dhcpcnf="/dev/null"
116fi
117 
118if [ -e $wl_dhcplss ]
119 then
120 wl_nop=1
121 else
122 echo "$wl_dhcplss not found"
123 wl_dhcplss="/dev/null"
124fi
12521simandl######################################################################
12614simandl 
12724simandlif [ -d ${wl_hostap}wlan0 ]
12821simandl then
129 wlf_hostap=1
130 else
131# echo "${wl_hostap}wlan0 not found"
132 wlf_hostap=0
133fi
1347simandl 
13527simandlif [ -d ${wl_sysdev}ath ]
13621simandl then
137 wlf_madwifi=1
138 else
139# echo "${wl_sysdev}ath0 not found"
140 wlf_madwifi=0
141fi
1427simandl 
14321simandlif [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ]
144 then
14524simandl echo "${wl_hostap}wlan0 not found"
146 echo "${wl_sysdev}ath0 not found"
14721simandl exit 1
148fi
14911simandl 
1502simandl######################################################################
15121simandl# procedures
152######################################################################
15311simandlw_col()
15410simandl{
15515simandlwlc_red=`tput setaf 1` # ruda (Red)
156wlc_green=`tput setaf 2` # zelena (Lime)
157wlc_brown=`tput setaf 3` # zluta (Yellow)
158wlc_blue=`tput setaf 4` # modra (Blue)
159wlc_magenta=`tput setaf 5` # fialova (Fuchsia)
160wlc_lblue=`tput setaf 6` # svetle modra (Aqua)
161wlc_grey=`tput setaf 7` # bila (White)
16211simandlwlc_std=`tput sgr0`
163 
16415simandlwlc_pkts=$wlc_red # Rx,Tx info color
16511simandlwlc_ip=$wlc_lblue # ip address color
166wlc_mac=$wlc_magenta # mac address color
16715simandlwlc_name=$wlc_magenta # host name color
16811simandlwlc_sig=$wlc_red # signal number color
169wlc_bar=$wlc_green # signal bar color
17015simandlwlc_noise=$wlc_red # Signal noise color
17110simandl}
172######################################################################
17315simandlw_colh()
174{
175 wlh_pkts="Olive" # signal number color html
176 wlh_ip="Blue" # ip address color html
177 wlh_mac="Fuchsia" # mac address color html
178 wlh_name="Fuchsia" # Host name color html
179 wlh_sig="Red" # signal number color html
180 wlh_bar="Lime" # signal bar color html
181 wlh_noise="Red" # Signal noise color html
182 
183 wlc_pkts="<font color=\"$wlh_pkts\">"
184 wlc_ip="<font color=\"$wlh_ip\">"
185 wlc_mac="<font color=\"$wlh_mac\">"
186 wlc_name="<font color=\"$wlh_name\">"
187 wlc_sig="<font color=\"$wlh_sig\">"
188 wlc_bar="<font color=\"$wlh_bar\">"
189 wlc_noise="<font color=\"$wlh_noise\">"
190 wlc_std="</font>"
191}
192######################################################################
1934simandlw_bw()
194{
19515simandl wlc_pkts=""
1966simandl wlc_ip=""
197 wlc_mac=""
198 wlc_sig=""
199 wlc_bar=""
20015simandl wlc_noise=""
2016simandl wlc_std=""
2024simandl}
203######################################################################
2042simandlw_bar()
205{
20611simandl wl_neg=`expr $wl_cnt \< 0 `
207 if [ "$wl_neg" -eq 1 ]
208 then
20915simandl echo -n "${wlc_noise}"
21011simandl wl_cnt=$(($wl_cnt * -1 ))
211 wl_bar=$wlch_noise
212 else
21315simandl echo -n "${wlc_bar}"
21411simandl wl_bar=$wlch_signal
215 fi
2162simandl until [ "$wl_cnt" -eq -1 ]
217 do
21811simandl echo -n "$wl_bar"
2192simandl wl_cnt=$(($wl_cnt - 1 ))
220 done
221 printf " \n"
2226simandl echo -n "${wlc_std}"
22311simandl# tput sgr0
2242simandl} # w_bar
225 
226######################################################################
22713simandlw_pkts()
228{
229 wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'`
23014simandl wl_nt1=`echo $wl_macpkts | $wl_awkcmd '{print $2}'`
231 wl_nt2=`echo $wl_macpkts | $wl_awkcmd '{print $4}'`
232 wl_nt5=`echo $wl_macpkts | $wl_awkcmd '{print $6}'`
233 wl_nt11=`echo $wl_macpkts | $wl_awkcmd '{print $8}'`
234 wl_nr1=`echo $wl_macpkts | $wl_awkcmd '{print $10}'`
235 wl_nr2=`echo $wl_macpkts | $wl_awkcmd '{print $12}'`
236 wl_nr5=`echo $wl_macpkts | $wl_awkcmd '{print $14}'`
237 wl_nr11=`echo $wl_macpkts | $wl_awkcmd '{print $16}'`
23813simandl 
239 if [ $wcm_ppkts -eq 1 ]
240 then
241 wl_pksize=$((98))
242 wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11))
243 if [ "$wl_nt1" -eq 0 ]
244 then
245 wl_nt1n="00"
246 else
247 wl_nt1n=$(($wl_pksize * $wl_nt1 / $wl_nt + 1))
248 [ "$wl_nt1n" -lt 10 ] && wl_nt1n="0"$wl_nt1n
249 fi
250 if [ "$wl_nt2" -eq 0 ]
251 then
252 wl_nt2n="00"
253 else
254 wl_nt2n=$(($wl_pksize * $wl_nt2 / $wl_nt + 1))
255 [ "$wl_nt2n" -lt 10 ] && wl_nt2n="0"$wl_nt2n
256 fi
257 if [ "$wl_nt5" -eq 0 ]
258 then
259 wl_nt5n="00"
260 else
261 wl_nt5n=$(($wl_pksize * $wl_nt5 / $wl_nt + 1))
262 [ "$wl_nt5n" -lt 10 ] && wl_nt5n="0"$wl_nt5n
263 fi
264 if [ "$wl_nt11" -eq 0 ]
265 then
266 wl_nt11n="00"
267 else
268 wl_nt11n=$(($wl_pksize * $wl_nt11 / $wl_nt + 1))
269 [ "$wl_nt11n" -lt 10 ] && wl_nt11n="0"$wl_nt11n
270 fi
271 wl_nr=$((1 + $wl_nr1 + $wl_nr2 + wl_nr5 + wl_nr11))
272 if [ "$wl_nr1" -eq 0 ]
273 then
274 wl_nr1n="00"
275 else
276 wl_nr1n=$(($wl_pksize * $wl_nr1 / $wl_nr + 1))
277 [ "$wl_nr1n" -lt 10 ] && wl_nr1n="0"$wl_nr1n
278 fi
279 if [ "$wl_nr2" -eq 0 ]
280 then
281 wl_nr2n="00"
282 else
283 wl_nr2n=$(($wl_pksize * $wl_nr2 / $wl_nr + 1))
284 [ "$wl_nr2n" -lt 10 ] && wl_nr2n="0"$wl_nr2n
285 fi
286 if [ "$wl_nr5" -eq 0 ]
287 then
288 wl_nr5n="00"
289 else
290 wl_nr5n=$(($wl_pksize * $wl_nr5 / $wl_nr + 1))
291 [ "$wl_nr5n" -lt 10 ] && wl_nr5n="0"$wl_nr5n
292 fi
293 if [ "$wl_nr11" -eq 0 ]
294 then
295 wl_nr11n="00"
296 else
297 wl_nr11n=$(($wl_pksize * $wl_nr11 / $wl_nr + 1))
298 [ "$wl_nr11n" -lt 10 ] && wl_nr11n="0"$wl_nr11n
299 fi
30015simandl echo -n "Tx"${wlc_pkts} $wl_nt1n $wl_nt2n $wl_nt5n $wl_nt11n ${wlc_std}""
301 echo -n "Rx"${wlc_pkts} $wl_nr1n $wl_nr2n $wl_nr5n $wl_nr11n ${wlc_std}""
30213simandl fi
303 
304 [ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 ""
305 
306} # w_pkts
307######################################################################
30817simandlw_managed()
309{ echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
31024simandl echo -n `$wl_ifccmd $wl_iface | grep -E "inet addr|inet adr" | $wl_awkcmd '{print $2}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfig
31115simandl 
31218simandl if [ $wcm_macoff -eq 0 ]
31315simandl then
31425simandl wl_mac=`echo -n $wl_iwctxt | $wl_awkcmd '{print $8}'`
31518simandl echo -n "${wlc_mac}$wl_mac${wlc_std} "
31615simandl fi
31726simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$10,$11,$12" "}'
31815simandl 
31924simandl wl_wtxt=`cat $wl_wireless | grep $wl_iface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'`
32014simandl wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'`
321 wl_signal=`echo $wl_wtxt | $wl_awkcmd '{print $2}'`
3222simandl wl_signal=$(($wl_signal - 256))
32314simandl wl_noise=`echo $wl_wtxt | $wl_awkcmd '{print $3}'`
3242simandl wl_noise=$(($wl_noise - 256))
3255simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
3262simandl wl_cnt=$wl_quality
327 w_bar
328 echo
329} # w_managed
330 
331######################################################################
332w_master()
33317simandl{ if [ $wcm_oneline -eq 0 ]
33421simandl then
335 echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
336 if [ $wcm_macoff -eq 1 ]
337 then
33826simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$11,$12" "}'
33921simandl else
34026simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$8,$11,$12" "}'
34121simandl fi
342 else
34326simandl echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11,$12" "}' | sed 's/ [^": ]*:/ /g'
34421simandl fi
345 
346 if [ -d $wl_hostap$wl_iface ]
34715simandl then
34821simandl wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
349 wl_macs=`ls $wl_hostap$wl_iface | grep 00`
3505simandl fi
35121simandl 
35227simandl if [ -d $wl_madwifi$wl_iface ]
35321simandl then
35428simandl wl_numcl=`$wl_wlancf $wl_iface list sta | grep -c ^[0..9]`
355# wl_numcl=`cat $wl_madwifi$wl_iface/associated_sta | grep -c macaddr`
356# wl_macs=`cat $wl_madwifi$wl_iface/associated_sta | tr "<" "#" | tr ">" "#" | tr " " "#" | tr "\n" "#" | tr "m" "\n" `
357 wl_macs=`$wl_wlancf $wl_iface list sta | grep ^[0..9] | tr " " "#"`
35821simandl fi
3592simandl echo $wlm_number_of_clients $wl_numcl
36013simandl 
3615simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
36213simandl 
36321simandl for wl_mac in $wl_macs
3642simandl do
36521simandl if [ -d $wl_hostap$wl_iface ]
366 then
367 wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'`
36822simandl wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal[=|:]//g'`
369 wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence[=|:]//g'`
37021simandl fi
371 
37227simandl if [ -d $wl_madwifi$wl_iface ]
37321simandl then
37428simandl wl_signal=`echo $wl_mac | tr "#" " " | $wl_awkcmd '{print $5}'`
375 wl_rxtx=`echo $wl_mac | tr "#" " " | $wl_awkcmd '{print "rate="$4" tx="$8" rx="$9}'`
37627simandl wl_silence="0"
37728simandl wl_mac=`echo $wl_mac | tr "#" " " | $wl_awkcmd '{print $1}'`
37821simandl fi
37911simandl wl_cnt=$(($wl_signal - $wl_silence))
38014simandl wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky
38113simandl 
38214simandl wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'`
383 if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ]
384 then
385 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}'`
386 if [ "$wl_name" = "" ]
387 then
38817simandl wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'`
38914simandl wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' `
390 fi
391 fi
39221simandl if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] && [ -d $wl_hostap$wl_iface ]
39313simandl then
394 w_pkts
395 fi
396 
3975simandl if [ $wcm_oneline -eq 0 ]
398 then
39915simandl echo -n "${wlc_name}$wl_name${wlc_std} "
4005simandl echo -n "${wlc_ip}$wl_ipc${wlc_std} "
40115simandl if [ $wcm_macoff -eq 0 ]
402 then
403 echo -n "${wlc_mac}$wl_mac${wlc_std} "
404 fi
405 if [ $wcm_threeline -eq 1 ]
406 then
407 echo ""
408 echo -n " "
409 fi
410 echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} "
411 if [ $wcm_rxtx -eq 0 ]
412 then
413 echo ""
414 else
41521simandl if [ -d $wl_hostap$wl_iface ]
416 then
41728simandl echo -n $wl_macparam | $wl_awkcmd '{print $1,$2" "}'
41821simandl fi
41928simandl if [ -d $wl_madwifi$wl_iface ]
420 then
421 echo -n $wl_rxtx
422 fi
423 echo ""
42415simandl fi
4255simandl w_bar
426 else
42715simandl if [ $wcm_macoff -eq 0 ]
428 then
429 echo -n "${wlc_mac}$wl_mac${wlc_std} "
430 fi
431 echo -n "${wlc_sig}$wl_cnt${wlc_std} "
43217simandl echo -n "$wl_name "
4335simandl w_bar
434 fi
4354simandl done
43611simandl 
437 echo
4382simandl} # w_master
439 
440######################################################################
441w_iface()
44226simandl{ wl_iwctxt=`$wl_iwccmd $wl_iface 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/'`
44314simandl wl_mode=`echo $wl_iwctxt | $wl_awkcmd '{print $5}' | sed 's/Mode://g'`
4442simandl if [ "a$wl_mode" = "aManaged" ]
445 then
446 w_managed
4478simandl elif [ "a$wl_mode" = "aAd-Hoc" ]
448 then
449 w_managed
4502simandl elif [ "a$wl_mode" = "aMaster" ]
451 then
452 w_master
453 else
45424simandl echo $wl_iface $wlm_no_managed_or_master
4552simandl echo
456 fi
457}
458 
459######################################################################
46011simandlw_version()
461{
462 echo wifimon $wl_version
463 exit 0
464}
465######################################################################
4665simandlw_help()
467{
46821simandl echo Monitorovani wifi karet pouzivajicich hostap nebo madwifi ovladace
4693simandl echo Pouziti: wifimon [param]
470 echo param:
47111simandl echo -v vypise verzi
4725simandl echo -html generovani html stranky
47313simandl echo -col barevny vypis na obrazovku
4745simandl echo -once vypsani jen jednoho vypisu a pak program skonci
475 echo -oneline vypsani klientu na jednu linku
47615simandl echo -threeline vypsani klienta na trech radcich
47721simandl echo -macoff vypnuti zobrazeni MAC adres
478 echo -wlan0 -ath0 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
479 echo nasledujici parametry ovlivnuji jen karty s hostap:
48015simandl echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta
48113simandl echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
482 echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
4833simandl echo bez parametru cyklicky vypis na obrazovku
4845simandl exit 0
485}
486######################################################################
487######################################################################
4882simandl 
4895simandlwl_unknown=""
490wl_cnt=1
491wcm_clear=1
492wcm_once=0
49324simandlwcm_col=0
4945simandlwcm_oneline=0
49515simandlwcm_threeline=0
4965simandlwcm_html=0
49715simandlwcm_rxtx=1
49813simandlwcm_ppkts=0
499wcm_pkts=0
5005simandlwcm_ifc=""
50115simandlwcm_macoff=0
5025simandl 
5036simandl# parsing input parameters
5045simandlwhile [ "a$1" != "a" ]
505do
506 case $1 in
50711simandl -v)
508 w_version
509 ;;
5105simandl -help)
511 w_help
512 ;;
513 -once)
514 wcm_once=1
515 shift
516 ;;
517 -oneline)
518 wcm_oneline=1
519 shift
520 ;;
52115simandl -threeline)
522 wcm_threeline=1
523 shift
524 ;;
52511simandl -col)
52624simandl wcm_col=1
5275simandl shift
528 ;;
529 -html)
530 wcm_html=1
531 shift
532 ;;
53315simandl -rxtxoff)
534 wcm_rxtx=0
535 shift
536 ;;
53713simandl -ppkts)
538 wcm_ppkts=1
539 shift
540 ;;
541 -pkts)
542 wcm_pkts=1
543 shift
544 ;;
54515simandl -macoff)
546 wcm_macoff=1
547 shift
548 ;;
5495simandl *)
550 wl_flg=0
55119simandl#wlan check
55221simandl if [ $wlf_hostap -eq 1 ]
5535simandl then
55421simandl for wl_iface in `ls $wl_hostap`
555 do
55624simandl if [ "a-$wl_iface" = "a$1" ]
55721simandl then
558 wcm_ifc="$wcm_ifc $wl_iface"
559 wl_flg=1
560 fi
561 done
562 fi
56319simandl# ath check
56421simandl if [ $wlf_madwifi -eq 1 ]
56519simandl then
56627simandl for wl_iface in `ls $wl_madwifi | grep "ath[0-9]"`
56721simandl do
56824simandl if [ "a-$wl_iface" = "a$1" ]
56921simandl then
570 wcm_ifc="$wcm_ifc $wl_iface"
571 wl_flg=1
572 fi
573 done
574 fi
5755simandl if [ $wl_flg -eq 0 ]
57621simandl then
577 wl_unknown="$wl_unknown$1 "
5785simandl fi
579 shift
580 esac
581done
582 
5836simandl# printing the list of bad parameters (if there are some)
5845simandlif [ "a$wl_unknown" != "a" ]
585then
586 echo "$wlm_unknown $wl_unknown"
587 w_help
588fi
5896simandl# if no interface is selected then all available are choosen
5905simandlif [ "a$wcm_ifc" = "a" ]
591then
59221simandl if [ $wlf_hostap -eq 1 ]
593 then
594 wcm_ifc=`ls $wl_hostap `
595 fi
596 if [ $wlf_madwifi -eq 1 ]
597 then
59827simandl wcm_ifc=`echo $wcm_ifc ; ls $wl_madwifi | grep "ath[0-9]"`
59921simandl fi
6005simandlfi
601 
6026simandl# setting for old and last same value to avoid double clear after start
603wl_numcllast=0
604wl_numclold=0
605for wl_iface in $wcm_ifc
606do
60721simandl if [ -d $wl_hostap$wl_iface ]
608 then
609 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
610 wl_numcllast=$(($wl_numcllast + $wl_numcl))
611 fi
61227simandl if [ -d $wl_madwifi$wl_iface ]
61321simandl then
61424simandl wl_mode=`$wl_iwccmd $wl_iface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'`
61521simandl if [ "a$wl_mode" = "aMaster" ]
616 then
61728simandl wl_numcl=`$wl_wlancf $wl_iface list sta | grep -c ^[0..9]`
61821simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
619 fi
620 fi
6216simandldone
622wl_numclold=$wl_numcllast
623 
62411simandlif [ $wcm_col -eq 0 ]
6256simandlthen
626 w_bw
62711simandlelse
62815simandl if [ $wcm_html -eq 1 ]
629 then
630 w_colh
631 else
632 w_col
633 fi
6346simandlfi
635 
63613simandlif [ $wcm_html -eq 1 ]
637then
638 [ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh
639 for wl_iface in $wcm_ifc
640 do
641 w_iface
642 done
643 echo $wl_footer
644 exit 0
645fi
646 
64715simandl#this is main loop and it will be executed forever
6486simandlwhile [ 1 ]
6495simandl do
65014simandl 
651 # when the number of associated klients has changed we will set for clear screen
6525simandl if [ $wl_numcllast -ne $wl_numclold ]
653 then
654 wl_numclold=$wl_numcllast
655 wcm_clear=1
656 fi
65714simandl 
658 #if it is set for clear screen we will do it except we produce single report
659 if [ $wcm_clear -eq 1 -a $wcm_once -eq 0 ]
6605simandl then
66114simandl echo -n $wl_clrcmde
6625simandl wcm_clear=0
663 fi
664 wl_numcllast=0
66511simandl 
66614simandl #for cyclic report we are trying to set cursor to the top left screen corner
667 if [ $wcm_once -eq 0 ]
668 then
669 echo -n $wl_tptcmde
670 fi
671 
672 #make report for all desired interfaces
67313simandl for wl_iface in $wcm_ifc
674 do
675 w_iface
676 done
677 
67814simandl #when a single report is needed than we are exiting
6795simandl if [ $wcm_once -eq 1 ]
680 then
681 exit 0
682 fi
683 sleep 1
6846simandldone
6855simandl 
686exit 0
687 

Powered by WebSVN 2.2.1