jablonka.czprosek.czf

wifimon

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

 

Line No. Rev Author Line
12simandl#!/bin/bash
23simandl# authors : Petr Simandl www.simandl.cz
34simandl# : Fyzik
45simandl# release date : 22/1/2003
52simandl# name : wifimon
65simandl# version : 0.3
72simandl# description : hostap powered wifi card monitoring
8# license : GPL
9 
10wl_iwccmd="/usr/local/sbin/iwconfig"
113simandlwl_ifccmd="/sbin/ifconfig"
12wl_hnmcmd="/bin/hostname"
132simandlwl_hostap="/proc/net/hostap/"
14wl_wireless="/proc/net/wireless"
153simandlwl_arp="/proc/net/arp"
162simandl 
174simandlwlc_red=`tput setaf 1`
18wlc_green=`tput setaf 2`
19wlc_brown=`tput setaf 3`
20wlc_blue=`tput setaf 4`
21wlc_magenta=`tput setaf 5`
22wlc_lblue=`tput setaf 6`
23wlc_grey=`tput setaf 7`
24wlc_std=`tput sgr0`
25 
26wlc_ip=$wlc_lblue # ip address color
27wlc_mac=$wlc_magenta # mac address color
28wlc_sig=$wlc_red # signal number color
29wlc_bar=$wlc_green # signal bar color
30 
313simandlwl_webpage="/tmp/wifimon.htm"
325simandlwl_header="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
333simandlwl_header_static="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
34wl_footer="</pre></body></html>"
35 
362simandlwlm_no_managed_or_master=" neni ani Master ani Managed..."
37wlm_number_of_clients="Pocet asociovanych klientu : "
385simandlwlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "
392simandl#wlm_no_managed_or_master=" is not Master or Managed..."
40#wlm_number_of_clients="Number of associated clients : "
414simandl 
422simandl######################################################################
434simandlw_bw()
44{
45 wlc_ip=$wlc_std
46 wlc_mac=$wlc_std
47 wlc_sig=$wlc_std
48 wlc_bar=$wlc_std
49}
50######################################################################
512simandlw_bar()
52{
534simandl echo -n "${wlc_bar}"
542simandl until [ "$wl_cnt" -eq -1 ]
55 do
56 printf "="
57 wl_cnt=$(($wl_cnt - 1 ))
58 done
59 printf " \n"
604simandl tput sgr0
612simandl} # w_bar
62 
63######################################################################
64w_managed()
65{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'
663simandl echo -n `$wl_ifccmd $wl_iface | grep -E "inet addr|inet adr" | awk '{print $2" "}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfig
67 echo $wl_iwctxt | awk '{print $9,$6,$11" "}'
682simandl #echo $wl_iwctxt | awk '{print $27,$28,$29,$31,$32" "}'
69 #cat $wl_wireless | grep $wl_iface
70 wl_wtxt=`cat $wl_wireless | grep $wl_iface | awk '{print $3,$4,$5}' | sed 's/\.//g'`
71 wl_quality=`echo $wl_wtxt | awk '{print $1}'`
72 wl_signal=`echo $wl_wtxt | awk '{print $2}'`
73 wl_signal=$(($wl_signal - 256))
74 wl_noise=`echo $wl_wtxt | awk '{print $3}'`
75 wl_noise=$(($wl_noise - 256))
765simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
772simandl wl_cnt=$wl_quality
78 w_bar
79 #wl_cnt=$(($wl_cnt + 100))
80 #w_bar
81 echo
82} # w_managed
83 
84######################################################################
85w_master()
865simandl{ if [ $wcm_oneline -eq 0 ]
87 then
88 echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'
89 echo $wl_iwctxt | awk '{print $6,$9,$11" "}'
90 else
91 echo $wl_iwctxt | awk '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g'
92 fi
932simandl 
94 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
95 echo $wlm_number_of_clients $wl_numcl
965simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
973simandl for wl_mac in `ls $wl_hostap$wl_iface | grep 00 `
982simandl do
99 wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx'`
100 wl_cnt=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'`
1013simandl wl_umac=`echo $wl_mac | tr abcdef ABCDEF`
102 wl_ipc=`cat $wl_arp | grep $wl_umac | awk '{print $1}'` # IP adresa peeru z arp tabulky
1035simandl if [ $wcm_oneline -eq 0 ]
104 then
105 echo -n "${wlc_ip}$wl_ipc${wlc_std} "
106 echo -n "${wlc_mac}$wl_umac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} "
107 echo $wl_macparam | awk '{print $1,$2" "}'
108 w_bar
109 else
110 #echo -n "${wlc_ip}$wl_ipc${wlc_std} "
111 echo -n "${wlc_mac}$wl_umac${wlc_std} ${wlc_sig}$wl_cnt${wlc_std} "
112 #echo -n $wl_macparam | awk '{print $1,$2" "}'
113 w_bar
114 fi
1154simandl done
1162simandl 
117 echo
118} # w_master
119 
120######################################################################
121w_iface()
122{ wl_iwctxt=`$wl_iwccmd $wl_iface | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/g'`
123 wl_mode=`echo $wl_iwctxt | awk '{print $5}' | sed 's/Mode://g'`
124 if [ "a$wl_mode" = "aManaged" ]
125 then
126 w_managed
127 elif [ "a$wl_mode" = "aMaster" ]
128 then
129 w_master
130 else
131 echo $wl_iface $wlm_no_managed_or_master
132 echo
133 fi
134}
135 
136######################################################################
1375simandlw_help()
138{
1393simandl echo Pouziti: wifimon [param]
140 echo param:
1415simandl echo -html generovani html stranky
1424simandl echo -col barevny cyklicky vypis na obrazovku
1435simandl echo -once vypsani jen jednoho vypisu a pak program skonci
144 echo -oneline vypsani klientu na jednu linku
145 echo -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
1463simandl echo bez parametru cyklicky vypis na obrazovku
1475simandl exit 0
148}
149######################################################################
150######################################################################
1512simandl 
1525simandl 
153wl_unknown=""
154wl_cnt=1
155wl_numcllast=0
156wl_numclold=0
157wcm_clear=1
158wcm_once=0
159wcm_col=0
160wcm_oneline=0
161wcm_html=0
162wcm_ifc=""
163 
164while [ "a$1" != "a" ]
165do
166 case $1 in
167 -help)
168 w_help
169 ;;
170 -once)
171 wcm_once=1
172 shift
173 ;;
174 -oneline)
175 wcm_oneline=1
176 shift
177 ;;
178 -col)
179 wcm_col=1
180 shift
181 ;;
182 -html)
183 wcm_html=1
184 shift
185 ;;
186 *)
187 wl_flg=0
188 for wl_iface in `ls $wl_hostap`
189 do
190 if [ "a-$wl_iface" = "a$1" ]
191 then
192 wcm_ifc="$wcm_ifc $wl_iface"
193 wl_flg=1
194 fi
195 done
196 if [ $wl_flg -eq 0 ]
197 then
198 wl_unknown="$wl_unknown$1 "
199 fi
200 shift
201 esac
202done
203 
204if [ "a$wl_unknown" != "a" ]
205then
206 echo "$wlm_unknown $wl_unknown"
207 w_help
208fi
209 
210if [ "a$wcm_ifc" = "a" ]
211then
212 wcm_ifc=`ls $wl_hostap`
213fi
214 
215 if [ $wcm_col -eq 0 ]
216 then
217 w_bw
218 fi
219 while [ 1 ]
220 do
221 if [ $wl_numcllast -ne $wl_numclold ]
222 then
223 wl_numclold=$wl_numcllast
224 wcm_clear=1
225 fi
226 if [ $wcm_clear -eq 1 ]
227 then
228 clear
229 wcm_clear=0
230 fi
231 tput cup 0 0
232 wl_numcllast=0
233 if [ $wcm_html -eq 1 ]
234 then
235 w_bw
236 echo $wl_header
237 for wl_iface in $wcm_ifc
238 do
239 w_iface
240 done
241 echo $wl_footer
242 else
243 for wl_iface in $wcm_ifc
244 do
245 w_iface
246 done
247 fi
248 
249 if [ $wcm_once -eq 1 ]
250 then
251 exit 0
252 fi
253 sleep 1
254 done
255 
256 
257 
258exit 0
259 
260 
261case $1 in
262-help)
263 w_help
2643simandl;;
265-htm1)
2664simandl 
267;;
2685simandl-1)
269 w_bw
270 clear
271 tput cup 0 0
272 for wl_iface in `ls $wl_hostap`
273 do
274 w_iface
275 done
2764simandl 
277;;
278-htm1)
279 w_bw
2803simandl echo $wl_header_static > $wl_webpage
281 for wl_iface in `ls $wl_hostap`
282 do
283 w_iface >> $wl_webpage
284 done
285 echo $wl_footer >> $wl_webpage
286;;
287-htm)
2884simandl w_bw
2893simandl while [ 1 ]
290 do
291 echo $wl_header > $wl_webpage.tmp
292 for wl_iface in `ls $wl_hostap`
293 do
294 w_iface >> $wl_webpage.tmp
295 done
296 echo $wl_footer >> $wl_webpage.tmp
297 cp $wl_webpage.tmp $wl_webpage
298 sleep 1
2992simandl done
3003simandl;;
3014simandl-col)
302 clear
303 while [ 1 ]
304 do
305 tput cup 0 0
306 for wl_iface in `ls $wl_hostap`
307 do
308 w_iface
309 done
310 sleep 1
311 done
312;;
3133simandl*)
3144simandl w_bw
3153simandl clear
316 while [ 1 ]
317 do
318 tput cup 0 0
319 for wl_iface in `ls $wl_hostap`
320 do
321 w_iface
322 done
323 sleep 1
324 done
325esac
3262simandl 
327exit 0
328 
329 

Powered by WebSVN 2.2.1