mirror of
https://github.com/limosek/zaf-plugins.git
synced 2025-01-21 07:25:56 +01:00
Repaired functions of iwx
This commit is contained in:
parent
fcc76c0072
commit
45ae337483
@ -4,7 +4,7 @@ Description::
|
|||||||
Plugin for wifi mac80211 informations and discovery
|
Plugin for wifi mac80211 informations and discovery
|
||||||
::
|
::
|
||||||
|
|
||||||
Version: 0.3
|
Version: 0.4
|
||||||
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/iwx
|
Url: https://raw.githubusercontent.com/limosek/zaf-plugins/master/iwx
|
||||||
Web: https://github.com/limosek/zaf-plugins
|
Web: https://github.com/limosek/zaf-plugins
|
||||||
|
|
||||||
|
213
iwx/functions.sh
213
iwx/functions.sh
@ -1,201 +1,160 @@
|
|||||||
|
|
||||||
|
|
||||||
wifi_ifphylist_openwrt() {
|
|
||||||
local devs phys p ifname ifindex i
|
|
||||||
|
|
||||||
if [ -f /usr/share/libubox/jshn.sh ]; then
|
|
||||||
. /usr/share/libubox/jshn.sh
|
|
||||||
|
|
||||||
json_load "$(ubus -S call network.wireless status)"
|
|
||||||
json_get_keys phys
|
|
||||||
for p in $phys; do
|
|
||||||
if [ "$1" = "phy" ]; then
|
|
||||||
echo $p
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
json_select "$p"
|
|
||||||
json_select "interfaces"
|
|
||||||
json_get_keys ifindex
|
|
||||||
for i in $ifindex; do
|
|
||||||
json_select $i
|
|
||||||
json_get_var ifname ifname
|
|
||||||
echo $ifname
|
|
||||||
json_select ..
|
|
||||||
done
|
|
||||||
json_select ..
|
|
||||||
json_select ..
|
|
||||||
done
|
|
||||||
else
|
|
||||||
wifi_ifphylist "$1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wifi_ifphylist() {
|
wifi_ifphylist() {
|
||||||
local i
|
if [ "$1" = "phy" ]; then
|
||||||
|
iw dev | grep Interface | cut -d ' ' -f 2
|
||||||
if [ "$1" = "phy" ]; then
|
else
|
||||||
for i in 0 1 2 3 4 5 6; do
|
iw phy | grep Wiphy | cut -d ' ' -f 2
|
||||||
if zaf_sudo iw phy phy$i info >/dev/null 2>/dev/null; then
|
fi
|
||||||
echo phy$i
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
for i in 0 1 2 3 4 5 6; do
|
|
||||||
if zaf_sudo iw dev wlan$i info >/dev/null 2>/dev/null; then
|
|
||||||
echo wlan$i
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_iflist(){
|
wifi_iflist(){
|
||||||
zaf_os_specific wifi_ifphylist || wifi_ifphylist
|
wifi_ifphylist
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_phylist(){
|
wifi_phylist(){
|
||||||
zaf_os_specific wifi_ifphylist phy || wifi_ifphylist phy
|
wifi_ifphylist phy
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_scan_dump(){
|
wifi_scan_dump(){
|
||||||
wifi_scan $1 | tr '(' ' ' | \
|
wifi_scan $1 | tr '(' ' ' | \
|
||||||
awk '/^BSS / { printf "'$1' %s ",$2} /freq:/ { printf "%s ",$2 } /signal:/ { printf "%s ",$2 } /SSID:/ { printf "%s\n",$2 } '
|
awk '/^BSS / { printf "'$1' %s ",$2} /freq:/ { printf "%s ",$2 } /signal:/ { printf "%s ",$2 } /SSID:/ { printf "%s\n",$2 } '
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_scan() {
|
wifi_scan() {
|
||||||
local key="wifi_scan_dump_$1"
|
local key="wifi_scan_dump_$1"
|
||||||
if ! zaf_fromcache "$key"; then
|
if ! zaf_fromcache "$key"; then
|
||||||
wifi_real_scan "$1" | zaf_tocache_stdin "$key" 300
|
wifi_real_scan "$1" | zaf_tocache_stdin "$key" 300
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_real_scan() {
|
wifi_real_scan() {
|
||||||
zaf_sudo iw dev "$1" scan
|
zaf_sudo iw dev "$1" scan
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_channel_dump(){
|
wifi_channel_dump(){
|
||||||
wifi_scan "$1" >/dev/null
|
wifi_scan "$1" >/dev/null
|
||||||
zaf_sudo iw dev $1 survey dump | tr -s '\t ' | \
|
zaf_sudo iw dev $1 survey dump | tr -s '\t ' | \
|
||||||
awk '/frequency:/ { printf "'$1' %i ",$2 } /noise:/ {printf "%i ",$2 } /active time:/ {printf "%i ",$4 } /busy time:/ {printf "%i ",$4 } /receive time:/ {printf "%i ",$4 } /transmit time:/ {printf "%i \n",$4 }'
|
awk '/frequency:/ { printf "'$1' %i ",$2 } /noise:/ {printf "%i ",$2 } /active time:/ {printf "%i ",$4 } /busy time:/ {printf "%i ",$4 } /receive time:/ {printf "%i ",$4 } /transmit time:/ {printf "%i \n",$4 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_if_discovery(){
|
wifi_if_discovery(){
|
||||||
wifi_iflist | grep '^[a-z].*' | zaf_discovery "{#IF}"
|
wifi_iflist | grep '^[a-z].*' | zaf_discovery "{#IF}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_phy_discovery(){
|
wifi_phy_discovery(){
|
||||||
wifi_phylist | grep '^[a-z].*' | zaf_discovery "{#DEV}"
|
wifi_phylist | grep '^[a-z].*' | zaf_discovery "{#DEV}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_channels_discovery(){
|
wifi_channels_discovery(){
|
||||||
local devs
|
local devs
|
||||||
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
||||||
for dev in $devs; do wifi_channel_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#FREQ}" "{#NOISE}"
|
for dev in $devs; do wifi_channel_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#FREQ}" "{#NOISE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_neigh_discovery(){
|
wifi_neigh_discovery(){
|
||||||
local devs
|
local devs
|
||||||
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
||||||
for dev in $devs; do wifi_scan_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#BSS}" "{#FREQ}" "{#SIGNAL}" "{#SSID}"
|
for dev in $devs; do wifi_scan_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#BSS}" "{#FREQ}" "{#SIGNAL}" "{#SSID}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_channel_noise(){
|
wifi_channel_noise(){
|
||||||
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $noise)
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $noise)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_channel_activetime(){
|
wifi_channel_activetime(){
|
||||||
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $active)
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $active)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_channel_busytime(){
|
wifi_channel_busytime(){
|
||||||
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $busy)
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $busy)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_channel_receivetime(){
|
wifi_channel_receivetime(){
|
||||||
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $receive)
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $receive)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_channel_transmittime(){
|
wifi_channel_transmittime(){
|
||||||
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $transmit)
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $transmit)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_neigh_channel(){
|
wifi_neigh_channel(){
|
||||||
wifi_scan_dump $1 | grep "^$1 $2" | (
|
wifi_scan_dump $1 | grep "^$1 $2" | (
|
||||||
read dev bss freq signal ssid;
|
read dev bss freq signal ssid;
|
||||||
if [ -n "$freq" ]; then
|
if [ -n "$freq" ]; then
|
||||||
echo $freq
|
echo $freq
|
||||||
else
|
else
|
||||||
echo "0"
|
echo "0"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_neigh_signal(){
|
wifi_neigh_signal(){
|
||||||
wifi_scan_dump $1 | grep "^$1 $2" | (
|
wifi_scan_dump $1 | grep "^$1 $2" | (
|
||||||
read dev bss freq signal ssid;
|
read dev bss freq signal ssid;
|
||||||
if [ -n "$signal" ]; then
|
if [ -n "$signal" ]; then
|
||||||
echo $signal
|
echo $signal
|
||||||
else
|
else
|
||||||
echo "-200"
|
echo "-200"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_neigh_ssid(){
|
wifi_neigh_ssid(){
|
||||||
wifi_scan_dump $1 | grep "^$1 $2" | (
|
wifi_scan_dump $1 | grep "^$1 $2" | (
|
||||||
read dev bss freq signal ssid;
|
read dev bss freq signal ssid;
|
||||||
if [ -n "$ssid" ]; then
|
if [ -n "$ssid" ]; then
|
||||||
echo $ssid
|
echo $ssid
|
||||||
else
|
else
|
||||||
echo "N/A"
|
echo "N/A"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_clients(){
|
wifi_clients(){
|
||||||
zaf_sudo iw dev $1 station dump | grep ^Station | wc -l
|
zaf_sudo iw dev $1 station dump | grep ^Station | wc -l
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_clients_dump(){
|
wifi_clients_dump(){
|
||||||
zaf_sudo iw dev $1 station dump | awk '/^Station / { printf "'$1' %s ",$2} /signal:/ { printf "%s ",$2 } /tx bitrate:/ { printf "%s ",$3 } /rx bitrate:/ { printf "%s\n",$3 } '
|
zaf_sudo iw dev $1 station dump | awk '/^Station / { printf "'$1' %s ",$2} /signal:/ { printf "%s ",$2 } /tx bitrate:/ { printf "%s ",$3 } /rx bitrate:/ { printf "%s\n",$3 } '
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_clients_discovery(){
|
wifi_clients_discovery(){
|
||||||
local devs
|
local devs
|
||||||
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
||||||
for dev in $devs; do wifi_clients_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#STATION}" "{#SIGNAL}" "{#TXRATE}" "{#RXRATE}"
|
for dev in $devs; do wifi_clients_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#STATION}" "{#SIGNAL}" "{#TXRATE}" "{#RXRATE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_client_signal(){
|
wifi_client_signal(){
|
||||||
wifi_clients_dump $1 | grep "^$1 $2" | (
|
wifi_clients_dump $1 | grep "^$1 $2" | (
|
||||||
read dev station signal tx rx;
|
read dev station signal tx rx;
|
||||||
if [ -n "$signal" ]; then
|
if [ -n "$signal" ]; then
|
||||||
echo $signal
|
echo $signal
|
||||||
else
|
else
|
||||||
echo "-200"
|
echo "-200"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_client_rxrate(){
|
wifi_client_rxrate(){
|
||||||
wifi_clients_dump $1 | grep "^$1 $2" | (
|
wifi_clients_dump $1 | grep "^$1 $2" | (
|
||||||
read dev station signal tx rx;
|
read dev station signal tx rx;
|
||||||
if [ -n "$rx" ]; then
|
if [ -n "$rx" ]; then
|
||||||
echo $rx
|
echo $rx
|
||||||
else
|
else
|
||||||
echo "0"
|
echo "0"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
wifi_client_txrate(){
|
wifi_client_txrate(){
|
||||||
wifi_clients_dump $1 | grep "^$1 $2" | (
|
wifi_clients_dump $1 | grep "^$1 $2" | (
|
||||||
read dev station signal tx rx;
|
read dev station signal tx rx;
|
||||||
if [ -n "$tx" ]; then
|
if [ -n "$tx" ]; then
|
||||||
echo $tx
|
echo $tx
|
||||||
else
|
else
|
||||||
echo "0"
|
echo "0"
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user