wifimon |
Subversion Repositories: |
Rev 9 | Rev 10 | |
---|---|---|
Line 1... | Line 1... | |
#!/bin/bash |
#!/bin/bash | |
# authors : Petr Simandl www.simandl.cz |
# authors : Petr Simandl www.simandl.cz | |
# : Fyzik, Covex |
# : Fyzik, Tydyt | |
# release date : 16/6/2003 |
# release date : 9/3/2003 | |
# name : wifimon |
# name : wifimon | |
# version : 0.4beta4 | ||
# description : hostap powered wifi card monitoring |
# description : hostap powered wifi card monitoring | |
# license : GPL |
# license : GPL | |
|
| |
wl_version="0.4beta4" |
# Upozorneni: pred instalaci programu doporucuji skontrolaovat nasledujici nasledujici cesty !!! | |
|
#wl_iwccmd="/usr/sbin/iwconfig" | |
wl_iwccmd="/usr/local/sbin/iwconfig" |
wl_iwccmd="/sbin/iwconfig" | |
wl_ifccmd="/sbin/ifconfig" |
wl_ifccmd="/sbin/ifconfig" | |
wl_hnmcmd="/bin/hostname" |
wl_hnmcmd="/bin/hostname" | |
wl_hostap="/proc/net/hostap/" |
wl_hostap="/proc/net/hostap/" | |
wl_wireless="/proc/net/wireless" |
wl_wireless="/proc/net/wireless" | |
wl_arp="/proc/net/arp" |
wl_arp="/proc/net/arp" | |
wl_dhcp_s="/etc/dhcpd.conf" | ||
wl_dhcp_d="/var/lib/dhcp/dhcpd.leases" | ||
|
| |
wlc_red=`tput setaf 1` |
wlc_red=`tput setaf 1` # ruda (Red) | |
wlc_green=`tput setaf 2` |
wlc_green=`tput setaf 2` # zelena (Lime) | |
wlc_brown=`tput setaf 3` |
wlc_brown=`tput setaf 3` # zluta (Yellow) | |
wlc_blue=`tput setaf 4` |
wlc_blue=`tput setaf 4` # modra (Blue) | |
wlc_magenta=`tput setaf 5` |
wlc_magenta=`tput setaf 5` # fialova (Fuchsia) | |
wlc_lblue=`tput setaf 6` |
wlc_lblue=`tput setaf 6` # svetle modra (Aqua) | |
wlc_grey=`tput setaf 7` |
wlc_grey=`tput setaf 7` # bila (White) | |
wlc_std=`tput sgr0` |
wlc_std=`tput sgr0` | |
|
| |
wlc_ip=$wlc_lblue # ip address color |
wlc_ip=$wlc_lblue # ip address color | |
wlc_mac=$wlc_magenta # mac address color |
wlc_mac=$wlc_magenta # mac address color | |
wlc_name=$wlc_brown # host name color | ||
wlc_sig=$wlc_red # signal number color |
wlc_sig=$wlc_red # signal number color | |
wlc_bar=$wlc_green # signal bar color |
wlc_bar=$wlc_green # signal bar color | |
| ||
wlh_ip="Blue" # ip address color html | ||
wlh_mac="Fuchsia" # mac address color html | ||
wlh_name="Olive" # Host name color html | ||
wlh_sig="Red" # signal number color html | ||
wlh_bar="Lime" # signal bar color html | ||
| ||
|
| |
wl_webpage="/tmp/wifimon.htm" |
wl_webpage="/tmp/wifimon.htm" | |
wl_header="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" |
wl_header="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"3\"><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>" |
wl_footer="</pre></body></html>" | |
|
| |
wlm_no_managed_or_master=" neni ani Master ani Managed..." |
wlm_no_managed_or_master=" neni ani Master ani Managed..." | |
wlm_number_of_clients="Pocet asociovanych klientu : " |
wlm_number_of_clients="Pocet asociovanych klientu : " | |
wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : " |
wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : " | |
wlm_number_of_wds="Pocet asociovanych WDS spoju : " | ||
#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 : " | |
|
| |
###################################################################### | ||
w_html() | ||
{ | ||
wlc_ip="<font color=\"$wlh_ip\">" | ||
wlc_mac="<font color=\"$wlh_mac\">" | ||
wlc_name="<font color=\"$wlh_name\">" | ||
wlc_sig="<font color=\"$wlh_sig\">" | ||
wlc_bar="<font color=\"$wlh_bar\">" | ||
wlc_std="</font>" | ||
} | ||
###################################################################### |
###################################################################### | |
w_bw() |
w_bw() | |
{ |
{ | |
wlc_ip="" |
wlc_ip="" | |
wlc_mac="" |
wlc_mac="" | |
wlc_name="" | ||
wlc_sig="" |
wlc_sig="" | |
wlc_bar="" |
wlc_bar="" | |
wlc_std="" |
wlc_std="" | |
} |
} | |
###################################################################### |
###################################################################### | |
Line 57... | Line 81... | |
printf "=" |
printf "=" | |
wl_cnt=$(($wl_cnt - 1 )) |
wl_cnt=$(($wl_cnt - 1 )) | |
done |
done | |
printf " \n" |
printf " \n" | |
echo -n "${wlc_std}" |
echo -n "${wlc_std}" | |
# tput sgr0 |
||
} # w_bar |
} # w_bar | |
|
| |
###################################################################### |
###################################################################### | |
w_managed() |
w_managed() | |
{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}' |
{ echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}' | |
Line 90... | Line 113... | |
echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}' |
echo $wl_iwctxt | awk '{print $1,$3,$4,$5" "}' | |
echo $wl_iwctxt | awk '{print $6,$9,$11" "}' |
echo $wl_iwctxt | awk '{print $6,$9,$11" "}' | |
else |
else | |
echo $wl_iwctxt | awk '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g' |
echo $wl_iwctxt | awk '{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'` | |
wl_cnt=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'` |
wl_cnt=`echo $wl_macparam | awk '{print $5}' | sed 's/signal=//g'` | |
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 | awk '{print $1}'` # IP adresa peeru z arp tabulky | |
wl_name=`cat /etc/dhcpd.conf | grep -i $wl_mac | awk '{print $2}'` |
wl_name=`cat $wl_dhcp_s | grep -i $wl_mac -B 1 | awk '{print$2,$3}' | grep -i $wl_mac -v | awk '{print$1}'` | |
if [ "$wl_name" = "" ] | ||
then | ||
wl_name=`cat $wl_dhcp_d | grep -i $wl_mac -A 2 | awk '{print$2,$3}' | grep -i $wl_mac -v | awk '{print$1}'` | ||
wl_name=`echo $wl_name | awk '{print$1}' ` | ||
fi | ||
if [ "$wl_name" = "" ] | ||
then | ||
wl_name=`echo " " ` | ||
fi | ||
if [ "$wl_ipc" = "" ] | ||
then | ||
wl_ipc=`echo " " ` | ||
fi | ||
if [ $wcm_oneline -eq 0 ] |
if [ $wcm_oneline -eq 0 ] | |
then |
then | |
echo -n "$wl_name " |
echo -n "${wlc_mac}$wl_mac${wlc_std} Signal:${wlc_sig}$wl_cnt${wlc_std} " | |
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_name}$wl_name${wlc_std} " | |
echo $wl_macparam | awk '{print $1,$2" "}' |
echo $wl_macparam | awk '{print $1,$2" "}' | |
w_bar |
w_bar | |
else |
else | |
echo -n "$wl_name " |
echo -n "${wlc_mac}$wl_mac${wlc_std} " | |
#echo -n "${wlc_ip}$wl_ipc${wlc_std} " |
echo -n "${wlc_ip}$wl_ipc${wlc_std} " | |
echo -n "${wlc_mac}$wl_mac${wlc_std} ${wlc_sig}$wl_cnt${wlc_std} " |
echo -n "${wlc_sig}$wl_cnt${wlc_std} " | |
#echo -n "${wlc_name}$wl_name${wlc_std} " | ||
#echo -n $wl_macparam | awk '{print $1,$2" "}' |
#echo -n $wl_macparam | awk '{print $1,$2" "}' | |
w_bar |
w_bar | |
fi |
fi | |
done |
done | |
|
echo -n " " | |
echo |
echo | |
} # w_master |
} # w_master | |
| ||
###################################################################### | ||
w_wds() | ||
{ #Vypsani WDS spoju (royhrani ulozeno v $wl_iface , $wcm_ifc ) | ||
wl_num_wds=`cat $wl_hostap$wl_iface/wds | grep -c 00` | ||
echo $wlm_number_of_wds $wl_num_wds " " | ||
wl_wds=`cat $wl_hostap$wl_iface/wds | awk '{print $1 " " $2 " "}' ` | ||
echo -n "$wl_wds" | ||
printf "\n " | ||
} # w_wds | ||
|
| |
###################################################################### |
###################################################################### | |
w_iface() |
w_iface() | |
{ wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ Nick/_Nick/g'` |
{ 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'` |
wl_mode=`echo $wl_iwctxt | awk '{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 138... | Line 185... | |
echo $wl_iface $wlm_no_managed_or_master |
echo $wl_iface $wlm_no_managed_or_master | |
echo |
echo | |
fi |
fi | |
} |
} | |
|
| |
###################################################################### |
||
w_version() |
||
{ |
||
echo wifimon $wl_version |
||
exit 0 |
||
} |
||
###################################################################### |
###################################################################### | |
w_help() |
w_help() | |
{ |
{ | |
echo Pouziti: wifimon [param] |
echo Pouziti: wifimon [param] | |
echo param: |
echo param: | |
echo -v vypise verzi |
||
echo -html generovani html stranky |
echo -html generovani html stranky | |
echo -col barevny cyklicky vypis na obrazovku |
echo -mono monochroni 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 -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi |
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 165... | Line 205... | |
|
| |
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_mono=0 | |
wcm_oneline=0 |
wcm_oneline=0 | |
wcm_html=0 |
wcm_html=0 | |
wcm_ifc="" |
wcm_ifc="" | |
|
| |
# parsing input parameters |
# parsing input parameters | |
while [ "a$1" != "a" ] |
while [ "a$1" != "a" ] | |
do |
do | |
case $1 in |
case $1 in | |
-v) |
||
w_version |
||
;; |
||
-help) |
-help) | |
w_help |
w_help | |
;; |
;; | |
-once) |
-once) | |
wcm_once=1 |
wcm_once=1 | |
Line 188... | Line 225... | |
;; |
;; | |
-oneline) |
-oneline) | |
wcm_oneline=1 |
wcm_oneline=1 | |
shift |
shift | |
;; |
;; | |
-col) |
-mono) | |
wcm_col=1 |
wcm_mono=1 | |
shift |
shift | |
;; |
;; | |
-html) |
-html) | |
wcm_html=1 |
wcm_html=1 | |
shift |
shift | |
Line 237... | Line 274... | |
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)) | |
done |
done | |
wl_numclold=$wl_numcllast |
wl_numclold=$wl_numcllast | |
|
| |
if [ $wcm_col -eq 0 ] |
if [ $wcm_html -eq 1 ] | |
then | ||
w_html | ||
fi | ||
| ||
if [ $wcm_mono -eq 1 ] | ||
then |
then | |
w_bw |
w_bw | |
fi |
fi | |
|
| |
while [ 1 ] |
while [ 1 ] | |
Line 249... | Line 291... | |
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 [ $wcm_clear -eq 1 ] | |
then |
then | |
clear |
clear | |
echo ahoj |
||
wcm_clear=0 |
wcm_clear=0 | |
fi |
fi | |
wl_numcllast=0 |
wl_numcllast=0 | |
if [ $wcm_html -eq 1 ] |
if [ $wcm_html -eq 1 ] | |
then |
then | |
w_bw |
||
echo $wl_header |
echo $wl_header | |
for wl_iface in $wcm_ifc |
for wl_iface in $wcm_ifc | |
do |
do | |
w_iface |
w_iface | |
w_wds | ||
done |
done | |
echo $wl_footer |
echo $wl_footer | |
else |
else | |
tput cup 0 0 |
tput cup 0 0 | |
for wl_iface in $wcm_ifc |
for wl_iface in $wcm_ifc | |
do |
do | |
w_iface |
w_iface | |
w_wds | ||
done |
done | |
fi |
fi | |
|
||
if [ $wcm_once -eq 1 ] |
if [ $wcm_once -eq 1 ] | |
then |
then | |
exit 0 |
exit 0 | |
fi |
fi | |
sleep 1 |
sleep 1 | |
done |
done | |
|
| |
exit 0 |
exit 0 | |
| ||
|
| |
|
|