jablonka.czprosek.czf

wifimon

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

 

Line No. Rev Author Line
12simandl#!/bin/bash
23simandl# authors : Petr Simandl www.simandl.cz
322simandl# : Fyzik, Covex, Tydyt, Thunder.m
427simandl# release date : 17/03/2006
52simandl# name : wifimon
621simandl# description : hostap and madwifi powered card monitoring
72simandl# license : GPL
821simandl######################################################################
92simandl 
1027simandlwl_version="0.5.7pre1"
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/"
2827simandlwl_madwifi="/proc/net/madwifi/"
2914simandlwl_wireless="/proc/net/wireless"
30wl_arp="/proc/net/arp"
31wl_dhcpcnf="/etc/dhcpd.conf"
32wl_dhcplss="/var/lib/dhcp/dhcpd.leases"
3317simandl# wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
34# wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
3514simandl 
3621simandlwl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
37wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
38wl_footer="</pre></body></html>"
3914simandl 
4021simandlwlm_no_managed_or_master=" neni ani Master ani Managed..."
41wlm_number_of_clients="Pocet asociovanych klientu : "
42wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "
43#wlm_no_managed_or_master=" is not Master or Managed..."
44#wlm_number_of_clients="Number of associated clients : "
45 
46wlch_signal="="
47wlch_noise="*"
48 
49######################################################################
50#testing basic setings
51 
5212simandlif [ "$wl_iwccmd x" = " x" ]
53 then
54 echo "iwconfig not found"
55 exit 1
56fi
572simandl 
5821simandlif [ "$wl_iwlcmd x" = " x" ]
59 then
60 echo "iwlist not found"
61 exit 1
62fi
63 
6414simandlif [ "$wl_ifccmd x" = " x" ]
65 then
66 echo "ifconfig not found"
67 exit 1
68fi
694simandl 
7014simandlif [ "$wl_hnmcmd x" = " x" ]
71 then
72 echo "hostname not found"
73 exit 1
74fi
75 
76if [ "$wl_awkcmd x" = " x" ]
77 then
78 echo "awk not found"
79 exit 1
80fi
81 
82if [ -e $wl_wireless ]
83 then
84 wl_nop=1
85 else
86 echo "$wl_wireless not found"
87 exit 1
88fi
89 
90if [ -e $wl_arp ]
91 then
92 wl_nop=1
93 else
94 echo "$wl_arp not found"
95 exit 1
96fi
97 
9822simandl#dhcp support
99#if not found trying to set alternative location
100if [ ! -f $wl_dhcpcnf ]; then
101 wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
102fi
103 
104if [ ! -f $wl_dhcplss ]; then
105 wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
106fi
107 
108#if not found a message is printed and /dev/null is used instead
10914simandlif [ -e $wl_dhcpcnf ]
110 then
111 wl_nop=1
112 else
113 echo "$wl_dhcpcnf not found"
114 wl_dhcpcnf="/dev/null"
115fi
116 
117if [ -e $wl_dhcplss ]
118 then
119 wl_nop=1
120 else
121 echo "$wl_dhcplss not found"
122 wl_dhcplss="/dev/null"
123fi
12421simandl######################################################################
12514simandl 
12624simandlif [ -d ${wl_hostap}wlan0 ]
12721simandl then
128 wlf_hostap=1
129 else
130# echo "${wl_hostap}wlan0 not found"
131 wlf_hostap=0
132fi
1337simandl 
13427simandlif [ -d ${wl_sysdev}ath ]
13521simandl then
136 wlf_madwifi=1
137 else
138# echo "${wl_sysdev}ath0 not found"
139 wlf_madwifi=0
140fi
1417simandl 
14221simandlif [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ]
143 then
14424simandl echo "${wl_hostap}wlan0 not found"
145 echo "${wl_sysdev}ath0 not found"
14621simandl exit 1
147fi
14811simandl 
1492simandl######################################################################
15021simandl# procedures
151######################################################################
15211simandlw_col()
15310simandl{
15415simandlwlc_red=`tput setaf 1` # ruda (Red)
155wlc_green=`tput setaf 2` # zelena (Lime)
156wlc_brown=`tput setaf 3` # zluta (Yellow)
157wlc_blue=`tput setaf 4` # modra (Blue)
158wlc_magenta=`tput setaf 5` # fialova (Fuchsia)
159wlc_lblue=`tput setaf 6` # svetle modra (Aqua)
160wlc_grey=`tput setaf 7` # bila (White)
16111simandlwlc_std=`tput sgr0`
162 
16315simandlwlc_pkts=$wlc_red # Rx,Tx info color
16411simandlwlc_ip=$wlc_lblue # ip address color
165wlc_mac=$wlc_magenta # mac address color
16615simandlwlc_name=$wlc_magenta # host name color
16711simandlwlc_sig=$wlc_red # signal number color
168wlc_bar=$wlc_green # signal bar color
16915simandlwlc_noise=$wlc_red # Signal noise color
17010simandl}
171######################################################################
17215simandlw_colh()
173{
174 wlh_pkts="Olive" # signal number color html
175 wlh_ip="Blue" # ip address color html
176 wlh_mac="Fuchsia" # mac address color html
177 wlh_name="Fuchsia" # Host name color html
178 wlh_sig="Red" # signal number color html
179 wlh_bar="Lime" # signal bar color html
180 wlh_noise="Red" # Signal noise color html
181 
182 wlc_pkts="<font color=\"$wlh_pkts\">"
183 wlc_ip="<font color=\"$wlh_ip\">"
184 wlc_mac="<font color=\"$wlh_mac\">"
185 wlc_name="<font color=\"$wlh_name\">"
186 wlc_sig="<font color=\"$wlh_sig\">"
187 wlc_bar="<font color=\"$wlh_bar\">"
188 wlc_noise="<font color=\"$wlh_noise\">"
189 wlc_std="</font>"
190}
191######################################################################
1924simandlw_bw()
193{
19415simandl wlc_pkts=""
1956simandl wlc_ip=""
196 wlc_mac=""
197 wlc_sig=""
198 wlc_bar=""
19915simandl wlc_noise=""
2006simandl wlc_std=""
2014simandl}
202######################################################################
2032simandlw_bar()
204{
20511simandl wl_neg=`expr $wl_cnt \< 0 `
206 if [ "$wl_neg" -eq 1 ]
207 then
20815simandl echo -n "${wlc_noise}"
20911simandl wl_cnt=$(($wl_cnt * -1 ))
210 wl_bar=$wlch_noise
211 else
21215simandl echo -n "${wlc_bar}"
21311simandl wl_bar=$wlch_signal
214 fi
2152simandl until [ "$wl_cnt" -eq -1 ]
216 do
21711simandl echo -n "$wl_bar"
2182simandl wl_cnt=$(($wl_cnt - 1 ))
219 done
220 printf " \n"
2216simandl echo -n "${wlc_std}"
22211simandl# tput sgr0
2232simandl} # w_bar
224 
225######################################################################
22613simandlw_pkts()
227{
228 wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'`
22914simandl wl_nt1=`echo $wl_macpkts | $wl_awkcmd '{print $2}'`
230 wl_nt2=`echo $wl_macpkts | $wl_awkcmd '{print $4}'`
231 wl_nt5=`echo $wl_macpkts | $wl_awkcmd '{print $6}'`
232 wl_nt11=`echo $wl_macpkts | $wl_awkcmd '{print $8}'`
233 wl_nr1=`echo $wl_macpkts | $wl_awkcmd '{print $10}'`
234 wl_nr2=`echo $wl_macpkts | $wl_awkcmd '{print $12}'`
235 wl_nr5=`echo $wl_macpkts | $wl_awkcmd '{print $14}'`
236 wl_nr11=`echo $wl_macpkts | $wl_awkcmd '{print $16}'`
23713simandl 
238 if [ $wcm_ppkts -eq 1 ]
239 then
240 wl_pksize=$((98))
241 wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11))
242 if [ "$wl_nt1" -eq 0 ]
243 then
244 wl_nt1n="00"
245 else
246 wl_nt1n=$(($wl_pksize * $wl_nt1 / $wl_nt + 1))
247 [ "$wl_nt1n" -lt 10 ] && wl_nt1n="0"$wl_nt1n
248 fi
249 if [ "$wl_nt2" -eq 0 ]
250 then
251 wl_nt2n="00"
252 else
253 wl_nt2n=$(($wl_pksize * $wl_nt2 / $wl_nt + 1))
254 [ "$wl_nt2n" -lt 10 ] && wl_nt2n="0"$wl_nt2n
255 fi
256 if [ "$wl_nt5" -eq 0 ]
257 then
258 wl_nt5n="00"
259 else
260 wl_nt5n=$(($wl_pksize * $wl_nt5 / $wl_nt + 1))
261 [ "$wl_nt5n" -lt 10 ] && wl_nt5n="0"$wl_nt5n
262 fi
263 if [ "$wl_nt11" -eq 0 ]
264 then
265 wl_nt11n="00"
266 else
267 wl_nt11n=$(($wl_pksize * $wl_nt11 / $wl_nt + 1))
268 [ "$wl_nt11n" -lt 10 ] && wl_nt11n="0"$wl_nt11n
269 fi
270 wl_nr=$((1 + $wl_nr1 + $wl_nr2 + wl_nr5 + wl_nr11))
271 if [ "$wl_nr1" -eq 0 ]
272 then
273 wl_nr1n="00"
274 else
275 wl_nr1n=$(($wl_pksize * $wl_nr1 / $wl_nr + 1))
276 [ "$wl_nr1n" -lt 10 ] && wl_nr1n="0"$wl_nr1n
277 fi
278 if [ "$wl_nr2" -eq 0 ]
279 then
280 wl_nr2n="00"
281 else
282 wl_nr2n=$(($wl_pksize * $wl_nr2 / $wl_nr + 1))
283 [ "$wl_nr2n" -lt 10 ] && wl_nr2n="0"$wl_nr2n
284 fi
285 if [ "$wl_nr5" -eq 0 ]
286 then
287 wl_nr5n="00"
288 else
289 wl_nr5n=$(($wl_pksize * $wl_nr5 / $wl_nr + 1))
290 [ "$wl_nr5n" -lt 10 ] && wl_nr5n="0"$wl_nr5n
291 fi
292 if [ "$wl_nr11" -eq 0 ]
293 then
294 wl_nr11n="00"
295 else
296 wl_nr11n=$(($wl_pksize * $wl_nr11 / $wl_nr + 1))
297 [ "$wl_nr11n" -lt 10 ] && wl_nr11n="0"$wl_nr11n
298 fi
29915simandl echo -n "Tx"${wlc_pkts} $wl_nt1n $wl_nt2n $wl_nt5n $wl_nt11n ${wlc_std}""
300 echo -n "Rx"${wlc_pkts} $wl_nr1n $wl_nr2n $wl_nr5n $wl_nr11n ${wlc_std}""
30113simandl fi
302 
303 [ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 ""
304 
305} # w_pkts
306######################################################################
30717simandlw_managed()
308{ echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
30924simandl 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
31015simandl 
31118simandl if [ $wcm_macoff -eq 0 ]
31215simandl then
31325simandl wl_mac=`echo -n $wl_iwctxt | $wl_awkcmd '{print $8}'`
31418simandl echo -n "${wlc_mac}$wl_mac${wlc_std} "
31515simandl fi
31626simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$10,$11,$12" "}'
31715simandl 
31824simandl wl_wtxt=`cat $wl_wireless | grep $wl_iface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'`
31914simandl wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'`
320 wl_signal=`echo $wl_wtxt | $wl_awkcmd '{print $2}'`
3212simandl wl_signal=$(($wl_signal - 256))
32214simandl wl_noise=`echo $wl_wtxt | $wl_awkcmd '{print $3}'`
3232simandl wl_noise=$(($wl_noise - 256))
3245simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
3252simandl wl_cnt=$wl_quality
326 w_bar
327 echo
328} # w_managed
329 
330######################################################################
331w_master()
33217simandl{ if [ $wcm_oneline -eq 0 ]
33321simandl then
334 echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
335 if [ $wcm_macoff -eq 1 ]
336 then
33726simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$11,$12" "}'
33821simandl else
33926simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$8,$11,$12" "}'
34021simandl fi
341 else
34226simandl echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11,$12" "}' | sed 's/ [^": ]*:/ /g'
34321simandl fi
344 
345 if [ -d $wl_hostap$wl_iface ]
34615simandl then
34721simandl wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
348 wl_macs=`ls $wl_hostap$wl_iface | grep 00`
3495simandl fi
35021simandl 
35127simandl if [ -d $wl_madwifi$wl_iface ]
35221simandl then
35327simandl wl_numcl=`cat $wl_madwifi$wl_iface/associated_sta | grep -c macaddr`
354 wl_macs=`cat $wl_madwifi$wl_iface/associated_sta | tr "<" "#" | tr ">" "#" | tr " " "#" | tr "\n" "#" | tr "m" "\n" `
35521simandl fi
356 
3572simandl echo $wlm_number_of_clients $wl_numcl
35813simandl 
3595simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
36013simandl 
36121simandl for wl_mac in $wl_macs
3622simandl do
36321simandl if [ -d $wl_hostap$wl_iface ]
364 then
365 wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'`
36622simandl wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal[=|:]//g'`
367 wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence[=|:]//g'`
36821simandl fi
369 
37027simandl if [ -d $wl_madwifi$wl_iface ]
37121simandl then
37227simandl wl_signal=`echo $wl_mac | $wl_awkcmd -F "#" '{print $7}'`
373 wl_silence="0"
374 wl_mac=`echo $wl_mac | $wl_awkcmd -F "#" '{print $3}'`
37521simandl fi
37627simandl 
37711simandl wl_cnt=$(($wl_signal - $wl_silence))
37814simandl wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky
37913simandl 
38014simandl wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'`
381 if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ]
382 then
383 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}'`
384 if [ "$wl_name" = "" ]
385 then
38617simandl wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'`
38714simandl wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' `
388 fi
389 fi
39021simandl if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] && [ -d $wl_hostap$wl_iface ]
39113simandl then
392 w_pkts
393 fi
394 
3955simandl if [ $wcm_oneline -eq 0 ]
396 then
39715simandl echo -n "${wlc_name}$wl_name${wlc_std} "
3985simandl echo -n "${wlc_ip}$wl_ipc${wlc_std} "
39915simandl if [ $wcm_macoff -eq 0 ]
400 then
401 echo -n "${wlc_mac}$wl_mac${wlc_std} "
402 fi
403 if [ $wcm_threeline -eq 1 ]
404 then
405 echo ""
406 echo -n " "
407 fi
408 echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} "
409 if [ $wcm_rxtx -eq 0 ]
410 then
411 echo ""
412 else
41321simandl if [ -d $wl_hostap$wl_iface ]
414 then
415 echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}'
416 else
417 echo ""
418 fi
41915simandl fi
4205simandl w_bar
421 else
42215simandl if [ $wcm_macoff -eq 0 ]
423 then
424 echo -n "${wlc_mac}$wl_mac${wlc_std} "
425 fi
426 echo -n "${wlc_sig}$wl_cnt${wlc_std} "
42717simandl echo -n "$wl_name "
4285simandl w_bar
429 fi
4304simandl done
43111simandl 
432 echo
4332simandl} # w_master
434 
435######################################################################
436w_iface()
43726simandl{ 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/'`
43814simandl wl_mode=`echo $wl_iwctxt | $wl_awkcmd '{print $5}' | sed 's/Mode://g'`
4392simandl if [ "a$wl_mode" = "aManaged" ]
440 then
441 w_managed
4428simandl elif [ "a$wl_mode" = "aAd-Hoc" ]
443 then
444 w_managed
4452simandl elif [ "a$wl_mode" = "aMaster" ]
446 then
447 w_master
448 else
44924simandl echo $wl_iface $wlm_no_managed_or_master
4502simandl echo
451 fi
452}
453 
454######################################################################
45511simandlw_version()
456{
457 echo wifimon $wl_version
458 exit 0
459}
460######################################################################
4615simandlw_help()
462{
46321simandl echo Monitorovani wifi karet pouzivajicich hostap nebo madwifi ovladace
4643simandl echo Pouziti: wifimon [param]
465 echo param:
46611simandl echo -v vypise verzi
4675simandl echo -html generovani html stranky
46813simandl echo -col barevny vypis na obrazovku
4695simandl echo -once vypsani jen jednoho vypisu a pak program skonci
470 echo -oneline vypsani klientu na jednu linku
47115simandl echo -threeline vypsani klienta na trech radcich
47221simandl echo -macoff vypnuti zobrazeni MAC adres
473 echo -wlan0 -ath0 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
474 echo nasledujici parametry ovlivnuji jen karty s hostap:
47515simandl echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta
47613simandl echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
477 echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
4783simandl echo bez parametru cyklicky vypis na obrazovku
4795simandl exit 0
480}
481######################################################################
482######################################################################
4832simandl 
4845simandlwl_unknown=""
485wl_cnt=1
486wcm_clear=1
487wcm_once=0
48824simandlwcm_col=0
4895simandlwcm_oneline=0
49015simandlwcm_threeline=0
4915simandlwcm_html=0
49215simandlwcm_rxtx=1
49313simandlwcm_ppkts=0
494wcm_pkts=0
4955simandlwcm_ifc=""
49615simandlwcm_macoff=0
4975simandl 
4986simandl# parsing input parameters
4995simandlwhile [ "a$1" != "a" ]
500do
501 case $1 in
50211simandl -v)
503 w_version
504 ;;
5055simandl -help)
506 w_help
507 ;;
508 -once)
509 wcm_once=1
510 shift
511 ;;
512 -oneline)
513 wcm_oneline=1
514 shift
515 ;;
51615simandl -threeline)
517 wcm_threeline=1
518 shift
519 ;;
52011simandl -col)
52124simandl wcm_col=1
5225simandl shift
523 ;;
524 -html)
525 wcm_html=1
526 shift
527 ;;
52815simandl -rxtxoff)
529 wcm_rxtx=0
530 shift
531 ;;
53213simandl -ppkts)
533 wcm_ppkts=1
534 shift
535 ;;
536 -pkts)
537 wcm_pkts=1
538 shift
539 ;;
54015simandl -macoff)
541 wcm_macoff=1
542 shift
543 ;;
5445simandl *)
545 wl_flg=0
54619simandl#wlan check
54721simandl if [ $wlf_hostap -eq 1 ]
5485simandl then
54921simandl for wl_iface in `ls $wl_hostap`
550 do
55124simandl if [ "a-$wl_iface" = "a$1" ]
55221simandl then
553 wcm_ifc="$wcm_ifc $wl_iface"
554 wl_flg=1
555 fi
556 done
557 fi
55819simandl# ath check
55921simandl if [ $wlf_madwifi -eq 1 ]
56019simandl then
56127simandl for wl_iface in `ls $wl_madwifi | grep "ath[0-9]"`
56221simandl do
56324simandl if [ "a-$wl_iface" = "a$1" ]
56421simandl then
565 wcm_ifc="$wcm_ifc $wl_iface"
566 wl_flg=1
567 fi
568 done
569 fi
5705simandl if [ $wl_flg -eq 0 ]
57121simandl then
572 wl_unknown="$wl_unknown$1 "
5735simandl fi
574 shift
575 esac
576done
577 
5786simandl# printing the list of bad parameters (if there are some)
5795simandlif [ "a$wl_unknown" != "a" ]
580then
581 echo "$wlm_unknown $wl_unknown"
582 w_help
583fi
5846simandl# if no interface is selected then all available are choosen
5855simandlif [ "a$wcm_ifc" = "a" ]
586then
58721simandl if [ $wlf_hostap -eq 1 ]
588 then
589 wcm_ifc=`ls $wl_hostap `
590 fi
591 if [ $wlf_madwifi -eq 1 ]
592 then
59327simandl wcm_ifc=`echo $wcm_ifc ; ls $wl_madwifi | grep "ath[0-9]"`
59421simandl fi
5955simandlfi
596 
5976simandl# setting for old and last same value to avoid double clear after start
598wl_numcllast=0
599wl_numclold=0
600for wl_iface in $wcm_ifc
601do
60221simandl if [ -d $wl_hostap$wl_iface ]
603 then
604 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
605 wl_numcllast=$(($wl_numcllast + $wl_numcl))
606 fi
60727simandl if [ -d $wl_madwifi$wl_iface ]
60821simandl then
60924simandl wl_mode=`$wl_iwccmd $wl_iface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'`
61021simandl if [ "a$wl_mode" = "aMaster" ]
611 then
61227simandl wl_numcl=`cat $wl_madwifi$wl_iface/associated_sta | grep -c macaddr`
61321simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
614 fi
615 fi
6166simandldone
617wl_numclold=$wl_numcllast
618 
61911simandlif [ $wcm_col -eq 0 ]
6206simandlthen
621 w_bw
62211simandlelse
62315simandl if [ $wcm_html -eq 1 ]
624 then
625 w_colh
626 else
627 w_col
628 fi
6296simandlfi
630 
63113simandlif [ $wcm_html -eq 1 ]
632then
633 [ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh
634 for wl_iface in $wcm_ifc
635 do
636 w_iface
637 done
638 echo $wl_footer
639 exit 0
640fi
641 
64215simandl#this is main loop and it will be executed forever
6436simandlwhile [ 1 ]
6445simandl do
64514simandl 
646 # when the number of associated klients has changed we will set for clear screen
6475simandl if [ $wl_numcllast -ne $wl_numclold ]
648 then
649 wl_numclold=$wl_numcllast
650 wcm_clear=1
651 fi
65214simandl 
653 #if it is set for clear screen we will do it except we produce single report
654 if [ $wcm_clear -eq 1 -a $wcm_once -eq 0 ]
6555simandl then
65614simandl echo -n $wl_clrcmde
6575simandl wcm_clear=0
658 fi
659 wl_numcllast=0
66011simandl 
66114simandl #for cyclic report we are trying to set cursor to the top left screen corner
662 if [ $wcm_once -eq 0 ]
663 then
664 echo -n $wl_tptcmde
665 fi
666 
667 #make report for all desired interfaces
66813simandl for wl_iface in $wcm_ifc
669 do
670 w_iface
671 done
672 
67314simandl #when a single report is needed than we are exiting
6745simandl if [ $wcm_once -eq 1 ]
675 then
676 exit 0
677 fi
678 sleep 1
6796simandldone
6805simandl 
681exit 0
682 

Powered by WebSVN 2.2.1