Open Source

Keep tabs on your network connection--for free!

Has your network come crashing down while you were living in oblivion? Wouldn't it be nice if there were a simple way to sound the alarms when the connection was broken? Well, there is. Let Jack Wallen show you a quick and free monitoring system.

The last time we went round about with this topic (”Free network uptime alarms with Linux”), we created a simple alarm system with the Linux operating system that would send out a ping into your network (either external or internal) and set off a simple alarm that would terminate only when killed by the administrator. This was Linux and was very simple.

This time, however, we’re going to tackle the same task in Windows-land. What we will have is a simple batch file that we will set up with the Task Scheduler to run every 10 minutes, ping a given URL (or IP address), and run the Windows Media Player to loop a small .wav file until it drives your staff absolutely mad!

The needs of the many
This particular monitor relies on your alarm-hosting PC having a soundly configured sound card, as well as speakers with which to hear its lofty sounds.

The script
Nothing horribly spectacular here, but it does the job (thanks to my counterpart in crime, John Sheesley). The script will be called Linktest.bat and will be stored in C:\WINNT. The script looks like this.

This is a simple script. First, with del %1.txt, it deletes any previous .txt files that were generated by earlier runs of the script. (The %1 is a variable that gets its input from the command entered. More on that later.) The second line, ping %1 –w 2500 > %1.txt, will ping the address passed through the variable %1, with a 2.5 second tolerance, and dump the results into the file %1.txt. (Again, it’s gaining its name from the command switch passed by you.) The next line checks the newly created file for the string bytes=32. (Remember, a successful ping in Windows will ping with 32 bytes of data and report that information back.) If findstr finds the string bytes=32 in the file, it will silently exit. If findstr does not find the configured string, it will then go to the next line, which opens the Windows Media Player and plays a configured sound (of course, we want to configure Media Player itself to continuously loop the sound) until the administrator makes it go away! Finally, just in case something is wrong with our sound (or someone pulls the plug on the speakers), we’ll pop up a message to a user (whose username is passed through the command line) with the net send command (see Figure A).

Figure A
Looks like our systems administrator has a sense of humor!

Okay, now that you know what it does, what do you do with it? Well, first things first. Paste the code into Word Pad or your favorite editor (mine is Pico, but we’re talking Windows, not Linux) and save the file as Linktest.bat in the WINNT directory (assuming you’re using Win2K). Once that file is saved, you’re ready to actually run the script and bask in its glory.

Running the script
Running this script requires a couple of switches be sent with the command executable. In order to run the command, you will need to open a command prompt (from Start | Run, enter cmd) and enter the following syntax:

So, if I open the command prompt and enter the following:
linktest wallenj

I will see one of two things: an error message, as seen in Figure B (if this is the first time the script has been run on this particular URL), or the results of the ping test quickly flying by. After one of these messages goes by, the command prompt will disappear.

Figure B
Since this is the first time the script has run, the file will not have been generated.

Now, should that address be unreachable, we would see something completely different. If we run the command
linktest ohboythisisaurl wallenj

we’ll first see the Windows Media player (which will loop the chimes.wav file), followed by the pop-up message you saw in Figure A.

Now, if you take a look in your root directory, you’ll see some new files (one called and one called ohboythisisaurl). Take a look at the file In it, you will see this. What you’re looking at is, you guessed it, the results of your ping test! Pretty groovy, eh?

Let’s schedule this puppy
With Linux, we simply set up a cron job so our script would run every 10 minutes. With the help of the Task Scheduler, we can do the same thing in Windows. From Start | Programs | Accessories | System Tools, select Scheduled Tasks. Once the Scheduled Tasks window is open, double-click on Add Scheduled Task to open the Scheduled Task Wizard. Once you get beyond the splash screen, you’ll have to select a program to run (see Figure C).

Figure C
Since we created our script, it won’t show up in the default selections.

Obviously, our batch file is not going to be listed here so you’ll have to click the Browse button. Then, navigate through WINNT, select the Linktest.bat file, and click Open. Once the next window opens, you’ll have to deal with what little offerings Microsoft initially gives up (we’ll tweak it in a bit). In this next window, give your task a name (it should come up Linktest) and then select One Time Only (see Figure D).

Figure D
Win2K will name your task for you. Whether you take that name is up to you.

Select Next and then you will have to choose a Start Time and Start Date (see Figure E). For our purposes, we are going to select the current time and date. Once you’ve clicked through this configuration, you will have to enter a username and password in order for the task to actually run.

Figure E
For now, we are going to pick a time and date for our task to run.

Now that we have our task scheduled, we are going to modify its settings. On the original screen, the Schedule Tasks window, you’ll see a new icon labeled Linktest. Right-click on this icon and select Properties. In this window, you will need to deal with both the Task and the Schedule tabs. Within the Task tab, you are going to fill out the remainder of the command. As you can see, in Figure F, we are going to add wallenj after C:\WINNT\linktest.bat in the Run dialog box.

Figure F
Too bad you couldn’t enter the complete command when you first created this task!

Once you have that bit of information entered, click on the Schedule tab and configure it as you see in Figure G.

Figure G
The only thing you really need to do is choose Repeat Task and choose a frequency.

With everything configured, you are ready to run. If you need to monitor your internal network, it would be best to add a second scheduled task that will have the Linktest.bat file ping an internal address as well. To do this, simply run through the same steps outlined above.

There is no denying that free is good. With the help of some simple tools and some creative energy, you can take this idea, make it your own, and wind up with one well-monitored network! Of course, you don’t want to forget to crank up the bass on your speakers so you can hear your alarm throughout the building.

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website

Editor's Picks

Free Newsletters, In your Inbox