My free SM-subnet-scanning script

This is a script I made to help show signal stats at my WISP. Runs on Linux.
It scans a class-C subnet, and for each IP, shows either the pingtime
or (NONE) if there’s nothing at that IP. If there’s a ping result, it
logs in to the SM with the admin username (and password you specified),
and it gets, and prints out, signal strength, jitter, and sitename.

Before you use it, you need to edit it to specify the first 3 bytes of your subnet, and the first and last IPs to scan. As below, it scans 10.10.10.2 to 10.10.10.254

---------------------

#!/bin/bash
# List canopy SMs on a subnet, incl. pingtime, signal, jitter and name. By Colin S., colin (a) ninja dot ca
# This script could be made better (single curl HTTP request instead of many to save b/w; then extract the info from that). Maybe one day…
# SM results without () around dbm and >< around jitter mean 8.0 software units

if [ -z $1 ]
then
echo “please put the SMs’ password as a parameter.”
exit 0
fi

IPMAX=254
IPMIN=2
SUBNET=10.10.10

hostsup=0

for ((currip=IPMIN; currip <= IPMAX ; currip++))
do
echo -n “IP:” $SUBNET.$currip
pingres=ping $SUBNET.$currip -w 2 -n -q -c 1 | tail -n 1 | cut -b 24-200 | cut -d / -f 1 | tr -d '\'n' | tr -d '\'r'
if [ -z $pingres ]
then
echo " (NONE)"
else
let hostsup=hostsup+1
echo -n " ping: " $pingres " ms, signal: "
curl -s --connect-timeout 10 -u admin:$1 http://$SUBNET.$currip/smstatus.html | grep “&nbsp;&nbsp;(” | cut -d’"’ -s -f 5-20 | cut -d’;’ -s -f 3-5 | cut -d’<’ -s -f 1 | tr -d ‘‘n’ | tr -d ‘‘r’
curl -s --connect-timeout 10 -u admin:$1 http://$SUBNET.$currip/main.cgi | tail -n 36 | head -n 1 | tr -d ‘‘n’ | tr -d ‘‘r’
echo -n ", jitter: "
curl -s --connect-timeout 10 -u admin:$1 http://$SUBNET.$currip/smstatus.html | grep -A 2 Jitter | tail -n 1 | cut -d’"’ -s -f 5 | cut -d’/’ -s -f 1 | tr -d '‘n’ | tr -d '‘r’
curl -s --connect-timeout 10 -u admin:$1 http://$SUBNET.$currip/main.cgi | tail -n 32 | head -n 1 | tr -d ‘‘n’ | tr -d ‘‘r’
echo -n " name: "
curl -s --connect-timeout 10 -u admin:$1 http://$SUBNET.$currip/smstatus.html | grep maxlength | cut -d’"’ -s -f 14 | head -n 1
curl -s --connect-timeout 10 -u admin:$1 http://$SUBNET.$currip/main.cgi | tail -n 16 | head -n 1
fi
done

echo "Number of SMs that replied to pings: " $hostsup
exit 0