jablonka.czprosek.czf

wifimon

Subversion Repositories:
[/] [trunk/] [wifimon] - Diff between revs 22 and 23

Show entire file Ignore whitespace

Rev 22 Rev 23
Line 5... Line 5...
# name : wifimon # name : wifimon
# description : hostap and madwifi powered card monitoring # description : hostap and madwifi powered card monitoring
# license : GPL # license : GPL
###################################################################### ######################################################################
   
wl_version="0.5.6" wl_version="0.5.6" #+ifrename support
   
###################################################################### ######################################################################
#custom settings #custom settings
   
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
Line 42... Line 42...
#wlm_no_managed_or_master=" is not Master or Managed..." #wlm_no_managed_or_master=" is not Master or Managed..."
#wlm_number_of_clients="Number of associated clients : " #wlm_number_of_clients="Number of associated clients : "
   
wlch_signal="=" wlch_signal="="
wlch_noise="*" wlch_noise="*"
   
  w_realiface()
  {
  wl_realiface="$wl_iface"
   
  # ifrename support: this must be set regarding to /etc/iftab
  #if [ "$wl_iface" = "ath0" ]; then
  # wl_realiface="wlan0"
  #fi
  #if [ "$wl_iface" = "wlan0" ]; then
  # wl_realiface="wlan1"
  #fi
  }
   
###################################################################### ######################################################################
#testing basic setings #testing basic setings
   
if [ "$wl_iwccmd x" = " x" ] if [ "$wl_iwccmd x" = " x" ]
Line 120... Line 133...
echo "$wl_dhcplss not found" echo "$wl_dhcplss not found"
wl_dhcplss="/dev/null" wl_dhcplss="/dev/null"
fi fi
###################################################################### ######################################################################
   
if [ -d ${wl_hostap}wlan0 ] if [ -d ${wl_hostap} ]
then then
wlf_hostap=1 wlf_hostap=1
else else
# echo "${wl_hostap}wlan0 not found" # echo "${wl_hostap}wlan0 not found"
wlf_hostap=0 wlf_hostap=0
fi fi
   
if [ -d ${wl_sysdev}ath0 ] if [ -d ${wl_sysdev}ath ]
then then
wlf_madwifi=1 wlf_madwifi=1
else else
# echo "${wl_sysdev}ath0 not found" # echo "${wl_sysdev}ath0 not found"
wlf_madwifi=0 wlf_madwifi=0
fi fi
   
if [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ] if [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ]
then then
echo "${wl_hostap}wlan0 not found" echo "${wl_hostap} not found"
echo "${wl_sysdev}ath0 not found" echo "${wl_sysdev}ath not found"
exit 1 exit 1
fi fi
   
