jablonka.czprosek.czf

wifimon

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

 

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 
1022simandlwl_version="0.5.6"
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 
48######################################################################
49#testing basic setings
50 
5112simandlif [ "$wl_iwccmd x" = " x" ]
52 then
53 echo "iwconfig not found"
54 exit 1
55fi
562simandl 
5721simandlif [ "$wl_iwlcmd x" = " x" ]
58 then
59 echo "iwlist not found"
60 exit 1
61fi
62 
6314simandlif [ "$wl_ifccmd x" = " x" ]
64 then
65 echo "ifconfig not found"
66 exit 1
67fi
684simandl 
6914simandlif [ "$wl_hnmcmd x" = " x" ]
70 then
71 echo "hostname not found"
72 exit 1
73fi
74 
75if [ "$wl_awkcmd x" = " x" ]
76 then
77 echo "awk not found"
78 exit 1
79fi
80 
81if [ -e $wl_wireless ]
82 then
83 wl_nop=1
84 else
85 echo "$wl_wireless not found"
86 exit 1
87fi
88 
89if [ -e $wl_arp ]
90 then
91 wl_nop=1
92 else
93 echo "$wl_arp not found"
94 exit 1
95fi
96 
9722simandl#dhcp support
98#if not found trying to set alternative location
99if [ ! -f $wl_dhcpcnf ]; then
100 wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
101fi
102 
103if [ ! -f $wl_dhcplss ]; then
104 wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
105fi
106 
107#if not found a message is printed and /dev/null is used instead
10814simandlif [ -e $wl_dhcpcnf ]
109 then
110 wl_nop=1
111 else
112 echo "$wl_dhcpcnf not found"
113 wl_dhcpcnf="/dev/null"
114fi
115 
116if [ -e $wl_dhcplss ]
117 then
118 wl_nop=1
119 else
120 echo "$wl_dhcplss not found"
121 wl_dhcplss="/dev/null"
122fi
12321simandl######################################################################
12414simandl 
12521simandlif [ -d ${wl_hostap}wlan0 ]
126 then
127 wlf_hostap=1
128 else
129# echo "${wl_hostap}wlan0 not found"
130 wlf_hostap=0
131fi
1327simandl 
13321simandlif [ -d ${wl_sysdev}ath0 ]
134 then
135 wlf_madwifi=1
136 else
137# echo "${wl_sysdev}ath0 not found"
138 wlf_madwifi=0
139fi
1407simandl 
14121simandlif [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ]
142 then
143 echo "${wl_hostap}wlan0 not found"
144 echo "${wl_sysdev}ath0 not found"
145 exit 1
146fi
14711simandl 
1482simandl######################################################################
14921simandl# procedures
150######################################################################
15111simandlw_col()
15210simandl{
15315simandlwlc_red=`tput setaf 1` # ruda (Red)
154wlc_green=`tput setaf 2` # zelena (Lime)
155wlc_brown=`tput setaf 3` # zluta (Yellow)
156wlc_blue=`tput setaf 4` # modra (Blue)
157wlc_magenta=`tput setaf 5` # fialova (Fuchsia)
158wlc_lblue=`tput setaf 6` # svetle modra (Aqua)
159wlc_grey=`tput setaf 7` # bila (White)
16011simandlwlc_std=`tput sgr0`
161 
16215simandlwlc_pkts=$wlc_red # Rx,Tx info color
16311simandlwlc_ip=$wlc_lblue # ip address color
164wlc_mac=$wlc_magenta # mac address color
16515simandlwlc_name=$wlc_magenta # host name color
16611simandlwlc_sig=$wlc_red # signal number color
167wlc_bar=$wlc_green # signal bar color
16815simandlwlc_noise=$wlc_red # Signal noise color
16910simandl}
170######################################################################
17115simandlw_colh()
172{
173 wlh_pkts="Olive" # signal number color html
174 wlh_ip="Blue" # ip address color html
175 wlh_mac="Fuchsia" # mac address color html
176 wlh_name="Fuchsia" # Host name color html
177 wlh_sig="Red" # signal number color html
178 wlh_bar="Lime" # signal bar color html
179 wlh_noise="Red" # Signal noise color html
180 
181 wlc_pkts="<font color=\"$wlh_pkts\">"
182 wlc_ip="<font color=\"$wlh_ip\">"
183 wlc_mac="<font color=\"$wlh_mac\">"
184 wlc_name="<font color=\"$wlh_name\">"
185 wlc_sig="<font color=\"$wlh_sig\">"
186 wlc_bar="<font color=\"$wlh_bar\">"
187 wlc_noise="<font color=\"$wlh_noise\">"
188 wlc_std="</font>"
189}
190######################################################################
1914simandlw_bw()
192{
19315simandl wlc_pkts=""
1946simandl wlc_ip=""
195 wlc_mac=""
196 wlc_sig=""
197 wlc_bar=""
19815simandl wlc_noise=""
1996simandl wlc_std=""
2004simandl}
201######################################################################
2022simandlw_bar()
203{
20411simandl wl_neg=`expr $wl_cnt \< 0 `
205 if [ "$wl_neg" -eq 1 ]
206 then
20715simandl echo -n "${wlc_noise}"
20811simandl wl_cnt=$(($wl_cnt * -1 ))
209 wl_bar=$wlch_noise
210 else
21115simandl echo -n "${wlc_bar}"
21211simandl wl_bar=$wlch_signal
213 fi
2142simandl until [ "$wl_cnt" -eq -1 ]
215 do
21611simandl echo -n "$wl_bar"
2172simandl wl_cnt=$(($wl_cnt - 1 ))
218 done
219 printf " \n"
2206simandl echo -n "${wlc_std}"
22111simandl# tput sgr0
2222simandl} # w_bar
223 
224######################################################################
22513simandlw_pkts()
226{
227 wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'`
22814simandl wl_nt1=`echo $wl_macpkts | $wl_awkcmd '{print $2}'`
229 wl_nt2=`echo $wl_macpkts | $wl_awkcmd '{print $4}'`
230 wl_nt5=`echo $wl_macpkts | $wl_awkcmd '{print $6}'`
231 wl_nt11=`echo $wl_macpkts | $wl_awkcmd '{print $8}'`
232 wl_nr1=`echo $wl_macpkts | $wl_awkcmd '{print $10}'`
233 wl_nr2=`echo $wl_macpkts | $wl_awkcmd '{print $12}'`
234 wl_nr5=`echo $wl_macpkts | $wl_awkcmd '{print $14}'`
235 wl_nr11=`echo $wl_macpkts | $wl_awkcmd '{print $16}'`
23613simandl 
237 if [ $wcm_ppkts -eq 1 ]
238 then
239 wl_pksize=$((98))
240 wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11))
241 if [ "$wl_nt1" -eq 0 ]
242 then
243 wl_nt1n="00"
244 else
245 wl_nt1n=$(($wl_pksize * $wl_nt1 / $wl_nt + 1))
246 [ "$wl_nt1n" -lt 10 ] && wl_nt1n="0"$wl_nt1n
247 fi
248 if [ "$wl_nt2" -eq 0 ]
249 then
250 wl_nt2n="00"
251 else
252 wl_nt2n=$(($wl_pksize * $wl_nt2 / $wl_nt + 1))
253 [ "$wl_nt2n" -lt 10 ] && wl_nt2n="0"$wl_nt2n
254 fi
255 if [ "$wl_nt5" -eq 0 ]
256 then
257 wl_nt5n="00"
258 else
259 wl_nt5n=$(($wl_pksize * $wl_nt5 / $wl_nt + 1))
260 [ "$wl_nt5n" -lt 10 ] && wl_nt5n="0"$wl_nt5n
261 fi
262 if [ "$wl_nt11" -eq 0 ]
263 then
264 wl_nt11n="00"
265 else
266 wl_nt11n=$(($wl_pksize * $wl_nt11 / $wl_nt + 1))
267 [ "$wl_nt11n" -lt 10 ] && wl_nt11n="0"$wl_nt11n
268 fi
269 wl_nr=$((1 + $wl_nr1 + $wl_nr2 + wl_nr5 + wl_nr11))
270 if [ "$wl_nr1" -eq 0 ]
271 then
272 wl_nr1n="00"
273 else
274 wl_nr1n=$(($wl_pksize * $wl_nr1 / $wl_nr + 1))
275 [ "$wl_nr1n" -lt 10 ] && wl_nr1n="0"$wl_nr1n
276 fi
277 if [ "$wl_nr2" -eq 0 ]
278 then
279 wl_nr2n="00"
280 else
281 wl_nr2n=$(($wl_pksize * $wl_nr2 / $wl_nr + 1))
282 [ "$wl_nr2n" -lt 10 ] && wl_nr2n="0"$wl_nr2n
283 fi
284 if [ "$wl_nr5" -eq 0 ]
285 then
286 wl_nr5n="00"
287 else
288 wl_nr5n=$(($wl_pksize * $wl_nr5 / $wl_nr + 1))
289 [ "$wl_nr5n" -lt 10 ] && wl_nr5n="0"$wl_nr5n
290 fi
291 if [ "$wl_nr11" -eq 0 ]
292 then
293 wl_nr11n="00"
294 else
295 wl_nr11n=$(($wl_pksize * $wl_nr11 / $wl_nr + 1))
296 [ "$wl_nr11n" -lt 10 ] && wl_nr11n="0"$wl_nr11n
297 fi
29815simandl echo -n "Tx"${wlc_pkts} $wl_nt1n $wl_nt2n $wl_nt5n $wl_nt11n ${wlc_std}""
299 echo -n "Rx"${wlc_pkts} $wl_nr1n $wl_nr2n $wl_nr5n $wl_nr11n ${wlc_std}""
30013simandl fi
301 
302 [ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 ""
303 
304} # w_pkts
305######################################################################
30617simandlw_managed()
307{ echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
30818simandl 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
30915simandl 
31018simandl if [ $wcm_macoff -eq 0 ]
31115simandl then
31222simandl wl_mac=`echo -n $wl_iwctxt | $wl_awkcmd '{print $8}'`
31318simandl echo -n "${wlc_mac}$wl_mac${wlc_std} "
31415simandl fi
31522simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$10,$11,$12" "}'
31615simandl 
31714simandl wl_wtxt=`cat $wl_wireless | grep $wl_iface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'`
318 wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'`
319 wl_signal=`echo $wl_wtxt | $wl_awkcmd '{print $2}'`
3202simandl wl_signal=$(($wl_signal - 256))
32114simandl wl_noise=`echo $wl_wtxt | $wl_awkcmd '{print $3}'`
3222simandl wl_noise=$(($wl_noise - 256))
3235simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
3242simandl wl_cnt=$wl_quality
325 w_bar
326 echo
327} # w_managed
328 
329######################################################################
330w_master()
33117simandl{ if [ $wcm_oneline -eq 0 ]
33221simandl then
333 echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
334 if [ $wcm_macoff -eq 1 ]
335 then
33622simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$11,$12" "}'
33721simandl else
33822simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$8,$11,$12" "}'
33921simandl fi
340 else
34122simandl echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11,$12" "}' | sed 's/ [^": ]*:/ /g'
34221simandl fi
343 
344 if [ -d $wl_hostap$wl_iface ]
34515simandl then
34621simandl wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
347 wl_macs=`ls $wl_hostap$wl_iface | grep 00`
3485simandl fi
34921simandl 
350 if [ -d $wl_sysdev$wl_iface ]
351 then
352 wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00`
353 wl_macs=`iwlist $wl_iface peers | grep 00 | awk '{print $1}'`
354 fi
355 
3562simandl echo $wlm_number_of_clients $wl_numcl
35713simandl 
3585simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
35913simandl 
36021simandl for wl_mac in $wl_macs
3612simandl do
36221simandl if [ -d $wl_hostap$wl_iface ]
363 then
364 wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'`
36522simandl wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal[=|:]//g'`
366 wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence[=|:]//g'`
36721simandl fi
368 
369 if [ -d $wl_sysdev$wl_iface ]
370 then
371 wl_macparam=`$wl_iwlcmd $wl_iface peers | grep $wl_mac`
37222simandl wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $5}' | sed 's/level[=|:]//g'`
373 wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $8}' | sed 's/level[=|:]//g'`
37421simandl fi
375 
37611simandl wl_cnt=$(($wl_signal - $wl_silence))
37714simandl wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky
37813simandl 
37914simandl wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'`
380 if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ]
381 then
382 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}'`
383 if [ "$wl_name" = "" ]
384 then
38517simandl wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'`
38614simandl wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' `
387 fi
388 fi
38921simandl if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] && [ -d $wl_hostap$wl_iface ]
39013simandl then
391 w_pkts
392 fi
393 
3945simandl if [ $wcm_oneline -eq 0 ]
395 then
39615simandl echo -n "${wlc_name}$wl_name${wlc_std} "
3975simandl echo -n "${wlc_ip}$wl_ipc${wlc_std} "
39815simandl if [ $wcm_macoff -eq 0 ]
399 then
400 echo -n "${wlc_mac}$wl_mac${wlc_std} "
401 fi
402 if [ $wcm_threeline -eq 1 ]
403 then
404 echo ""
405 echo -n " "
406 fi
407 echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} "
408 if [ $wcm_rxtx -eq 0 ]
409 then
410 echo ""
411 else
41221simandl if [ -d $wl_hostap$wl_iface ]
413 then
414 echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}'
415 else
416 echo ""
417 fi
41815simandl fi
4195simandl w_bar
420 else
42115simandl if [ $wcm_macoff -eq 0 ]
422 then
423 echo -n "${wlc_mac}$wl_mac${wlc_std} "
424 fi
425 echo -n "${wlc_sig}$wl_cnt${wlc_std} "
42617simandl echo -n "$wl_name "
4275simandl w_bar
428 fi
4294simandl done
43011simandl 
431 echo
4322simandl} # w_master
433 
434######################################################################
435w_iface()
43622simandl{ 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/'`
43714simandl wl_mode=`echo $wl_iwctxt | $wl_awkcmd '{print $5}' | sed 's/Mode://g'`
4382simandl if [ "a$wl_mode" = "aManaged" ]
439 then
440 w_managed
4418simandl elif [ "a$wl_mode" = "aAd-Hoc" ]
442 then
443 w_managed
4442simandl elif [ "a$wl_mode" = "aMaster" ]
445 then
446 w_master
447 else
448 echo $wl_iface $wlm_no_managed_or_master
449 echo
450 fi
451}
452 
453######################################################################
45411simandlw_version()
455{
456 echo wifimon $wl_version
457 exit 0
458}
459######################################################################
4605simandlw_help()
461{
46221simandl echo Monitorovani wifi karet pouzivajicich hostap nebo madwifi ovladace
4633simandl echo Pouziti: wifimon [param]
464 echo param:
46511simandl echo -v vypise verzi
4665simandl echo -html generovani html stranky
46713simandl echo -col barevny vypis na obrazovku
4685simandl echo -once vypsani jen jednoho vypisu a pak program skonci
469 echo -oneline vypsani klientu na jednu linku
47015simandl echo -threeline vypsani klienta na trech radcich
47121simandl echo -macoff vypnuti zobrazeni MAC adres
472 echo -wlan0 -ath0 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
473 echo nasledujici parametry ovlivnuji jen karty s hostap:
47415simandl echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta
47513simandl echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
476 echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
4773simandl echo bez parametru cyklicky vypis na obrazovku
4785simandl exit 0
479}
480######################################################################
481######################################################################
4822simandl 
4835simandlwl_unknown=""
484wl_cnt=1
485wcm_clear=1
486wcm_once=0
48711simandlwcm_col=0
4885simandlwcm_oneline=0
48915simandlwcm_threeline=0
4905simandlwcm_html=0
49115simandlwcm_rxtx=1
49213simandlwcm_ppkts=0
493wcm_pkts=0
4945simandlwcm_ifc=""
49515simandlwcm_macoff=0
4965simandl 
4976simandl# parsing input parameters
4985simandlwhile [ "a$1" != "a" ]
499do
500 case $1 in
50111simandl -v)
502 w_version
503 ;;
5045simandl -help)
505 w_help
506 ;;
507 -once)
508 wcm_once=1
509 shift
510 ;;
511 -oneline)
512 wcm_oneline=1
513 shift
514 ;;
51515simandl -threeline)
516 wcm_threeline=1
517 shift
518 ;;
51911simandl -col)
520 wcm_col=1
5215simandl shift
522 ;;
523 -html)
524 wcm_html=1
525 shift
526 ;;
52715simandl -rxtxoff)
528 wcm_rxtx=0
529 shift
530 ;;
53113simandl -ppkts)
532 wcm_ppkts=1
533 shift
534 ;;
535 -pkts)
536 wcm_pkts=1
537 shift
538 ;;
53915simandl -macoff)
540 wcm_macoff=1
541 shift
542 ;;
5435simandl *)
544 wl_flg=0
54519simandl#wlan check
54621simandl if [ $wlf_hostap -eq 1 ]
5475simandl then
54821simandl for wl_iface in `ls $wl_hostap`
549 do
550 if [ "a-$wl_iface" = "a$1" ]
551 then
552 wcm_ifc="$wcm_ifc $wl_iface"
553 wl_flg=1
554 fi
555 done
556 fi
55719simandl# ath check
55821simandl if [ $wlf_madwifi -eq 1 ]
55919simandl then
56021simandl for wl_iface in `ls $wl_sysdev | grep "ath[0-9]"`
561 do
562 if [ "a-$wl_iface" = "a$1" ]
563 then
564 wcm_ifc="$wcm_ifc $wl_iface"
565 wl_flg=1
566 fi
567 done
568 fi
5695simandl if [ $wl_flg -eq 0 ]
57021simandl then
571 wl_unknown="$wl_unknown$1 "
5725simandl fi
573 shift
574 esac
575done
576 
5776simandl# printing the list of bad parameters (if there are some)
5785simandlif [ "a$wl_unknown" != "a" ]
579then
580 echo "$wlm_unknown $wl_unknown"
581 w_help
582fi
5836simandl# if no interface is selected then all available are choosen
5845simandlif [ "a$wcm_ifc" = "a" ]
585then
58621simandl if [ $wlf_hostap -eq 1 ]
587 then
588 wcm_ifc=`ls $wl_hostap `
589 fi
590 if [ $wlf_madwifi -eq 1 ]
591 then
592 wcm_ifc=`echo $wcm_ifc ; ls $wl_sysdev | grep "ath[0-9]"`
593 fi
5945simandlfi
595 
5966simandl# setting for old and last same value to avoid double clear after start
597wl_numcllast=0
598wl_numclold=0
599for wl_iface in $wcm_ifc
600do
60121simandl if [ -d $wl_hostap$wl_iface ]
602 then
603 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
604 wl_numcllast=$(($wl_numcllast + $wl_numcl))
605 fi
606 if [ -d $wl_sysdev$wl_iface ]
607 then
608 wl_mode=`$wl_iwccmd $wl_iface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'`
609 if [ "a$wl_mode" = "aMaster" ]
610 then
611 wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00`
612 wl_numcllast=$(($wl_numcllast + $wl_numcl))
613 fi
614 fi
6156simandldone
616wl_numclold=$wl_numcllast
617 
61811simandlif [ $wcm_col -eq 0 ]
6196simandlthen
620 w_bw
62111simandlelse
62215simandl if [ $wcm_html -eq 1 ]
623 then
624 w_colh
625 else
626 w_col
627 fi
6286simandlfi
629 
63013simandlif [ $wcm_html -eq 1 ]
631then
632 [ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh
633 for wl_iface in $wcm_ifc
634 do
635 w_iface
636 done
637 echo $wl_footer
638 exit 0
639fi
640 
64115simandl#this is main loop and it will be executed forever
6426simandlwhile [ 1 ]
6435simandl do
64414simandl 
645 # when the number of associated klients has changed we will set for clear screen
6465simandl if [ $wl_numcllast -ne $wl_numclold ]
647 then
648 wl_numclold=$wl_numcllast
649 wcm_clear=1
650 fi
65114simandl 
652 #if it is set for clear screen we will do it except we produce single report
653 if [ $wcm_clear -eq 1 -a $wcm_once -eq 0 ]
6545simandl then
65514simandl echo -n $wl_clrcmde
6565simandl wcm_clear=0
657 fi
658 wl_numcllast=0
65911simandl 
66014simandl #for cyclic report we are trying to set cursor to the top left screen corner
661 if [ $wcm_once -eq 0 ]
662 then
663 echo -n $wl_tptcmde
664 fi
665 
666 #make report for all desired interfaces
66713simandl for wl_iface in $wcm_ifc
668 do
669 w_iface
670 done
671 
67214simandl #when a single report is needed than we are exiting
6735simandl if [ $wcm_once -eq 1 ]
674 then
675 exit 0
676 fi
677 sleep 1
6786simandldone
6795simandl 
680exit 0
681 

Powered by WebSVN 2.2.1