1 | 2 | simandl | #!/bin/bash |
2 | 3 | simandl | # authors : Petr Simandl www.simandl.cz |
3 | 14 | simandl | # : Fyzik, Covex, Tydyt |
4 | 20 | simandl | # release date : 09/09/2005 |
5 | 2 | simandl | # name : wifimon |
6 | 20 | simandl | # description : hostap powered wifi card monitoring |
7 | 2 | simandl | # license : GPL |
8 | | | |
9 | 20 | simandl | wl_version="0.5.5pre1" |
10 | 11 | simandl | |
11 | 13 | simandl | PATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin |
12 | | | |
13 | 14 | simandl | wl_iwccmd=`which iwconfig` |
14 | | | wl_ifccmd=`which ifconfig` |
15 | | | wl_hnmcmd=`which hostname` |
16 | | | wl_awkcmd=`which awk` |
17 | | | |
18 | | | wl_tptcmde="[1;1H" |
19 | | | wl_clrcmde="[H[2J" |
20 | | | |
21 | 19 | simandl | wl_sysdev="/proc/sys/dev/" |
22 | 14 | simandl | wl_hostap="/proc/net/hostap/" |
23 | | | wl_wireless="/proc/net/wireless" |
24 | | | wl_arp="/proc/net/arp" |
25 | | | wl_dhcpcnf="/etc/dhcpd.conf" |
26 | | | wl_dhcplss="/var/lib/dhcp/dhcpd.leases" |
27 | 17 | simandl | # wl_dhcpcnf="/etc/dhcp3/dhcpd.conf" |
28 | | | # wl_dhcplss="/var/lib/dhcp3/dhcpd.leases" |
29 | 14 | simandl | |
30 | 20 | simandl | #testing all settings |
31 | 14 | simandl | |
32 | 12 | simandl | if [ "$wl_iwccmd x" = " x" ] |
33 | | | then |
34 | | | echo "iwconfig not found" |
35 | | | exit 1 |
36 | | | fi |
37 | 2 | simandl | |
38 | 14 | simandl | if [ "$wl_ifccmd x" = " x" ] |
39 | | | then |
40 | | | echo "ifconfig not found" |
41 | | | exit 1 |
42 | | | fi |
43 | 4 | simandl | |
44 | 14 | simandl | if [ "$wl_hnmcmd x" = " x" ] |
45 | | | then |
46 | | | echo "hostname not found" |
47 | | | exit 1 |
48 | | | fi |
49 | | | |
50 | | | if [ "$wl_awkcmd x" = " x" ] |
51 | | | then |
52 | | | echo "awk not found" |
53 | | | exit 1 |
54 | | | fi |
55 | | | |
56 | 20 | simandl | if [ -d $wl_hostap ] |
57 | | | then |
58 | | | wl_nop=1 |
59 | | | else |
60 | | | echo "hostap not found" |
61 | | | exit 1 |
62 | | | fi |
63 | | | |
64 | 14 | simandl | if [ -e $wl_wireless ] |
65 | | | then |
66 | | | wl_nop=1 |
67 | | | else |
68 | | | echo "$wl_wireless not found" |
69 | | | exit 1 |
70 | | | fi |
71 | | | |
72 | | | if [ -e $wl_arp ] |
73 | | | then |
74 | | | wl_nop=1 |
75 | | | else |
76 | | | echo "$wl_arp not found" |
77 | | | exit 1 |
78 | | | fi |
79 | | | |
80 | | | if [ -e $wl_dhcpcnf ] |
81 | | | then |
82 | | | wl_nop=1 |
83 | | | else |
84 | | | echo "$wl_dhcpcnf not found" |
85 | | | wl_dhcpcnf="/dev/null" |
86 | | | fi |
87 | | | |
88 | | | if [ -e $wl_dhcplss ] |
89 | | | then |
90 | | | wl_nop=1 |
91 | | | else |
92 | | | echo "$wl_dhcplss not found" |
93 | | | wl_dhcplss="/dev/null" |
94 | | | fi |
95 | | | |
96 | 20 | simandl | wl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" |
97 | | | wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" |
98 | | | wl_footer="</pre></body></html>" |
99 | 7 | simandl | |
100 | 20 | simandl | wlm_no_managed_or_master=" neni ani Master ani Managed..." |
101 | | | wlm_number_of_clients="Pocet asociovanych klientu : " |
102 | | | wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : " |
103 | | | #wlm_no_managed_or_master=" is not Master or Managed..." |
104 | | | #wlm_number_of_clients="Number of associated clients : " |
105 | 7 | simandl | |
106 | 20 | simandl | wlch_signal="=" |
107 | | | wlch_noise="*" |
108 | 11 | simandl | |
109 | 2 | simandl | ###################################################################### |
110 | 11 | simandl | w_col() |
111 | 10 | simandl | { |
112 | 15 | simandl | wlc_red=`tput setaf 1` # ruda (Red) |
113 | | | wlc_green=`tput setaf 2` # zelena (Lime) |
114 | | | wlc_brown=`tput setaf 3` # zluta (Yellow) |
115 | | | wlc_blue=`tput setaf 4` # modra (Blue) |
116 | | | wlc_magenta=`tput setaf 5` # fialova (Fuchsia) |
117 | | | wlc_lblue=`tput setaf 6` # svetle modra (Aqua) |
118 | | | wlc_grey=`tput setaf 7` # bila (White) |
119 | 11 | simandl | wlc_std=`tput sgr0` |
120 | | | |
121 | 15 | simandl | wlc_pkts=$wlc_red # Rx,Tx info color |
122 | 11 | simandl | wlc_ip=$wlc_lblue # ip address color |
123 | | | wlc_mac=$wlc_magenta # mac address color |
124 | 15 | simandl | wlc_name=$wlc_magenta # host name color |
125 | 11 | simandl | wlc_sig=$wlc_red # signal number color |
126 | | | wlc_bar=$wlc_green # signal bar color |
127 | 15 | simandl | wlc_noise=$wlc_red # Signal noise color |
128 | 10 | simandl | } |
129 | | | ###################################################################### |
130 | 15 | simandl | w_colh() |
131 | | | { |
132 | | | wlh_pkts="Olive" # signal number color html |
133 | | | wlh_ip="Blue" # ip address color html |
134 | | | wlh_mac="Fuchsia" # mac address color html |
135 | | | wlh_name="Fuchsia" # Host name color html |
136 | | | wlh_sig="Red" # signal number color html |
137 | | | wlh_bar="Lime" # signal bar color html |
138 | | | wlh_noise="Red" # Signal noise color html |
139 | | | |
140 | | | wlc_pkts="<font color=\"$wlh_pkts\">" |
141 | | | wlc_ip="<font color=\"$wlh_ip\">" |
142 | | | wlc_mac="<font color=\"$wlh_mac\">" |
143 | | | wlc_name="<font color=\"$wlh_name\">" |
144 | | | wlc_sig="<font color=\"$wlh_sig\">" |
145 | | | wlc_bar="<font color=\"$wlh_bar\">" |
146 | | | wlc_noise="<font color=\"$wlh_noise\">" |
147 | | | wlc_std="</font>" |
148 | | | } |
149 | | | ###################################################################### |
150 | 4 | simandl | w_bw() |
151 | | | { |
152 | 15 | simandl | wlc_pkts="" |
153 | 6 | simandl | wlc_ip="" |
154 | | | wlc_mac="" |
155 | | | wlc_sig="" |
156 | | | wlc_bar="" |
157 | 15 | simandl | wlc_noise="" |
158 | 6 | simandl | wlc_std="" |
159 | 4 | simandl | } |
160 | | | ###################################################################### |
161 | 2 | simandl | w_bar() |
162 | | | { |
163 | 11 | simandl | wl_neg=`expr $wl_cnt \< 0 ` |
164 | | | if [ "$wl_neg" -eq 1 ] |
165 | | | then |
166 | 15 | simandl | echo -n "${wlc_noise}" |
167 | 11 | simandl | wl_cnt=$(($wl_cnt * -1 )) |
168 | | | wl_bar=$wlch_noise |
169 | | | else |
170 | 15 | simandl | echo -n "${wlc_bar}" |
171 | 11 | simandl | wl_bar=$wlch_signal |
172 | | | fi |
173 | 2 | simandl | until [ "$wl_cnt" -eq -1 ] |
174 | | | do |
175 | 11 | simandl | echo -n "$wl_bar" |
176 | 2 | simandl | wl_cnt=$(($wl_cnt - 1 )) |
177 | | | done |
178 | | | printf " \n" |
179 | 6 | simandl | echo -n "${wlc_std}" |
180 | 11 | simandl | # tput sgr0 |
181 | 2 | simandl | } # w_bar |
182 | | | |
183 | | | ###################################################################### |
184 | 13 | simandl | w_pkts() |
185 | | | { |
186 | | | wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'` |
187 | 14 | simandl | wl_nt1=`echo $wl_macpkts | $wl_awkcmd '{print $2}'` |
188 | | | wl_nt2=`echo $wl_macpkts | $wl_awkcmd '{print $4}'` |
189 | | | wl_nt5=`echo $wl_macpkts | $wl_awkcmd '{print $6}'` |
190 | | | wl_nt11=`echo $wl_macpkts | $wl_awkcmd '{print $8}'` |
191 | | | wl_nr1=`echo $wl_macpkts | $wl_awkcmd '{print $10}'` |
192 | | | wl_nr2=`echo $wl_macpkts | $wl_awkcmd '{print $12}'` |
193 | | | wl_nr5=`echo $wl_macpkts | $wl_awkcmd '{print $14}'` |
194 | | | wl_nr11=`echo $wl_macpkts | $wl_awkcmd '{print $16}'` |
195 | 13 | simandl | |
196 | | | if [ $wcm_ppkts -eq 1 ] |
197 | | | then |
198 | | | wl_pksize=$((98)) |
199 | | | wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11)) |
200 | | | if [ "$wl_nt1" -eq 0 ] |
201 | | | then |
202 | | | wl_nt1n="00" |
203 | | | else |
204 | | | wl_nt1n=$(($wl_pksize * $wl_nt1 / $wl_nt + 1)) |
205 | | | [ "$wl_nt1n" -lt 10 ] && wl_nt1n="0"$wl_nt1n |
206 | | | fi |
207 | | | if [ "$wl_nt2" -eq 0 ] |
208 | | | then |
209 | | | wl_nt2n="00" |
210 | | | else |
211 | | | wl_nt2n=$(($wl_pksize * $wl_nt2 / $wl_nt + 1)) |
212 | | | [ "$wl_nt2n" -lt 10 ] && wl_nt2n="0"$wl_nt2n |
213 | | | fi |
214 | | | if [ "$wl_nt5" -eq 0 ] |
215 | | | then |
216 | | | wl_nt5n="00" |
217 | | | else |
218 | | | wl_nt5n=$(($wl_pksize * $wl_nt5 / $wl_nt + 1)) |
219 | | | [ "$wl_nt5n" -lt 10 ] && wl_nt5n="0"$wl_nt5n |
220 | | | fi |
221 | | | if [ "$wl_nt11" -eq 0 ] |
222 | | | then |
223 | | | wl_nt11n="00" |
224 | | | else |
225 | | | wl_nt11n=$(($wl_pksize * $wl_nt11 / $wl_nt + 1)) |
226 | | | [ "$wl_nt11n" -lt 10 ] && wl_nt11n="0"$wl_nt11n |
227 | | | fi |
228 | | | wl_nr=$((1 + $wl_nr1 + $wl_nr2 + wl_nr5 + wl_nr11)) |
229 | | | if [ "$wl_nr1" -eq 0 ] |
230 | | | then |
231 | | | wl_nr1n="00" |
232 | | | else |
233 | | | wl_nr1n=$(($wl_pksize * $wl_nr1 / $wl_nr + 1)) |
234 | | | [ "$wl_nr1n" -lt 10 ] && wl_nr1n="0"$wl_nr1n |
235 | | | fi |
236 | | | if [ "$wl_nr2" -eq 0 ] |
237 | | | then |
238 | | | wl_nr2n="00" |
239 | | | else |
240 | | | wl_nr2n=$(($wl_pksize * $wl_nr2 / $wl_nr + 1)) |
241 | | | [ "$wl_nr2n" -lt 10 ] && wl_nr2n="0"$wl_nr2n |
242 | | | fi |
243 | | | if [ "$wl_nr5" -eq 0 ] |
244 | | | then |
245 | | | wl_nr5n="00" |
246 | | | else |
247 | | | wl_nr5n=$(($wl_pksize * $wl_nr5 / $wl_nr + 1)) |
248 | | | [ "$wl_nr5n" -lt 10 ] && wl_nr5n="0"$wl_nr5n |
249 | | | fi |
250 | | | if [ "$wl_nr11" -eq 0 ] |
251 | | | then |
252 | | | wl_nr11n="00" |
253 | | | else |
254 | | | wl_nr11n=$(($wl_pksize * $wl_nr11 / $wl_nr + 1)) |
255 | | | [ "$wl_nr11n" -lt 10 ] && wl_nr11n="0"$wl_nr11n |
256 | | | fi |
257 | 15 | simandl | echo -n "Tx"${wlc_pkts} $wl_nt1n $wl_nt2n $wl_nt5n $wl_nt11n ${wlc_std}"" |
258 | | | echo -n "Rx"${wlc_pkts} $wl_nr1n $wl_nr2n $wl_nr5n $wl_nr11n ${wlc_std}"" |
259 | 13 | simandl | fi |
260 | | | |
261 | | | [ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 "" |
262 | | | |
263 | | | } # w_pkts |
264 | | | ###################################################################### |
265 | 17 | simandl | w_managed() |
266 | | | { echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}' |
267 | 18 | simandl | 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 |
268 | 15 | simandl | |
269 | 18 | simandl | if [ $wcm_macoff -eq 0 ] |
270 | 15 | simandl | then |
271 | 19 | simandl | wl_mac=`echo -n $wl_iwctxt | $wl_awkcmd '{print $9}'` |
272 | 18 | simandl | echo -n "${wlc_mac}$wl_mac${wlc_std} " |
273 | 15 | simandl | fi |
274 | 18 | simandl | echo $wl_iwctxt | $wl_awkcmd '{print $6,$10" "}' |
275 | 15 | simandl | |
276 | 14 | simandl | wl_wtxt=`cat $wl_wireless | grep $wl_iface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'` |
277 | | | wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'` |
278 | | | wl_signal=`echo $wl_wtxt | $wl_awkcmd '{print $2}'` |
279 | 2 | simandl | wl_signal=$(($wl_signal - 256)) |
280 | 14 | simandl | wl_noise=`echo $wl_wtxt | $wl_awkcmd '{print $3}'` |
281 | 2 | simandl | wl_noise=$(($wl_noise - 256)) |
282 | 5 | simandl | echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise " |
283 | 2 | simandl | wl_cnt=$wl_quality |
284 | | | w_bar |
285 | | | echo |
286 | | | } # w_managed |
287 | | | |
288 | | | ###################################################################### |
289 | | | w_master() |
290 | 17 | simandl | { if [ $wcm_oneline -eq 0 ] |
291 | 20 | simandl | then |
292 | | | echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}' |
293 | | | if [ $wcm_macoff -eq 1 ] |
294 | 15 | simandl | then |
295 | 20 | simandl | echo $wl_iwctxt | $wl_awkcmd '{print $6,$11" "}' |
296 | | | else |
297 | | | echo $wl_iwctxt | $wl_awkcmd '{print $6,$9,$11" "}' |
298 | | | fi |
299 | | | else |
300 | | | echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g' |
301 | 5 | simandl | fi |
302 | 20 | simandl | wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` |
303 | 2 | simandl | echo $wlm_number_of_clients $wl_numcl |
304 | 13 | simandl | |
305 | 5 | simandl | wl_numcllast=$(($wl_numcllast + $wl_numcl)) |
306 | 13 | simandl | |
307 | 20 | simandl | for wl_mac in `ls $wl_hostap$wl_iface | grep 00 ` |
308 | 2 | simandl | do |
309 | 20 | simandl | wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'` |
310 | | | wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal=//g'` |
311 | | | wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence=//g'` |
312 | 11 | simandl | wl_cnt=$(($wl_signal - $wl_silence)) |
313 | 14 | simandl | wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky |
314 | 13 | simandl | |
315 | 14 | simandl | wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'` |
316 | | | if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ] |
317 | | | then |
318 | | | 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}'` |
319 | | | if [ "$wl_name" = "" ] |
320 | | | then |
321 | 17 | simandl | wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'` |
322 | 14 | simandl | wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' ` |
323 | | | fi |
324 | | | fi |
325 | 20 | simandl | if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] |
326 | 13 | simandl | then |
327 | | | w_pkts |
328 | | | fi |
329 | | | |
330 | 5 | simandl | if [ $wcm_oneline -eq 0 ] |
331 | | | then |
332 | 15 | simandl | echo -n "${wlc_name}$wl_name${wlc_std} " |
333 | 5 | simandl | echo -n "${wlc_ip}$wl_ipc${wlc_std} " |
334 | 15 | simandl | if [ $wcm_macoff -eq 0 ] |
335 | | | then |
336 | | | echo -n "${wlc_mac}$wl_mac${wlc_std} " |
337 | | | fi |
338 | | | if [ $wcm_threeline -eq 1 ] |
339 | | | then |
340 | | | echo "" |
341 | | | echo -n " " |
342 | | | fi |
343 | | | echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} " |
344 | | | if [ $wcm_rxtx -eq 0 ] |
345 | | | then |
346 | | | echo "" |
347 | | | else |
348 | 20 | simandl | echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}' |
349 | 15 | simandl | fi |
350 | 5 | simandl | w_bar |
351 | | | else |
352 | 15 | simandl | if [ $wcm_macoff -eq 0 ] |
353 | | | then |
354 | | | echo -n "${wlc_mac}$wl_mac${wlc_std} " |
355 | | | fi |
356 | | | echo -n "${wlc_sig}$wl_cnt${wlc_std} " |
357 | 17 | simandl | echo -n "$wl_name " |
358 | 5 | simandl | w_bar |
359 | | | fi |
360 | 4 | simandl | done |
361 | 11 | simandl | |
362 | | | echo |
363 | 2 | simandl | } # w_master |
364 | | | |
365 | | | ###################################################################### |
366 | | | w_iface() |
367 | 18 | simandl | { wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/' | sed 's/Access Point/Access_Point/'` |
368 | 14 | simandl | wl_mode=`echo $wl_iwctxt | $wl_awkcmd '{print $5}' | sed 's/Mode://g'` |
369 | 2 | simandl | if [ "a$wl_mode" = "aManaged" ] |
370 | | | then |
371 | | | w_managed |
372 | 8 | simandl | elif [ "a$wl_mode" = "aAd-Hoc" ] |
373 | | | then |
374 | | | w_managed |
375 | 2 | simandl | elif [ "a$wl_mode" = "aMaster" ] |
376 | | | then |
377 | | | w_master |
378 | | | else |
379 | | | echo $wl_iface $wlm_no_managed_or_master |
380 | | | echo |
381 | | | fi |
382 | | | } |
383 | | | |
384 | | | ###################################################################### |
385 | 11 | simandl | w_version() |
386 | | | { |
387 | | | echo wifimon $wl_version |
388 | | | exit 0 |
389 | | | } |
390 | | | ###################################################################### |
391 | 5 | simandl | w_help() |
392 | | | { |
393 | 3 | simandl | echo Pouziti: wifimon [param] |
394 | | | echo param: |
395 | 11 | simandl | echo -v vypise verzi |
396 | 5 | simandl | echo -html generovani html stranky |
397 | 13 | simandl | echo -col barevny vypis na obrazovku |
398 | 5 | simandl | echo -once vypsani jen jednoho vypisu a pak program skonci |
399 | | | echo -oneline vypsani klientu na jednu linku |
400 | 15 | simandl | echo -threeline vypsani klienta na trech radcich |
401 | | | echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta |
402 | 20 | simandl | echo -macoff vypnuti zobrazeni MAC adres |
403 | 13 | simandl | echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty |
404 | | | echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty |
405 | 20 | simandl | echo -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi |
406 | 3 | simandl | echo bez parametru cyklicky vypis na obrazovku |
407 | 5 | simandl | exit 0 |
408 | | | } |
409 | | | ###################################################################### |
410 | | | ###################################################################### |
411 | 2 | simandl | |
412 | 5 | simandl | wl_unknown="" |
413 | | | wl_cnt=1 |
414 | | | wcm_clear=1 |
415 | | | wcm_once=0 |
416 | 11 | simandl | wcm_col=0 |
417 | 5 | simandl | wcm_oneline=0 |
418 | 15 | simandl | wcm_threeline=0 |
419 | 5 | simandl | wcm_html=0 |
420 | 15 | simandl | wcm_rxtx=1 |
421 | 13 | simandl | wcm_ppkts=0 |
422 | | | wcm_pkts=0 |
423 | 5 | simandl | wcm_ifc="" |
424 | 15 | simandl | wcm_macoff=0 |
425 | 5 | simandl | |
426 | 6 | simandl | # parsing input parameters |
427 | 5 | simandl | while [ "a$1" != "a" ] |
428 | | | do |
429 | | | case $1 in |
430 | 11 | simandl | -v) |
431 | | | w_version |
432 | | | ;; |
433 | 5 | simandl | -help) |
434 | | | w_help |
435 | | | ;; |
436 | | | -once) |
437 | | | wcm_once=1 |
438 | | | shift |
439 | | | ;; |
440 | | | -oneline) |
441 | | | wcm_oneline=1 |
442 | | | shift |
443 | | | ;; |
444 | 15 | simandl | -threeline) |
445 | | | wcm_threeline=1 |
446 | | | shift |
447 | | | ;; |
448 | 11 | simandl | -col) |
449 | | | wcm_col=1 |
450 | 5 | simandl | shift |
451 | | | ;; |
452 | | | -html) |
453 | | | wcm_html=1 |
454 | | | shift |
455 | | | ;; |
456 | 15 | simandl | -rxtxoff) |
457 | | | wcm_rxtx=0 |
458 | | | shift |
459 | | | ;; |
460 | 13 | simandl | -ppkts) |
461 | | | wcm_ppkts=1 |
462 | | | shift |
463 | | | ;; |
464 | | | -pkts) |
465 | | | wcm_pkts=1 |
466 | | | shift |
467 | | | ;; |
468 | 15 | simandl | -macoff) |
469 | | | wcm_macoff=1 |
470 | | | shift |
471 | | | ;; |
472 | 5 | simandl | *) |
473 | | | wl_flg=0 |
474 | 19 | simandl | #wlan check |
475 | 20 | simandl | for wl_iface in `ls $wl_hostap` |
476 | | | do |
477 | | | if [ "a-$wl_iface" = "a$1" ] |
478 | 5 | simandl | then |
479 | 20 | simandl | wcm_ifc="$wcm_ifc $wl_iface" |
480 | | | wl_flg=1 |
481 | | | fi |
482 | | | done |
483 | 19 | simandl | # ath check |
484 | 20 | simandl | for wl_iface in `ls $wl_sysdev | grep "ath[0..9]"` |
485 | | | do |
486 | | | if [ "a-$wl_iface" = "a$1" ] |
487 | 19 | simandl | then |
488 | 20 | simandl | wcm_ifc="$wcm_ifc $wl_iface" |
489 | | | wl_flg=1 |
490 | | | fi |
491 | | | done |
492 | 5 | simandl | if [ $wl_flg -eq 0 ] |
493 | 20 | simandl | then |
494 | | | wl_unknown="$wl_unknown$1 " |
495 | 5 | simandl | fi |
496 | | | shift |
497 | | | esac |
498 | | | done |
499 | | | |
500 | 6 | simandl | # printing the list of bad parameters (if there are some) |
501 | 5 | simandl | if [ "a$wl_unknown" != "a" ] |
502 | | | then |
503 | | | echo "$wlm_unknown $wl_unknown" |
504 | | | w_help |
505 | | | fi |
506 | 20 | simandl | |
507 | 6 | simandl | # if no interface is selected then all available are choosen |
508 | 5 | simandl | if [ "a$wcm_ifc" = "a" ] |
509 | | | then |
510 | 20 | simandl | wcm_ifc=`ls $wl_hostap ; ls $wl_sysdev | grep "ath[0..9]"` |
511 | 5 | simandl | fi |
512 | | | |
513 | 6 | simandl | # setting for old and last same value to avoid double clear after start |
514 | | | wl_numcllast=0 |
515 | | | wl_numclold=0 |
516 | | | for wl_iface in $wcm_ifc |
517 | | | do |
518 | 20 | simandl | wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` |
519 | | | wl_numcllast=$(($wl_numcllast + $wl_numcl)) |
520 | 6 | simandl | done |
521 | | | wl_numclold=$wl_numcllast |
522 | | | |
523 | 11 | simandl | if [ $wcm_col -eq 0 ] |
524 | 6 | simandl | then |
525 | | | w_bw |
526 | 11 | simandl | else |
527 | 15 | simandl | if [ $wcm_html -eq 1 ] |
528 | | | then |
529 | | | w_colh |
530 | | | else |
531 | | | w_col |
532 | | | fi |
533 | 6 | simandl | fi |
534 | | | |
535 | 13 | simandl | if [ $wcm_html -eq 1 ] |
536 | | | then |
537 | | | [ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh |
538 | | | for wl_iface in $wcm_ifc |
539 | | | do |
540 | | | w_iface |
541 | | | done |
542 | | | echo $wl_footer |
543 | | | exit 0 |
544 | | | fi |
545 | | | |
546 | 15 | simandl | #this is main loop and it will be executed forever |
547 | 6 | simandl | while [ 1 ] |
548 | 5 | simandl | do |
549 | 14 | simandl | |
550 | | | # when the number of associated klients has changed we will set for clear screen |
551 | 5 | simandl | if [ $wl_numcllast -ne $wl_numclold ] |
552 | | | then |
553 | | | wl_numclold=$wl_numcllast |
554 | | | wcm_clear=1 |
555 | | | fi |
556 | 14 | simandl | |
557 | | | #if it is set for clear screen we will do it except we produce single report |
558 | | | if [ $wcm_clear -eq 1 -a $wcm_once -eq 0 ] |
559 | 5 | simandl | then |
560 | 14 | simandl | echo -n $wl_clrcmde |
561 | 5 | simandl | wcm_clear=0 |
562 | | | fi |
563 | | | wl_numcllast=0 |
564 | 11 | simandl | |
565 | 14 | simandl | #for cyclic report we are trying to set cursor to the top left screen corner |
566 | | | if [ $wcm_once -eq 0 ] |
567 | | | then |
568 | | | echo -n $wl_tptcmde |
569 | | | fi |
570 | | | |
571 | | | #make report for all desired interfaces |
572 | 13 | simandl | for wl_iface in $wcm_ifc |
573 | | | do |
574 | | | w_iface |
575 | | | done |
576 | | | |
577 | 14 | simandl | #when a single report is needed than we are exiting |
578 | 5 | simandl | if [ $wcm_once -eq 1 ] |
579 | | | then |
580 | | | exit 0 |
581 | | | fi |
582 | | | sleep 1 |
583 | 6 | simandl | done |
584 | 5 | simandl | |
585 | | | exit 0 |
586 | | | |