![]() ![]() |
wifimon |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/bin/bash# authors : Petr Simandl www.simandl.cz# : Fyzik# release date : 6/1/2003# name : wifimon# version : 0.2 beta 2# description : hostap powered wifi card monitoring# license : GPLwl_iwccmd="/usr/local/sbin/iwconfig"wl_ifccmd="/sbin/ifconfig"wl_hnmcmd="/bin/hostname"wl_hostap="/proc/net/hostap/"wl_wireless="/proc/net/wireless"wl_arp="/proc/net/arp"wlc_red=`tput setaf 1`wlc_green=`tput setaf 2`wlc_brown=`tput setaf 3`wlc_blue=`tput setaf 4`wlc_magenta=`tput setaf 5`wlc_lblue=`tput setaf 6`wlc_grey=`tput setaf 7`wlc_std=`tput sgr0`wlc_ip=$wlc_lblue # ip address colorwlc_mac=$wlc_magenta # mac address colorwlc_sig=$wlc_red # signal number colorwlc_bar=$wlc_green # signal bar colorwl_webpage="/tmp/wifimon.htm"wl_header="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"wl_header_static="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"wl_footer="</pre></body></html>"wlm_no_managed_or_master=" neni ani Master ani Managed..."wlm_number_of_clients="Pocet asociovanych klientu : "#wlm_no_managed_or_master=" is not Master or Managed..."#wlm_number_of_clients="Number of associated clients : "######################################################################w_bw(){wlc_ip=$wlc_stdwlc_mac=$wlc_stdwlc_sig=$wlc_stdwlc_bar=$wlc_std}######################################################################w_bar(){echo -n "${wlc_bar}"until [ "$wl_cnt" -eq -1 ]doprintf "="wl_cnt=$(($wl_cnt - 1 ))doneprintf " \n"tput sgr0} # w_bar######################################################################w_managed(){ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'echo -n `$wl_ifccmd $wl_iface | grep -E "inet addr|inet adr" | awk '{print $2" "}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfigecho $wl_iwctxt | awk '{print $9,$6,$11" "}'#echo $wl_iwctxt | awk '{print $27,$28,$29,$31,$32" "}'#cat $wl_wireless | grep $wl_ifacewl_wtxt=`cat $wl_wireless | grep $wl_iface | awk '{print $3,$4,$5}' | sed 's/\.//g'`wl_quality=`echo $wl_wtxt | awk '{print $1}'`wl_signal=`echo $wl_wtxt | awk '{print $2}'`wl_signal=$(($wl_signal - 256))wl_noise=`echo $wl_wtxt | awk '{print $3}'`wl_noise=$(($wl_noise - 256))echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise"wl_cnt=$wl_qualityw_bar#wl_cnt=$(($wl_cnt + 100))#w_barecho} # w_managed######################################################################w_master(){ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}'echo $wl_iwctxt | awk '{print $6,$9,$11" "}'wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`echo $wlm_number_of_clients $wl_numclfor wl_mac in `ls $wl_hostap$wl_iface | grep 00 `dowl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx'`wl_cnt=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'`wl_umac=`echo $wl_mac | tr abcdef ABCDEF`wl_ipc=`cat $wl_arp | grep $wl_umac | awk '{print $1}'` # IP adresa peeru z arp tabulkyecho -n "${wlc_ip}$wl_ipc${wlc_std} "echo -n "${wlc_mac}$wl_umac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} "echo $wl_macparam | awk '{print $1,$2" "}'w_bardoneecho} # w_master######################################################################w_iface(){ wl_iwctxt=`$wl_iwccmd $wl_iface | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/g'`wl_mode=`echo $wl_iwctxt | awk '{print $5}' | sed 's/Mode://g'`if [ "a$wl_mode" = "aManaged" ]thenw_managedelif [ "a$wl_mode" = "aMaster" ]thenw_masterelseecho $wl_iface $wlm_no_managed_or_masterechofi}############################################################################################################################################case $1 in-help)echo Pouziti: wifimon [param]echo param:echo -htm cyklicke generovani stranky s 1s obnonovanimecho -htm1 jedna staticka strankaecho -col barevny cyklicky vypis na obrazovkuecho bez parametru cyklicky vypis na obrazovku;;-htm1);;-htm1)echo bez parametru cyklicky vypis na obrazovku;;-htm1)w_bwecho $wl_header_static > $wl_webpagefor wl_iface in `ls $wl_hostap`dow_iface >> $wl_webpagedoneecho $wl_footer >> $wl_webpage;;-htm)w_bwwhile [ 1 ]doecho $wl_header > $wl_webpage.tmpfor wl_iface in `ls $wl_hostap`dow_iface >> $wl_webpage.tmpdoneecho $wl_footer >> $wl_webpage.tmpcp $wl_webpage.tmp $wl_webpagesleep 1done;;-col)clearwhile [ 1 ]dotput cup 0 0for wl_iface in `ls $wl_hostap`dow_ifacedonesleep 1done;;*)w_bwclearwhile [ 1 ]dotput cup 0 0for wl_iface in `ls $wl_hostap`dow_ifacedonesleep 1doneesacexit 0