jablonka.czprosek.czf

wifimon

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

 

Line No. Rev Author Line
12simandl#!/bin/bash
23simandl# authors : Petr Simandl www.simandl.cz
34simandl# : Fyzik
4# release date : 6/1/2003
52simandl# name : wifimon
64simandl# version : 0.2 beta 2
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"
32wl_header="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
33wl_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 : "
38#wlm_no_managed_or_master=" is not Master or Managed..."
39#wlm_number_of_clients="Number of associated clients : "
404simandl 
412simandl######################################################################
424simandlw_bw()
43{
44 wlc_ip=$wlc_std
45 wlc_mac=$wlc_std
46 wlc_sig=$wlc_std
47 wlc_bar=$wlc_std
48}
49######################################################################
502simandlw_bar()
51{
524simandl echo -n "${wlc_bar}"
532simandl until [ "$wl_cnt" -eq -1 ]
54 do
55 printf "="
56 wl_cnt=$(($wl_cnt - 1 ))
57 done
58 printf " \n"
594simandl tput sgr0
602simandl} # w_bar
61 
62######################################################################
63w_managed()
64{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'
653simandl 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
66 echo $wl_iwctxt | awk '{print $9,$6,$11" "}'
672simandl #echo $wl_iwctxt | awk '{print $27,$28,$29,$31,$32" "}'
68 #cat $wl_wireless | grep $wl_iface
69 wl_wtxt=`cat $wl_wireless | grep $wl_iface | awk '{print $3,$4,$5}' | sed 's/\.//g'`
70 wl_quality=`echo $wl_wtxt | awk '{print $1}'`
71 wl_signal=`echo $wl_wtxt | awk '{print $2}'`
72 wl_signal=$(($wl_signal - 256))
73 wl_noise=`echo $wl_wtxt | awk '{print $3}'`
74 wl_noise=$(($wl_noise - 256))
754simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise"
762simandl wl_cnt=$wl_quality
77 w_bar
78 #wl_cnt=$(($wl_cnt + 100))
79 #w_bar
80 echo
81} # w_managed
82 
83######################################################################
84w_master()
85{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'
86 echo $wl_iwctxt | awk '{print $6,$9,$11" "}'
87 
88 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
89 echo $wlm_number_of_clients $wl_numcl
903simandl for wl_mac in `ls $wl_hostap$wl_iface | grep 00 `
912simandl do
92 wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx'`
93 wl_cnt=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'`
943simandl wl_umac=`echo $wl_mac | tr abcdef ABCDEF`
95 wl_ipc=`cat $wl_arp | grep $wl_umac | awk '{print $1}'` # IP adresa peeru z arp tabulky
964simandl echo -n "${wlc_ip}$wl_ipc${wlc_std} "
97 echo -n "${wlc_mac}$wl_umac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} "
98 echo $wl_macparam | awk '{print $1,$2" "}'
992simandl w_bar
1004simandl done
1012simandl 
102 echo
103} # w_master
104 
105######################################################################
106w_iface()
107{ wl_iwctxt=`$wl_iwccmd $wl_iface | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/g'`
108 wl_mode=`echo $wl_iwctxt | awk '{print $5}' | sed 's/Mode://g'`
109 if [ "a$wl_mode" = "aManaged" ]
110 then
111 w_managed
112 elif [ "a$wl_mode" = "aMaster" ]
113 then
114 w_master
115 else
116 echo $wl_iface $wlm_no_managed_or_master
117 echo
118 fi
119}
120 
121######################################################################
122######################################################################
123 
1243simandlcase $1 in
125-help)
126 echo Pouziti: wifimon [param]
127 echo param:
128 echo -htm cyklicke generovani stranky s 1s obnonovanim
129 echo -htm1 jedna staticka stranka
1304simandl echo -col barevny cyklicky vypis na obrazovku
1313simandl echo bez parametru cyklicky vypis na obrazovku
1322simandl 
1333simandl;;
134-htm1)
1354simandl 
136;;
137-htm1)
138 echo bez parametru cyklicky vypis na obrazovku
139 
140;;
141-htm1)
142 w_bw
1433simandl echo $wl_header_static > $wl_webpage
144 for wl_iface in `ls $wl_hostap`
145 do
146 w_iface >> $wl_webpage
147 done
148 echo $wl_footer >> $wl_webpage
149;;
150-htm)
1514simandl w_bw
1523simandl while [ 1 ]
153 do
154 echo $wl_header > $wl_webpage.tmp
155 for wl_iface in `ls $wl_hostap`
156 do
157 w_iface >> $wl_webpage.tmp
158 done
159 echo $wl_footer >> $wl_webpage.tmp
160 cp $wl_webpage.tmp $wl_webpage
161 sleep 1
1622simandl done
1633simandl;;
1644simandl-col)
165 clear
166 while [ 1 ]
167 do
168 tput cup 0 0
169 for wl_iface in `ls $wl_hostap`
170 do
171 w_iface
172 done
173 sleep 1
174 done
175;;
1763simandl*)
1774simandl w_bw
1783simandl clear
179 while [ 1 ]
180 do
181 tput cup 0 0
182 for wl_iface in `ls $wl_hostap`
183 do
184 w_iface
185 done
186 sleep 1
187 done
188esac
1892simandl 
190exit 0
191 
192 

Powered by WebSVN 2.2.1