jablonka.czprosek.czf

wifimon

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

 

Line No. Rev Author Line
12simandl#!/bin/bash
23simandl# authors : Petr Simandl www.simandl.cz
39simandl# : Fyzik, Covex
4# release date : 16/6/2003
52simandl# name : wifimon
6# description : hostap powered wifi card monitoring
7# license : GPL
8 
99simandlwl_version="0.4beta4"
10 
117simandlwl_iwccmd="/usr/local/sbin/iwconfig"
12wl_ifccmd="/sbin/ifconfig"
13wl_hnmcmd="/bin/hostname"
142simandlwl_hostap="/proc/net/hostap/"
15wl_wireless="/proc/net/wireless"
163simandlwl_arp="/proc/net/arp"
172simandl 
184simandlwlc_red=`tput setaf 1`
19wlc_green=`tput setaf 2`
20wlc_brown=`tput setaf 3`
21wlc_blue=`tput setaf 4`
22wlc_magenta=`tput setaf 5`
23wlc_lblue=`tput setaf 6`
24wlc_grey=`tput setaf 7`
25wlc_std=`tput sgr0`
26 
27wlc_ip=$wlc_lblue # ip address color
28wlc_mac=$wlc_magenta # mac address color
29wlc_sig=$wlc_red # signal number color
30wlc_bar=$wlc_green # signal bar color
317simandl 
32wl_webpage="/tmp/wifimon.htm"
33wl_header="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
34wl_footer="</pre></body></html>"
35 
36wlm_no_managed_or_master=" neni ani Master ani Managed..."
37wlm_number_of_clients="Pocet asociovanych klientu : "
38wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "
39#wlm_no_managed_or_master=" is not Master or Managed..."
40#wlm_number_of_clients="Number of associated clients : "
41 
422simandl######################################################################
434simandlw_bw()
44{
456simandl wlc_ip=""
46 wlc_mac=""
47 wlc_sig=""
48 wlc_bar=""
49 wlc_std=""
504simandl}
51######################################################################
522simandlw_bar()
53{
544simandl echo -n "${wlc_bar}"
552simandl until [ "$wl_cnt" -eq -1 ]
56 do
577simandl printf "="
582simandl wl_cnt=$(($wl_cnt - 1 ))
59 done
60 printf " \n"
616simandl echo -n "${wlc_std}"
62# tput sgr0
632simandl} # w_bar
64 
65######################################################################
66w_managed()
677simandl{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'
68 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
69 echo $wl_iwctxt | awk '{print $9,$6,$11" "}'
70 #echo $wl_iwctxt | awk '{print $27,$28,$29,$31,$32" "}'
71 #cat $wl_wireless | grep $wl_iface
72 wl_wtxt=`cat $wl_wireless | grep $wl_iface | awk '{print $3,$4,$5}' | sed 's/\.//g'`
73 wl_quality=`echo $wl_wtxt | awk '{print $1}'`
74 wl_signal=`echo $wl_wtxt | awk '{print $2}'`
752simandl wl_signal=$(($wl_signal - 256))
767simandl wl_noise=`echo $wl_wtxt | awk '{print $3}'`
772simandl wl_noise=$(($wl_noise - 256))
785simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
792simandl wl_cnt=$wl_quality
80 w_bar
817simandl #wl_cnt=$(($wl_cnt + 100))
82 #w_bar
832simandl echo
84} # w_managed
85 
86######################################################################
87w_master()
885simandl{ if [ $wcm_oneline -eq 0 ]
89 then
907simandl echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'
91 echo $wl_iwctxt | awk '{print $6,$9,$11" "}'
925simandl else
937simandl echo $wl_iwctxt | awk '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g'
945simandl fi
952simandl 
96 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
97 echo $wlm_number_of_clients $wl_numcl
985simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
993simandl for wl_mac in `ls $wl_hostap$wl_iface | grep 00 `
1002simandl do
1019simandl wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'`
1027simandl wl_cnt=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'`
1038simandl wl_ipc=`cat $wl_arp | grep -i $wl_mac | awk '{print $1}'` # IP adresa peeru z arp tabulky
104 wl_name=`cat /etc/dhcpd.conf | grep -i $wl_mac | awk '{print $2}'`
1055simandl if [ $wcm_oneline -eq 0 ]
106 then
1078simandl echo -n "$wl_name "
1085simandl echo -n "${wlc_ip}$wl_ipc${wlc_std} "
1098simandl echo -n "${wlc_mac}$wl_mac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} "
1107simandl echo $wl_macparam | awk '{print $1,$2" "}'
1115simandl w_bar
112 else
1138simandl echo -n "$wl_name "
1147simandl #echo -n "${wlc_ip}$wl_ipc${wlc_std} "
1158simandl echo -n "${wlc_mac}$wl_mac${wlc_std} ${wlc_sig}$wl_cnt${wlc_std} "
1167simandl #echo -n $wl_macparam | awk '{print $1,$2" "}'
1175simandl w_bar
118 fi
1194simandl done
1202simandl 
121 echo
122} # w_master
123 
124######################################################################
125w_iface()
1269simandl{ wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/g'`
1277simandl wl_mode=`echo $wl_iwctxt | awk '{print $5}' | sed 's/Mode://g'`
1282simandl if [ "a$wl_mode" = "aManaged" ]
129 then
130 w_managed
1318simandl elif [ "a$wl_mode" = "aAd-Hoc" ]
132 then
133 w_managed
1342simandl elif [ "a$wl_mode" = "aMaster" ]
135 then
136 w_master
137 else
138 echo $wl_iface $wlm_no_managed_or_master
139 echo
140 fi
141}
142 
143######################################################################
1449simandlw_version()
145{
146 echo wifimon $wl_version
147 exit 0
148}
149######################################################################
1505simandlw_help()
151{
1523simandl echo Pouziti: wifimon [param]
153 echo param:
1549simandl echo -v vypise verzi
1555simandl echo -html generovani html stranky
1567simandl echo -col barevny cyklicky vypis na obrazovku
1575simandl echo -once vypsani jen jednoho vypisu a pak program skonci
158 echo -oneline vypsani klientu na jednu linku
159 echo -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
1603simandl echo bez parametru cyklicky vypis na obrazovku
1615simandl exit 0
162}
163######################################################################
164######################################################################
1652simandl 
1665simandlwl_unknown=""
167wl_cnt=1
168wcm_clear=1
169wcm_once=0
170wcm_col=0
171wcm_oneline=0
172wcm_html=0
173wcm_ifc=""
174 
1756simandl# parsing input parameters
1765simandlwhile [ "a$1" != "a" ]
177do
178 case $1 in
1799simandl -v)
180 w_version
181 ;;
1825simandl -help)
183 w_help
184 ;;
185 -once)
186 wcm_once=1
187 shift
188 ;;
189 -oneline)
190 wcm_oneline=1
191 shift
192 ;;
193 -col)
194 wcm_col=1
195 shift
196 ;;
197 -html)
198 wcm_html=1
199 shift
200 ;;
201 *)
202 wl_flg=0
203 for wl_iface in `ls $wl_hostap`
204 do
205 if [ "a-$wl_iface" = "a$1" ]
206 then
207 wcm_ifc="$wcm_ifc $wl_iface"
208 wl_flg=1
209 fi
210 done
211 if [ $wl_flg -eq 0 ]
212 then
213 wl_unknown="$wl_unknown$1 "
214 fi
215 shift
216 esac
217done
218 
2196simandl# printing the list of bad parameters (if there are some)
2205simandlif [ "a$wl_unknown" != "a" ]
221then
222 echo "$wlm_unknown $wl_unknown"
223 w_help
224fi
225 
2266simandl# if no interface is selected then all available are choosen
2275simandlif [ "a$wcm_ifc" = "a" ]
228then
229 wcm_ifc=`ls $wl_hostap`
230fi
231 
2326simandl# setting for old and last same value to avoid double clear after start
233wl_numcllast=0
234wl_numclold=0
235for wl_iface in $wcm_ifc
236do
237 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
238 wl_numcllast=$(($wl_numcllast + $wl_numcl))
239done
240wl_numclold=$wl_numcllast
241 
242if [ $wcm_col -eq 0 ]
243then
244 w_bw
245fi
246 
247while [ 1 ]
2485simandl do
249 if [ $wl_numcllast -ne $wl_numclold ]
250 then
251 wl_numclold=$wl_numcllast
252 wcm_clear=1
253 fi
2549simandl if [ $wcm_clear -eq 1 -a $wcm_html -ne 1 ]
2555simandl then
2567simandl clear
2579simandl echo ahoj
2585simandl wcm_clear=0
259 fi
260 wl_numcllast=0
2617simandl if [ $wcm_html -eq 1 ]
2625simandl then
2637simandl w_bw
264 echo $wl_header
265 for wl_iface in $wcm_ifc
266 do
267 w_iface
268 done
269 echo $wl_footer
270 else
271 tput cup 0 0
272 for wl_iface in $wcm_ifc
273 do
274 w_iface
275 done
2765simandl fi
277 
278 if [ $wcm_once -eq 1 ]
279 then
280 exit 0
281 fi
282 sleep 1
2836simandldone
2845simandl 
285exit 0
286 

Powered by WebSVN 2.2.1