Hacking PingPlotter, Part 2

screen shot 2014 07 11 at 5.12.43 pm
Credit: Mark Gibbs

In the previous column on hacking PingPlotter I discussed how you can use the tool’s Web interface and the curl utility to add targets to be tracked, for example, to add a single host you would enter the following on the command line:

curl ‘ \

This assumes is the host that's running PingPlotter Pro with the Web server enabled and is the host you want to monitor. Better still, a whole range of hosts can be added using sequences; for example:


But, as I pondered at the end of the previous column, how could you add only the active hosts on your network? After a bit of tinkering this is the Bash script I came up with:

# (the previous “hash bang” line isn’t necessary under OS X)
# Usage: pp-prog %1 %2 %3 %4 %5
#       %1 - first IP address octet
#       %2 - second IP address octet
#       %3 - third IP address octet
#       %4 - start value for fourth IP address octet
#       %5 - end value for fourth IP address octet
# Example: > pp-prog.sh 192 168 1 1 254
COUNT=3    # number of pings to send to each host
DOT=“.”    # separator for IP address
a=$1$DOT$2$DOT$3$DOT  # build a string of the top
# three IP address octets
for (( i=$4; i<=$5; i++ )) # note 1
    response=$(ping -t 1 -c $COUNT $a$i | \
grep 'received' | \
awk -F',' '{ print $2 }' | \
awk '{ print $1 }’)  # notes 2, 3, 4, 5
    if [ $response -ne 0 ];
        printf "Host : $a$i is up at $(date)  \r” # note 6a
        curl ' \
&target='$a$i &>/dev/null  #note 6b
        printf "Host : $a$i is down at $(date)\r”  # note 7
printf "%0.s " {1..62} # note 8a
printf "\rDone.\n" # note 8b

If you’re on OS X and have curl installed (see the previous column) then you can just create a file called pp-prog.sh with the above text (modified for the address of your PingPlotter host then make it executable with the command:

chmod +x pp-prog.sh

Voila! You can now configure PingPlotter for only the active hosts on your network.

Note that if you run the script again PingPlotter will add a second entry for each host the script finds which is not what you want … so, if you have a better script or even one that can run repeatedly and add newly found hosts without duplicating those already added as targets to PingPlotter or even remove hosts that go missing let me know.


First of all, if you're on Windows and you don't have the Bash shell see Is there a way to run Bash scripts on Windows?

Next, here are a few notes on what the script is doing:

1 2 Page 1
Must read: 10 new UI features coming to Windows 10