###################################################################### ######################################################################
# procedures # procedures
Line 303... Line 316...
   
} # w_pkts } # w_pkts
###################################################################### ######################################################################
w_managed() w_managed()
{ echo $wl_iwctxt | $wl_awkcmd '{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" | $wl_awkcmd '{print $2}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfig echo -n `$wl_ifccmd $wl_realiface | grep -E "inet addr|inet adr" | $wl_awkcmd '{print $2}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfig
   
if [ $wcm_macoff -eq 0 ] if [ $wcm_macoff -eq 0 ]
then then
wl_mac=`echo -n $wl_iwctxt | $wl_awkcmd '{print $8}'` wl_mac=`echo -n $wl_iwctxt | $wl_awkcmd '{print $8}'`
echo -n "${wlc_mac}$wl_mac${wlc_std} " echo -n "${wlc_mac}$wl_mac${wlc_std} "
fi fi
echo $wl_iwctxt | $wl_awkcmd '{print $6,$10,$11,$12" "}' echo $wl_iwctxt | $wl_awkcmd '{print $6,$10,$11,$12" "}'
   
wl_wtxt=`cat $wl_wireless | grep $wl_iface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'` wl_wtxt=`cat $wl_wireless | grep $wl_realiface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'`
wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'` wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'`
wl_signal=`echo $wl_wtxt | $wl_awkcmd '{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 | $wl_awkcmd '{print $3}'` wl_noise=`echo $wl_wtxt | $wl_awkcmd '{print $3}'`
wl_noise=$(($wl_noise - 256)) wl_noise=$(($wl_noise - 256))
Line 347... Line 360...
wl_macs=`ls $wl_hostap$wl_iface | grep 00` wl_macs=`ls $wl_hostap$wl_iface | grep 00`
fi fi
   
if [ -d $wl_sysdev$wl_iface ] if [ -d $wl_sysdev$wl_iface ]
then then
wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00` wl_numcl=`$wl_iwlcmd $wl_realiface peers | grep -c 00`
wl_macs=`iwlist $wl_iface peers | grep 00 | awk '{print $1}'` wl_macs=`iwlist $wl_realiface peers | grep 00 | awk '{print $1}'`
fi fi
   
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))
Line 366... Line 379...
wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence[=|:]//g'` wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence[=|:]//g'`
fi fi
   
if [ -d $wl_sysdev$wl_iface ] if [ -d $wl_sysdev$wl_iface ]
then then
wl_macparam=`$wl_iwlcmd $wl_iface peers | grep $wl_mac` wl_macparam=`$wl_iwlcmd $wl_realiface peers | grep $wl_mac`
wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $5}' | sed 's/level[=|:]//g'` wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $5}' | sed 's/level[=|:]//g'`
wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $8}' | sed 's/level[=|:]//g'` wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $8}' | sed 's/level[=|:]//g'`
fi fi
   
wl_cnt=$(($wl_signal - $wl_silence)) wl_cnt=$(($wl_signal - $wl_silence))
Line 431... Line 444...
echo echo
} # w_master } # w_master
   
###################################################################### ######################################################################
w_iface() w_iface()
{ wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ dBm/dBm/' | sed 's/ GHz/GHz/' | sed 's/ Mb/Mb/' | sed 's/ Nick/_Nick/' | sed 's/Access Point/Access_Point/'` { wl_iwctxt=`$wl_iwccmd $wl_realiface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ dBm/dBm/' | sed 's/ GHz/GHz/' | sed 's/ Mb/Mb/' | sed 's/ Nick/_Nick/' | sed 's/Access Point/Access_Point/'`
wl_mode=`echo $wl_iwctxt | $wl_awkcmd '{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" ]
Line 443... Line 456...
w_managed w_managed
elif [ "a$wl_mode" = "aMaster" ] elif [ "a$wl_mode" = "aMaster" ]
then then
w_master w_master
else else
echo $wl_iface $wlm_no_managed_or_master echo $wl_realiface $wlm_no_managed_or_master
echo echo
fi fi
} }
   
###################################################################### ######################################################################
Line 482... Line 495...
   
wl_unknown="" wl_unknown=""
wl_cnt=1 wl_cnt=1
wcm_clear=1 wcm_clear=1
wcm_once=0 wcm_once=0
wcm_col=0 wcm_col=1
wcm_oneline=0 wcm_oneline=0
wcm_threeline=0 wcm_threeline=0
wcm_html=0 wcm_html=0
wcm_rxtx=1 wcm_rxtx=1
wcm_ppkts=0 wcm_ppkts=0
wcm_pkts=0 wcm_pkts=0
wcm_ifc="" wcm_ifc=""
  wcm_realifc=""
wcm_macoff=0 wcm_macoff=0
   
# parsing input parameters # parsing input parameters
while [ "a$1" != "a" ] while [ "a$1" != "a" ]
do do
Line 515... Line 529...
-threeline) -threeline)
wcm_threeline=1 wcm_threeline=1
shift shift
;; ;;
-col) -col)
wcm_col=1 wcm_col=0
shift shift
;; ;;
-html) -html)
wcm_html=1 wcm_html=1
shift shift
Line 545... Line 559...
#wlan check #wlan check
if [ $wlf_hostap -eq 1 ] if [ $wlf_hostap -eq 1 ]
then then
for wl_iface in `ls $wl_hostap` for wl_iface in `ls $wl_hostap`
do do
if [ "a-$wl_iface" = "a$1" ] w_realiface
  if [ "a-$wl_realiface" = "a$1" ]
