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