Wednesday, November 14, 2007

Download This! - Heartbeat Monitor

Let's say you leave your computer alone for a while, working on a task (uploading content to your site, downloading a large VM appliance etc.). You return after a couple of hours to find out your computer disconnected from the internet and the entire job failed.

Or let's say you're like me, on the road 80% of your time. You leave your computer at home on - and connect to it from the road through VNC. Only, if the computer disconnected from the internet, due to a DSL drop - you're screwed.

That was the problem I've encountered about a year ago: I was working in Europe, limited, in many places, to modem-speed connection. I therefore used it to connect to my home computer and order it to do the heavy lifting.

About once a week, my ISP dropped my DSL connection (I later found out it's their a policy: if you have a private account, you're not supposed to be connected 24X7 - because that would imply you're a business, and then you need to pay for a business account) and I could not connect to my computer until I returned home.

This pissed me off to no end for several months, until I decided to solve it. [Yes, this post's tool was written by me].

I wrote a small application called Heartbeat Monitor that runs in the background (minimized to the tray) and pings a certain address (one that's supposed to be up 99.999% of the time, say www.google.com). If the ping operation failed, the program launched a script that called the internet dialer and resumed the connection. If it was an actual line problem, it would keep trying to run the script every n minutes. Eventually, it resumed the internet connection (unless there was a complete power failure) and I could reach my computer again.

The application is written as a .Net 2.0 console application and I've allowed myself to play with GUI nuts and bolts (such as an in-memory cyclic log, taskbar icon, gradiant-colored form etc.).
I planned to write a CodeProject article on it - and I may soon, when I have the time (see my other CodeProject articles).

The script that the application runs in case of a ping failure can be any executable or Windows batch. It can even restart the machine.

I published the application to SourceForge about a year ago and had several hundred downloads. So far, 3 people wrote to me, describing how they're using it. One is an IT consultant who installs it for every customer he has, to maintain connection to a central server. Another, who wrote me 2 days ago, used it to prove to his ISP that his DSL connection is constantly dropped, by showing them the log file.

Here's a link to a page I put up, describing the application, and providing some script samples.
You can also download the application - and its source from the same page.

No comments: