Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


November 06, 2009

Monitor Network Connections with Pingmon

RSS
Subscribe to Windows IT Pro | See More Systems Administration Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

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.

End of Article



Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Battery Life Issues Almost Certainly Not Windows 7's Fault

While Microsoft is still investigating a notebook battery life issue that was supposedly caused by Windows 7, some interesting trends have emerged. ...

Confirmed: Battery Life Issues Not Windows 7's Fault

Microsoft on Monday issued a lengthy statement about the recent Windows 7 battery controversy, echoing my assessment from earlier in the day, but backing it up with hard, cold evidence. ...

Getting your iPhone to Sync with Exchange 2003

Follow these steps to use an iPhone with Exchange. ...


Task Automation Whitepapers Three Ways to Prevent Insider Risk within Your SCCM-Managed Environment

From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Managing IT Across Multiple Locations

7 Ways To Get More From Your SharePoint Deployment Now

Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2010 Penton Media, Inc. Terms of Use | Privacy Statement