What's new

NODE --->ROUTER

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:

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