wifimon |
Subversion Repositories: |
Rev 20 | Rev 21 | |
---|---|---|
Line 2... | Line 2... | |
# authors : Petr Simandl www.simandl.cz |
# authors : Petr Simandl www.simandl.cz | |
# : Fyzik, Covex, Tydyt |
# : Fyzik, Covex, Tydyt | |
# release date : 09/09/2005 |
# release date : 11/09/2005 | |
# name : wifimon |
# name : wifimon | |
# description : hostap powered wifi card monitoring |
# description : hostap and madwifi powered card monitoring | |
# license : GPL |
# license : GPL | |
###################################################################### | ||
|
| |
wl_version="0.5.5pre1" |
wl_version="0.5.5pre5" | |
| ||
###################################################################### | ||
#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 | |
|
| |
wl_iwccmd=`which iwconfig` |
wl_iwccmd=`which iwconfig` | |
wl_iwlcmd=`which iwlist` | ||
wl_ifccmd=`which ifconfig` |
wl_ifccmd=`which ifconfig` | |
wl_hnmcmd=`which hostname` |
wl_hnmcmd=`which hostname` | |
wl_awkcmd=`which awk` |
wl_awkcmd=`which awk` | |
|
| |
wl_tptcmde="[1;1H" |
wl_tptcmde="[1;1H" | |
Line 25... | Line 30... | |
wl_dhcpcnf="/etc/dhcpd.conf" |
wl_dhcpcnf="/etc/dhcpd.conf" | |
wl_dhcplss="/var/lib/dhcp/dhcpd.leases" |
wl_dhcplss="/var/lib/dhcp/dhcpd.leases" | |
# wl_dhcpcnf="/etc/dhcp3/dhcpd.conf" |
# wl_dhcpcnf="/etc/dhcp3/dhcpd.conf" | |
# wl_dhcplss="/var/lib/dhcp3/dhcpd.leases" |
# wl_dhcplss="/var/lib/dhcp3/dhcpd.leases" | |
|
| |
#testing all settings |
wl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><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>" | ||
| ||
wlm_no_managed_or_master=" neni ani Master ani Managed..." | ||
wlm_number_of_clients="Pocet asociovanych klientu : " | ||
wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : " | ||
#wlm_no_managed_or_master=" is not Master or Managed..." | ||
#wlm_number_of_clients="Number of associated clients : " | ||
| ||
wlch_signal="=" | ||
wlch_noise="*" | ||
| ||
###################################################################### | ||
#testing basic setings | ||
|
| |
if [ "$wl_iwccmd x" = " x" ] |
if [ "$wl_iwccmd x" = " x" ] | |
then |
then | |
echo "iwconfig not found" |
echo "iwconfig not found" | |
exit 1 | ||
fi | ||
| ||
if [ "$wl_iwlcmd x" = " x" ] | ||
then | ||
echo "iwlist not found" | ||
exit 1 |
exit 1 | |
fi |
fi | |
|
| |
if [ "$wl_ifccmd x" = " x" ] |
if [ "$wl_ifccmd x" = " x" ] | |
then |
then | |
Line 48... | Line 73... | |
fi |
fi | |
|
| |
if [ "$wl_awkcmd x" = " x" ] |
if [ "$wl_awkcmd x" = " x" ] | |
then |
then | |
echo "awk not found" |
echo "awk not found" | |
exit 1 |
||
fi |
||
|
||
if [ -d $wl_hostap ] |
||
then |
||
wl_nop=1 |
||
else |
||
echo "hostap not found" |
||
exit 1 |
exit 1 | |
fi |
fi | |
|
| |
if [ -e $wl_wireless ] |
if [ -e $wl_wireless ] | |
then |
then | |
Line 90... | Line 107... | |
wl_nop=1 |
wl_nop=1 | |
else |
else | |
echo "$wl_dhcplss not found" |
echo "$wl_dhcplss not found" | |
wl_dhcplss="/dev/null" |
wl_dhcplss="/dev/null" | |
fi |
fi | |
###################################################################### | ||
|
| |
wl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" |
if [ -d ${wl_hostap}wlan0 ] | |
wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" |
then | |
wl_footer="</pre></body></html>" |
wlf_hostap=1 | |
else | ||
# echo "${wl_hostap}wlan0 not found" | ||
wlf_hostap=0 | ||
fi | ||
|
| |
wlm_no_managed_or_master=" neni ani Master ani Managed..." |
if [ -d ${wl_sysdev}ath0 ] | |
wlm_number_of_clients="Pocet asociovanych klientu : " |
then | |
wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : " |
wlf_madwifi=1 | |
#wlm_no_managed_or_master=" is not Master or Managed..." |
else | |
#wlm_number_of_clients="Number of associated clients : " |
# echo "${wl_sysdev}ath0 not found" | |
wlf_madwifi=0 | ||
fi | ||
|
| |
wlch_signal="=" |
if [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ] | |
wlch_noise="*" |
then | |
echo "${wl_hostap}wlan0 not found" | ||
echo "${wl_sysdev}ath0 not found" | ||
exit 1 | ||
fi | ||
|
| |
###################################################################### | ||
# procedures | ||
###################################################################### |
###################################################################### | |
w_col() |
w_col() | |
{ |
{ | |
wlc_red=`tput setaf 1` # ruda (Red) |
wlc_red=`tput setaf 1` # ruda (Red) | |
wlc_green=`tput setaf 2` # zelena (Lime) |
wlc_green=`tput setaf 2` # zelena (Lime) | |
Line 286... | Line 316... | |
} # w_managed |
} # w_managed | |
|
| |
###################################################################### |
###################################################################### | |
w_master() |
w_master() | |
{ if [ $wcm_oneline -eq 0 ] |
{ if [ $wcm_oneline -eq 0 ] | |
then |
then | |
echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}' |
echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}' | |
if [ $wcm_macoff -eq 1 ] |
if [ $wcm_macoff -eq 1 ] | |
then | ||
echo $wl_iwctxt | $wl_awkcmd '{print $6,$11" "}' | ||
else | ||
echo $wl_iwctxt | $wl_awkcmd '{print $6,$9,$11" "}' | ||
fi | ||
else | ||
echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g' | ||
fi | ||
| ||
if [ -d $wl_hostap$wl_iface ] | ||
then |
then | |
echo $wl_iwctxt | $wl_awkcmd '{print $6,$11" "}' |
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` | |
else |
wl_macs=`ls $wl_hostap$wl_iface | grep 00` | |
echo $wl_iwctxt | $wl_awkcmd '{print $6,$9,$11" "}' |
||
fi |
||
else |
||
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` |
| |
if [ -d $wl_sysdev$wl_iface ] | ||
then | ||
wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00` | ||
wl_macs=`iwlist $wl_iface peers | grep 00 | awk '{print $1}'` | ||
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)) | |
|
| |
for wl_mac in `ls $wl_hostap$wl_iface | grep 00 ` |
for wl_mac in $wl_macs | |
do |
do | |
wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'` |
if [ -d $wl_hostap$wl_iface ] | |
wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal=//g'` |
then | |
wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence=//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 | $wl_awkcmd '{print $6}' | sed 's/signal=//g'` | ||
wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence=//g'` | ||
fi | ||
| ||
if [ -d $wl_sysdev$wl_iface ] | ||
then | ||
wl_macparam=`$wl_iwlcmd $wl_iface peers | grep $wl_mac` | ||
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'` | ||
fi | ||
| ||
wl_cnt=$(($wl_signal - $wl_silence)) |
wl_cnt=$(($wl_signal - $wl_silence)) | |
wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{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 | $wl_awkcmd '{print $2}'` |
wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'` | |
if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ] |
if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ] | |
Line 320... | Line 373... | |
then |
then | |
wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'` |
wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'` | |
wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' ` |
wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' ` | |
fi |
fi | |
fi |
fi | |
if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] |
if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] && [ -d $wl_hostap$wl_iface ] | |
then |
then | |
w_pkts |
w_pkts | |
fi |
fi | |
|
| |
if [ $wcm_oneline -eq 0 ] |
if [ $wcm_oneline -eq 0 ] | |
Line 343... | Line 396... | |
echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} " |
echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} " | |
if [ $wcm_rxtx -eq 0 ] |
if [ $wcm_rxtx -eq 0 ] | |
then |
then | |
echo "" |
echo "" | |
else |
else | |
echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}' |
if [ -d $wl_hostap$wl_iface ] | |
then | ||
echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}' | ||
else | ||
echo "" | ||
fi | ||
fi |
fi | |
w_bar |
w_bar | |
else |
else | |
if [ $wcm_macoff -eq 0 ] |
if [ $wcm_macoff -eq 0 ] | |
then |
then | |
Line 388... | Line 446... | |
exit 0 |
exit 0 | |
} |
} | |
###################################################################### |
###################################################################### | |
w_help() |
w_help() | |
{ |
{ | |
echo Monitorovani wifi karet pouzivajicich hostap nebo madwifi ovladace | ||
echo Pouziti: wifimon [param] |
echo Pouziti: wifimon [param] | |
echo param: |
echo param: | |
echo -v vypise verzi |
echo -v vypise verzi | |
echo -html generovani html stranky |
echo -html generovani html stranky | |
echo -col barevny vypis na obrazovku |
echo -col barevny vypis na obrazovku | |
echo -once vypsani jen jednoho vypisu a pak program skonci |
echo -once vypsani jen jednoho vypisu a pak program skonci | |
echo -oneline vypsani klientu na jednu linku |
echo -oneline vypsani klientu na jednu linku | |
echo -threeline vypsani klienta na trech radcich |
echo -threeline vypsani klienta na trech radcich | |
echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta |
||
echo -macoff vypnuti zobrazeni MAC adres |
echo -macoff vypnuti zobrazeni MAC adres | |
echo -wlan0 -ath0 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi | ||
echo nasledujici parametry ovlivnuji jen karty s hostap: | ||
echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta | ||
echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty |
echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty | |
echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty |
echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty | |
echo -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi |
||
echo bez parametru cyklicky vypis na obrazovku |
echo bez parametru cyklicky vypis na obrazovku | |
exit 0 |
exit 0 | |
} |
} | |
###################################################################### |
###################################################################### | |
###################################################################### |
###################################################################### | |
Line 470... | Line 530... | |
shift |
shift | |
;; |
;; | |
*) |
*) | |
wl_flg=0 |
wl_flg=0 | |
#wlan check |
#wlan check | |
for wl_iface in `ls $wl_hostap` |
if [ $wlf_hostap -eq 1 ] | |
do |
||
if [ "a-$wl_iface" = "a$1" ] |
||
then |
then | |
wcm_ifc="$wcm_ifc $wl_iface" |
for wl_iface in `ls $wl_hostap` | |
wl_flg=1 |
do | |
fi |
if [ "a-$wl_iface" = "a$1" ] | |
done |
then | |
wcm_ifc="$wcm_ifc $wl_iface" | ||
wl_flg=1 | ||
fi | ||
done | ||
fi | ||
# ath check |
# ath check | |
for wl_iface in `ls $wl_sysdev | grep "ath[0..9]"` |
if [ $wlf_madwifi -eq 1 ] | |
do |
||
if [ "a-$wl_iface" = "a$1" ] |
||
then |
then | |
wcm_ifc="$wcm_ifc $wl_iface" |
for wl_iface in `ls $wl_sysdev | grep "ath[0-9]"` | |
wl_flg=1 |
do | |
fi |
if [ "a-$wl_iface" = "a$1" ] | |
done |
then | |
wcm_ifc="$wcm_ifc $wl_iface" | ||
wl_flg=1 | ||
fi | ||
done | ||
fi | ||
if [ $wl_flg -eq 0 ] |
if [ $wl_flg -eq 0 ] | |
then |
then | |
wl_unknown="$wl_unknown$1 " |
wl_unknown="$wl_unknown$1 " | |
fi |
fi | |
shift |
shift | |
esac |
esac | |
done |
done | |
|
| |
Line 501... | Line 567... | |
if [ "a$wl_unknown" != "a" ] |
if [ "a$wl_unknown" != "a" ] | |
then |
then | |
echo "$wlm_unknown $wl_unknown" |
echo "$wlm_unknown $wl_unknown" | |
w_help |
w_help | |
fi |
fi | |
|
||
# if no interface is selected then all available are choosen |
# if no interface is selected then all available are choosen | |
if [ "a$wcm_ifc" = "a" ] |
if [ "a$wcm_ifc" = "a" ] | |
then |
then | |
wcm_ifc=`ls $wl_hostap ; ls $wl_sysdev | grep "ath[0..9]"` |
if [ $wlf_hostap -eq 1 ] | |
then | ||
wcm_ifc=`ls $wl_hostap ` | ||
fi | ||
if [ $wlf_madwifi -eq 1 ] | ||
then | ||
wcm_ifc=`echo $wcm_ifc ; ls $wl_sysdev | grep "ath[0-9]"` | ||
fi | ||
fi |
fi | |
|
| |
# 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 | |
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` |
if [ -d $wl_hostap$wl_iface ] | |
wl_numcllast=$(($wl_numcllast + $wl_numcl)) |
then | |
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` | ||
wl_numcllast=$(($wl_numcllast + $wl_numcl)) | ||
fi | ||
if [ -d $wl_sysdev$wl_iface ] | ||
then | ||
wl_mode=`$wl_iwccmd $wl_iface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'` | ||
if [ "a$wl_mode" = "aMaster" ] | ||
then | ||
wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00` | ||
wl_numcllast=$(($wl_numcllast + $wl_numcl)) | ||
fi | ||
fi | ||
done |
done | |
wl_numclold=$wl_numcllast |
wl_numclold=$wl_numcllast | |
|
| |
if [ $wcm_col -eq 0 ] |
if [ $wcm_col -eq 0 ] | |
then |
then |