What's new

how do I pull node wireless data from main router in a script

JB_1366

Occasional Visitor
Im running this script manually on my node, and manually uploading node_upload.txt to my main router. is there a way to automate the process, so i can just run my script on router to use node_upload.txt and apply results? A direct pull of variables would be great, if possible.

Code:
#!/bin/sh
# --- Configuration ---
YAZ_CLIENTS="/jffs/addons/YazDHCP.d/DHCP_clients"
[ ! -f "$YAZ_CLIENTS" ] && YAZ_CLIENTS="/jffs/scripts/DHCP_clients"
TXT_EXPORT="/jffs/scripts/node_upload.txt"

# Get dynamic router name and time
ROUTER_NAME=$(nvram get modelname)
[ -z "$ROUTER_NAME" ] && ROUTER_NAME=$(hostname)
CUR_TIME=$(date +'%m/%d %H:%M')

# Initialize File
echo "NAME|$ROUTER_NAME" > "$TXT_EXPORT"
echo "TIME|$CUR_TIME" >> "$TXT_EXPORT"

EXC=0; GOOD=0; FAIR=0; POOR=0; TOTAL=0

echo "========================================================================================="
echo "                  NODE WIRELESS SIGNAL REPORT [$ROUTER_NAME]                             "
echo "========================================================================================="
printf "%-22s | %-17s | %-10s | %-12s | %-8s | %-5s\n" "Hostname" "MAC Address" "Signal" "Quality" "Band" "IFace"
echo "-----------------------------------------------------------------------------------------"

for iface in $(ifconfig -a | grep -oE "wl[0-9].[0-9]"); do
    case "$iface" in wl0*) B="2.4G" ;; *) B="5G" ;; esac
    for mac in $(wl -i "$iface" assoclist | awk '{print $2}'); do
        [ -z "$mac" ] && continue
        rssi=$(wl -i "$iface" rssi "$mac" | awk '{print $1}')
        mac_up=$(echo "$mac" | tr '[:lower:]' '[:upper:]')
        name=$(grep -i "$mac_up" "$YAZ_CLIENTS" 2>/dev/null | awk -F',' '{print $3}')
        [ -z "$name" ] && name="Unknown"

        if [ "$rssi" -ge -50 ]; then Q="Excellent"; EXC=$((EXC+1))
        elif [ "$rssi" -ge -65 ]; then Q="Good"; GOOD=$((GOOD+1))
        elif [ "$rssi" -ge -75 ]; then Q="Fair"; FAIR=$((FAIR+1))
        else Q="Poor"; POOR=$((POOR+1)); fi
        TOTAL=$((TOTAL+1))

        printf "%-22s | %-17s | %-10s | %-12s | %-8s | %-5s\n" "$name" "$mac_up" "$rssi dBm" "$Q" "$B" "$iface"
        echo "$mac_up|$rssi|$Q|$B|$iface" >> "$TXT_EXPORT"
    done
done

echo "-----------------------------------------------------------------------------------------"
echo "SUMMARY FOR THIS NODE: Total: $TOTAL (Excellent: $EXC, Good: $GOOD, Fair: $FAIR, Poor: $POOR)"
echo "========================================================================================="
 
Last edited:
If you're running Merlin on the node couldn't you write a script that you execute on the router that would SSH into the node, run the script you pasted above, and have the output piped to a local file?
 
If you're running Merlin on the node couldn't you write a script that you execute on the router that would SSH into the node, run the script you pasted above, and have the output piped to a local file?
If you have a way, I'm listening. Gemini-AI tried for me for hours, would not ssh-authenticate between routers, and I tried with ssh-key and password. if router could ssh into node, I could bypass script and just pull wireless variables. ASUS might have it locked down.
 
Last edited:
If you have a way, I'm listening. Gemini-AI tried for me for hours, would not ssh-authenticate between routers, and I tried with ssh-key and password. if router could ssh into node, I could bypass script and just pull wireless variables. ASUS might have it locked down.

Edit: FYI I just used Putty to SSH into my main router and then did command-line SSH to go from there into one of my nodes (main router is Merlin, node is Asus stock firmware), so it does work.
 
Last edited:
I can ssh into router, then from there to node, both running Merlin.

Make sure allow password login is enabled in the SSH config on the router.
 

I can ssh into router, then from there to node, both running Merlin.

Make sure allow password login is enabled in the SSH config on the router.
i too can now ssh into node from router using password, problem is, you cant put a password in script using ssh command. sshpass supposedly does this, but opkg doesnt carry it.

I probably should have name thread: how do I pull node wireless data from main router in a script.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top