jablonka.czprosek.czf

wifimon

Subversion Repositories:
[/] [trunk/] [wifimon] - Diff between revs 13 and 14

Show entire file Ignore whitespace

Rev 13 Rev 14
Line 1... Line 1...
#!/bin/bash #!/bin/bash
# authors : Petr Simandl www.simandl.cz # authors : Petr Simandl www.simandl.cz
# : Fyzik, Covex # : Fyzik, Covex, Tydyt
# release date : 14/8/2003 # release date : 05/10/2003
# name : wifimon # name : wifimon
# description : hostap powered wifi card monitoring # description : hostap powered wifi card monitoring
# license : GPL # license : GPL
   
wl_version="0.4beta8" wl_version="0.5.0"
   
PATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin PATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin
   
wl_iwccmd=`/usr/bin/which iwconfig` wl_iwccmd=`which iwconfig`
  wl_ifccmd=`which ifconfig`
  wl_hnmcmd=`which hostname`
  wl_awkcmd=`which awk`
   
  wl_tptcmde=""
  wl_clrcmde=""
   
  wl_hostap="/proc/net/hostap/"
  wl_wireless="/proc/net/wireless"
  wl_arp="/proc/net/arp"
  wl_dhcpcnf="/etc/dhcpd.conf"
  wl_dhcplss="/var/lib/dhcp/dhcpd.leases"
   
  #testing all settings
   
if [ "$wl_iwccmd x" = " x" ] if [ "$wl_iwccmd x" = " x" ]
then then
echo "iwconfig not found" echo "iwconfig not found"
exit 1 exit 1
fi fi
wl_ifccmd="/sbin/ifconfig"  
wl_hnmcmd="/bin/hostname"  
wl_hostap="/proc/net/hostap/"  
wl_wireless="/proc/net/wireless"  
wl_arp="/proc/net/arp"  
wl_dhcpcnf="/etc/dhcpd.conf"  
   
  if [ "$wl_ifccmd x" = " x" ]
  then
  echo "ifconfig not found"
  exit 1
  fi
   
  if [ "$wl_hnmcmd x" = " x" ]
  then
  echo "hostname not found"
  exit 1
  fi
   
  if [ "$wl_awkcmd x" = " x" ]
  then
  echo "awk not found"
  exit 1
  fi
   
  if [ -d $wl_hostap ]
  then
  wl_nop=1
  else
  echo "hostap not found"
  exit 1
  fi
   
  if [ -e $wl_wireless ]
  then
  wl_nop=1
  else
  echo "$wl_wireless not found"
  exit 1
  fi
   
  if [ -e $wl_arp ]
  then
  wl_nop=1
  else
  echo "$wl_arp not found"
  exit 1
  fi
   
  if [ -e $wl_dhcpcnf ]
  then
  wl_nop=1
  else
  echo "$wl_dhcpcnf not found"
  wl_dhcpcnf="/dev/null"
  fi
   
  if [ -e $wl_dhcplss ]
  then
  wl_nop=1
  else
  echo "$wl_dhcplss not found"
  wl_dhcplss="/dev/null"
  fi
   
wl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" wl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
wl_footer="</pre></body></html>" wl_footer="</pre></body></html>"
   
Line 87... Line 153...
   
