Script CLI show connected clients info scripting question

Hi,

I need some help with some scripting

I have a Dumb AP, and with addrwatch I found already how to get the mac and ip adres.

Alos found this script and I modified it to get it work. Now I want to extend it with more (SNR SSID etc) The first I want to add is the SNR. I found the command on 1 SSID to get them, but how can I get it in the script

iwinfo phy0-ap0 assoclist | grep dBm | cut -d" " -f9 | cut -d")" -f1

Script that I have, and needs this line above into it.

echo    "# All connected wifi devices, with IP address,"
echo    "# hostname (if available), and MAC address."
echo -e "# IP4 address\tname\tMAC address\t\tSNR"
# list all wireless network interfaces
for interface in `iwinfo | grep ESSID | cut -f 1 -s -d" "`
do
  # for each interface, get mac addresses of connected stations/clients
  maclist=`iwinfo $interface assoclist | grep dBm | cut -f 1 -s -d" "`
  # for each mac address in that list...
  for mac in $maclist
  do
    ip="UNKN"
    host=""
    ip=`cat /etc/ethers | grep -i $mac | cut -f 2 -d" "`
    host=`cat /tmp/dhcp.leases | cut -f 2,3,4 -s -d" " | grep -i $mac | cut -f 3 -s -d" "`
    # ... show the mac address:
    echo -e "$ip\t$host\t$mac"
  done
done
#!/bin/sh

echo "# All connected wifi devices, with IP address,"
echo "# hostname (if available), and MAC address."
echo -e "# IP4 address\tname\tMAC address\t\tSNR"

# list all wireless network interfaces
for interface in $(iwinfo | grep ESSID | cut -f 1 -s -d" ")
do
  # for each interface, get mac addresses of connected stations/clients
  maclist=$(iwinfo "$interface" assoclist | grep dBm | cut -f 1 -s -d" ")
  # for each mac address in that list...
  for mac in $maclist
  do
    ip="UNKN"
    host=""
    snr=""
    ip=$(grep -i "$mac" /proc/net/arp | awk '{print $1}')
    host=$(grep -i "$mac" /tmp/dhcp.leases | awk '{print $4}')
    snr=$(iw dev "$interface" station get "$mac" | awk '/signal avg/ {print $3}')
    # ... show the ip address, hostname, and mac address:
    echo -e "$ip\t$host\t$mac\t\t$snr"
  done
done

Hi,

Thnx. Now I have some ideas to get more info. I notice that if the if the ip not yet is revolved and not is in the file, I got not the UNKN value, it's empty and then that line is not right formatted.

I also want to expand it with channel of de both radio's , so I see what devices (on mac ) uses what radio channel.

This is what I have right now.

#!/bin/sh

echo -e "# IP4 address\tname\tMAC address\t\tSNR\tSpeed Rx/Tx (mpbs)"
echo -e "-------------\t----\t-----------\t\t---\t------------------"

# list all wireless network interfaces
for interface in $(iwinfo | grep ESSID | cut -f 1 -s -d" ")
do
  # for each interface, get mac addresses of connected stations/clients
  maclist=$(iwinfo "$interface" assoclist | grep dBm | cut -f 1 -s -d" ")
  # for each mac address in that list...
  for mac in $maclist
  do
    ip="---"
    host="---"
    snr=""
    ip=`cat /etc/ethers | grep -i $mac | cut -f 2 -d" "`
    host=$(grep -i "$mac" /tmp/dhcp.leases | awk '{print $4}')
    snr=$(iwinfo "$interface" assoclist | grep "$mac" | grep dBm | cut -d" " -f9 | cut -d")" -f1)
    rx=$(iw dev "$interface" station get "$mac" | awk '/rx bitrate/ {print $3}')
    tx=$(iw dev "$interface" station get "$mac" | awk '/tx bitrate/ {print $3}')
    # ... show the ip address, hostname, and mac address SNR and Rx and Tx speed:
    echo -e "$ip\t$host\t$mac\t$snr\t$rx\t$tx"
  done
done