then then
wcm_ifc="$wcm_ifc $wl_iface" wcm_ifc="$wcm_ifc $wl_iface"
wl_flg=1 wl_flg=1
fi fi
done done
Line 557... Line 572...
# ath check # ath check
if [ $wlf_madwifi -eq 1 ] if [ $wlf_madwifi -eq 1 ]
then then
for wl_iface in `ls $wl_sysdev | grep "ath[0-9]"` for wl_iface in `ls $wl_sysdev | grep "ath[0-9]"`
do do
if [ "a-$wl_iface" = "a$1" ] w_realiface
  if [ "a-$wl_realiface" = "a$1" ]
then then
wcm_ifc="$wcm_ifc $wl_iface" wcm_ifc="$wcm_ifc $wl_iface"
wl_flg=1 wl_flg=1
fi fi
done done
Line 590... Line 606...
if [ $wlf_madwifi -eq 1 ] if [ $wlf_madwifi -eq 1 ]
then then
wcm_ifc=`echo $wcm_ifc ; ls $wl_sysdev | grep "ath[0-9]"` wcm_ifc=`echo $wcm_ifc ; ls $wl_sysdev | grep "ath[0-9]"`
fi fi
fi fi
   
  # sort ifaces by name - if you want to do it smarter, just go ahead :)
  for wl_iface in $wcm_ifc
  do
  w_realiface
  wcm_realifc="$wcm_realifc $wl_realiface"
  done
   
  wcm_realifc="`echo $wcm_realifc | fmt -1 -s | sort -t' '`"
  for wl_realifc in $wcm_realifc
  do
  for wl_iface in $wcm_ifc
  do
  w_realiface
  if [ "a$wl_realiface" = "a$wl_realifc" ]
  then
  wcm_ifc_sorted="$wcm_ifc_sorted $wl_iface"
  fi
  done
  done
  wcm_ifc="$wcm_ifc_sorted"
   
# setting for old and last same value to avoid double clear after start # setting for old and last same value to avoid double clear after start
wl_numcllast=0 wl_numcllast=0
wl_numclold=0 wl_numclold=0
for wl_iface in $wcm_ifc for wl_iface in $wcm_ifc
do do
  w_realiface
if [ -d $wl_hostap$wl_iface ] if [ -d $wl_hostap$wl_iface ]
then then
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
wl_numcllast=$(($wl_numcllast + $wl_numcl)) wl_numcllast=$(($wl_numcllast + $wl_numcl))
fi fi
if [ -d $wl_sysdev$wl_iface ] if [ -d $wl_sysdev$wl_iface ]
then then
wl_mode=`$wl_iwccmd $wl_iface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'` wl_mode=`$wl_iwccmd $wl_realiface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'`
if [ "a$wl_mode" = "aMaster" ] if [ "a$wl_mode" = "aMaster" ]
then then
wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00` wl_numcl=`$wl_iwlcmd $wl_realiface peers | grep -c 00`
wl_numcllast=$(($wl_numcllast + $wl_numcl)) wl_numcllast=$(($wl_numcllast + $wl_numcl))
fi fi
fi fi
done done
wl_numclold=$wl_numcllast wl_numclold=$wl_numcllast
Line 630... Line 668...
if [ $wcm_html -eq 1 ] if [ $wcm_html -eq 1 ]
then then
[ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh [ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh
for wl_iface in $wcm_ifc for wl_iface in $wcm_ifc
do do
  w_realiface
w_iface w_iface
done done
echo $wl_footer echo $wl_footer
exit 0 exit 0
fi fi
Line 664... Line 703...
fi fi
   
#make report for all desired interfaces #make report for all desired interfaces
for wl_iface in $wcm_ifc for wl_iface in $wcm_ifc
do do
  w_realiface
w_iface w_iface
done done
   
#when a single report is needed than we are exiting #when a single report is needed than we are exiting
if [ $wcm_once -eq 1 ] if [ $wcm_once -eq 1 ]

Powered by WebSVN 2.2.1