###################################################################### ######################################################################
w_pkts() w_pkts()
{ {
wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'` wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'`
wl_nt1=`echo $wl_macpkts | awk '{print $2}'` wl_nt1=`echo $wl_macpkts | $wl_awkcmd '{print $2}'`
wl_nt2=`echo $wl_macpkts | awk '{print $4}'` wl_nt2=`echo $wl_macpkts | $wl_awkcmd '{print $4}'`
wl_nt5=`echo $wl_macpkts | awk '{print $6}'` wl_nt5=`echo $wl_macpkts | $wl_awkcmd '{print $6}'`
wl_nt11=`echo $wl_macpkts | awk '{print $8}'` wl_nt11=`echo $wl_macpkts | $wl_awkcmd '{print $8}'`
wl_nr1=`echo $wl_macpkts | awk '{print $10}'` wl_nr1=`echo $wl_macpkts | $wl_awkcmd '{print $10}'`
wl_nr2=`echo $wl_macpkts | awk '{print $12}'` wl_nr2=`echo $wl_macpkts | $wl_awkcmd '{print $12}'`
wl_nr5=`echo $wl_macpkts | awk '{print $14}'` wl_nr5=`echo $wl_macpkts | $wl_awkcmd '{print $14}'`
wl_nr11=`echo $wl_macpkts | awk '{print $16}'` wl_nr11=`echo $wl_macpkts | $wl_awkcmd '{print $16}'`
   
if [ $wcm_ppkts -eq 1 ] if [ $wcm_ppkts -eq 1 ]
then then
wl_pksize=$((98)) wl_pksize=$((98))
wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11)) wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11))
Line 165... Line 231...
[ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 "" [ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 ""
   
} # w_pkts } # w_pkts
###################################################################### ######################################################################
w_managed() w_managed()
{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}' { echo $wl_iwctxt | $wl_awkcmd '{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 ifconfig 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
echo $wl_iwctxt | awk '{print $9,$6,$11" "}' echo $wl_iwctxt | $wl_awkcmd '{print $9,$6,$11" "}'
wl_wtxt=`cat $wl_wireless | grep $wl_iface | awk '{print $3,$4,$5}' | sed 's/\.//g'` wl_wtxt=`cat $wl_wireless | grep $wl_iface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'`
wl_quality=`echo $wl_wtxt | awk '{print $1}'` wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'`
wl_signal=`echo $wl_wtxt | awk '{print $2}'` wl_signal=`echo $wl_wtxt | $wl_awkcmd '{print $2}'`
wl_signal=$(($wl_signal - 256)) wl_signal=$(($wl_signal - 256))
wl_noise=`echo $wl_wtxt | awk '{print $3}'` wl_noise=`echo $wl_wtxt | $wl_awkcmd '{print $3}'`
wl_noise=$(($wl_noise - 256)) wl_noise=$(($wl_noise - 256))
echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise " echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
wl_cnt=$wl_quality wl_cnt=$wl_quality
w_bar w_bar
echo echo
Line 184... Line 250...
   
###################################################################### ######################################################################
w_master() w_master()
{ if [ $wcm_oneline -eq 0 ] { if [ $wcm_oneline -eq 0 ]
then then
echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}' echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
echo $wl_iwctxt | awk '{print $6,$9,$11" "}' echo $wl_iwctxt | $wl_awkcmd '{print $6,$9,$11" "}'
else else
echo $wl_iwctxt | awk '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g' echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g'
fi fi
   
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
echo $wlm_number_of_clients $wl_numcl echo $wlm_number_of_clients $wl_numcl
   
wl_numcllast=$(($wl_numcllast + $wl_numcl)) wl_numcllast=$(($wl_numcllast + $wl_numcl))
   
for wl_mac in `ls $wl_hostap$wl_iface | grep 00 ` for wl_mac in `ls $wl_hostap$wl_iface | grep 00 `
do do
wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'` wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'`
wl_signal=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'` wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $5}' | sed 's/signal=//g'`
wl_silence=`echo $wl_macparam | awk '{print $4}' | sed 's/silence=//g'` wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence=//g'`
wl_cnt=$(($wl_signal - $wl_silence)) wl_cnt=$(($wl_signal - $wl_silence))
wl_ipc=`cat $wl_arp | grep -i $wl_mac | awk '{print $1}'` # IP adresa peeru z arp tabulky wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky
wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | awk '{print $2}'`  
   
  wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'`
  if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ]
  then
  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}'`
  if [ "$wl_name" = "" ]
  then
  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}'`
  wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' `
  fi
  fi
if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ]
then then
w_pkts w_pkts
fi fi
   
if [ $wcm_oneline -eq 0 ] if [ $wcm_oneline -eq 0 ]
then then
echo -n "$wl_name " echo -n "$wl_name "
echo -n "${wlc_ip}$wl_ipc${wlc_std} " echo -n "${wlc_ip}$wl_ipc${wlc_std} "
echo -n "${wlc_mac}$wl_mac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} " echo -n "${wlc_mac}$wl_mac${wlc_std} Signal ${wlc_sig}$wl_cnt${wlc_std} "
echo $wl_macparam | awk '{print $1,$2" "}' echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}'
w_bar w_bar
else else
echo -n "$wl_name " echo -n "$wl_name "
echo -n "${wlc_mac}$wl_mac${wlc_std} ${wlc_sig}$wl_cnt${wlc_std} " echo -n "${wlc_mac}$wl_mac${wlc_std} ${wlc_sig}$wl_cnt${wlc_std} "
w_bar w_bar
Line 229... Line 304...
} # w_master } # w_master
   
###################################################################### ######################################################################
w_iface() w_iface()
{ wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/'` { wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/'`
wl_mode=`echo $wl_iwctxt | awk '{print $5}' | sed 's/Mode://g'` wl_mode=`echo $wl_iwctxt | $wl_awkcmd '{print $5}' | sed 's/Mode://g'`
if [ "a$wl_mode" = "aManaged" ] if [ "a$wl_mode" = "aManaged" ]
then then
w_managed w_managed
elif [ "a$wl_mode" = "aAd-Hoc" ] elif [ "a$wl_mode" = "aAd-Hoc" ]
then then
Line 375... Line 450...
done done
echo $wl_footer echo $wl_footer
exit 0 exit 0
fi fi
   
  #this is main loop and it will be executer forever
while [ 1 ] while [ 1 ]
do do
   
  # when the number of associated klients has changed we will set for clear screen
if [ $wl_numcllast -ne $wl_numclold ] if [ $wl_numcllast -ne $wl_numclold ]
then then
wl_numclold=$wl_numcllast wl_numclold=$wl_numcllast
wcm_clear=1 wcm_clear=1
fi fi
if [ $wcm_clear -eq 1 -a $wcm_html -ne 1 ]  
  #if it is set for clear screen we will do it except we produce single report
  if [ $wcm_clear -eq 1 -a $wcm_once -eq 0 ]
then then
clear echo -n $wl_clrcmde
wcm_clear=0 wcm_clear=0
fi fi
wl_numcllast=0 wl_numcllast=0
   
[ -e /usr/bin/tput ] && tput cup 0 0 || clear #for cyclic report we are trying to set cursor to the top left screen corner
  if [ $wcm_once -eq 0 ]
  then
  echo -n $wl_tptcmde
  fi
   
  #make report for all desired interfaces
for wl_iface in $wcm_ifc for wl_iface in $wcm_ifc
do do
w_iface w_iface
done done
   
  #when a single report is needed than we are exiting
if [ $wcm_once -eq 1 ] if [ $wcm_once -eq 1 ]
then then
exit 0 exit 0
fi fi
sleep 1 sleep 1

Powered by WebSVN 2.2.1