Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

November 06, 2009 12:00 AM

Monitor Network Connections with Pingmon

Windows IT Pro
InstantDoc ID #102911
Rating: (1)
Downloads
102911.zip

The staff at a remote location in my company had reported frequent network outages, so I had to come up with a way to monitor their network connection. I wanted to see how often the connection went down and how long it took to come back up. Rather than spending money on a commercial program or digging through huge ping logs, I pulled together a few free utilities and wrote a .bat script named Pingmon.

Pingmon is simple in concept: It watches an address that's either responding or not, and if the state changes, the script generates an email and a log entry. The log shows when the connection went up or down. When a connection goes from down to up, the log also shows how long it was down.

The syntax to use Pingmon is straightforward:

pingmon <computername> <frequency>
  <email-address> <log-file> [<comment>]

where

  • computername is the name or IP address of the device you want to monitor
  • frequency is the number of seconds to wait between ping attempts
  • email-address is where you want to receive email notifications
  • log-file is the name of the file in which you want to log all state changes
  • comment is an optional one-word description of what you're monitoring

(Although this command wraps here, you'd enter it all on one line. The same holds true for the sample command that follows.)

If you don't want to receive the email notifications or have a log file, you can just use a period for that parameter. You might not want email notifications if you expect a device to go up and down frequently and you just need to keep track of the device's state. You might not want to have a log file if you need to take some action as soon as a device becomes available.

Pingmon uses three utilities: date.exe, SleepX, and Blat. Date.exe is a port of the UNIX date command. It provides a UNIX-type date so that the script can calculate how long a circuit is down. Date.exe is one of many UNIX tools in the UnxUtils.zip file, which you can download from unxutils.sourceforge.net.

The script uses SleepX to create a pause between ping attempts. SleepX is part of the Shell Scripting Toolkit, which is collection of Win32 command-line utilities you can use in cmd.exe shell scripts. You can download the Shell Scripting Toolkit from www.westmesatech.com/sst.html.

Pingmon uses Blat to send the email notifications. Blat is an extremely versatile command-line mailer that's easy to set up and use. However, I recommend that you install it as follows: Download the utility from www.blat.net, and copy the blat.exe file into a library in your path. Then, at a command prompt, run

blat.exe –install <your.mailserver.com>
  <you@yourdomain.com>

substituting your.mailserver.com and you@yourdomain.com with the name of your SMTP email server and your email address, respectively. Installing it this way saves these values in your registry so you don't have to pass them as parameters every time you run Blat.

Besides using Pingmon to troubleshoot the remote location's network outages, my colleagues and I have found many other uses for it. We've used it to watch several devices at remote locations to determine what switches are dropping out. To monitor a plant's network, we ran several Pingmon scripts, had them log to the same file, and set up a scheduled task to email the log to us every day. We also used the script to monitor servers awaiting reboots and monitor circuit uptime in international locations. Whatever you're watching, Pingmon throws out the fluff so you only have to look at interesting events.

You can download Pingmon, which I wrote for use on Windows NT 4.0 and later, by clicking the Download the Code Here button. You don't need to customize the code at all, but you do need to install the date.exe, SleepX, and Blat utilities to use Pingmon. Depending on what you plan to use Pingmon for, you might want to enhance it. For example, you could add an option to write the log entries in a database or have it run Traceroute (tracert.exe) when a device goes down.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.