Last week I wrote about PingPlotter and my quest to diagnose AT&T U-verse’s flaky service. As I explained, it looks like AT&T default DNS servers are behaving badly and I’m waiting to hear back from the “powers that be” at AT&T.
PingPlotter is, as I discussed, extremely useful for this kind of problem or, indeed, as just a general host availability monitor, and in its bag of tricks is the ability to be scripted. This latter facility would be great except for the fact that it uses the Windows Scripting host, which is not a platform I particularly care for, and the API isn't documented except by a number of scripts (decoding them seemed like a lot of work).
But wait! The Pro version of PingPlotter (cheap at $199.95) has a built-in Web server. This nifty addition lets you expose the PingPlotter display, albeit in a slightly condensed form, to a Web browser or to be used with simple command line tools to get data and configure the application. Here’s what the default Web output looks like:
Ah! If you can set a new host to trace through the UI then you can add that and anything else the UI permits from a command line with curl, an incredibly rich tool that lets you make protocol-based requests including HTTP and is available for just about every platform other than vacuum cleaners and toasters.
Nessoft, bless their hearts, haven’t documented the RESTful calls that can be made to PingPlotter’s Web server, so we’re just going to have to poke around a bit. Let’s use Chrome’s DevTools: Go to the top right and click on the “hamburger” (that’s the icon of three horizontal bars) to open the Chrome menu and select Tools | Developer Tools.
Next, in Chrome go to the PingPlotter page, right click, and bring up the context menu and select Inspect Element and you’ll get something a lot like this:
Now enter a target site in PingPlotter’s New Target to Trace field (say, nessoft.com), then in the DevTools window click on the Network tab and then click on the Stop icon at the top left; that will clear the display because the PingPlotter UI keeps reloading that data to update the display and we don’t need to wade through so much cruft. Now, click on the New Target button in the PingPlotter display and voila! Your DevTools Network display should look like this:
The second entry from the top is what you’re looking for. Click on that entry and you can see the detail of the request:
Here’s the data at the start of the headers section more clearly:
Status Code:200 OK
You can see in the request URL the parameters that are passed and it turns out that the only ones we need are the ID key NEWTARGET and, for the value, the IP address or domain name of the target. The polling frequency as well as all other parameters will default to whatever is set in PingPlotter’s application UI (note that if you wanted to use a specific polling frequency you’d use the Interval key and give a value in milliseconds).
So, over to the command line. If you’re on a number of operating systems that includes OS X then curl will already be installed (if you’re not sure whether curl is on your machine just type “curl”at the command prompt and if you get something like “command not found”you need to go to the curl download page).
Note for OS X Mavericks users: See Important note for curl users on OS X Mavericks 10.9 on the curl site.
So, with curl installed all you need to do to add a target, say, 192.168.1.254, is enter:
RedQueen:~ mgibbs$ curl ‘http://192.168.1.127:81/cmd.asp?ID=NEWTARGET&target=192.168.1.254'
And the new target will be added to the target list. Now, let’s say you want to add a range of IP addresses. Turns out that curl know how to iterate over a range; just put the beginning and end IP addresses in square brackets like this:
RedQueen:~ mgibbs$ curl
Neat, eh? We’ve just added in all the IP addresses for a Class C network. Want a Class B network? Luckily curl is smart enough to iterate an iteration:
RedQueen:~ mgibbs$ curl
Removing a PingPlotter target is tricky because once added targets are identified by a PingPlotter-assigned ID. To get that ID you’d have to parse the contents of the PingPlotter Web page which .
But there’s a problem with adding too many targets: PingPlotter won’t be able to display so many graphs (they’ll all be squished up) and at some point the program will run out of memory or exhaust processor cycles. So, we need to be picky about which targets to add…we’ll figure out an answer in the next part.