Boswell's Q&A

Script Sampling

A reader needs a dynamic, graphical count of network traffic and wants to use scripting to do it. Bill points to a few sources for understanding scripting.

Bill: Is there anyway by means of VB script or a plain VB program to capture the network I/O packet count on a machine? I'd like to write a program to dynamically retrieve all the network traffic counts for my network and display them graphically. Any ideas?
—Dennis P.

Dennis: Your best bet at getting any kind of hardware or device information from Windows is by using WMI. The Win32_PerfFormattedData_TCPIP_NetworkInterface class collects the same network information as shown in Task Manager on Windows XP and Windows Server 2003. If you have experience writing WMI scripts, then it should be a simple thing to capture the network statistics in this class at various periods of time and display the results in HTML.

Get Help from Bill

Got a Windows or Exchange question or need troubleshooting help? Or maybe you want a better explanation than provided in the manuals? Describe your dilemma in an e-mail to Bill at mailto:[email protected]; the best questions get answered in this column.

When you send your questions, please include your full first and last name, location, certifications (if any) with your message. (If you prefer to remain anonymous, specify this in your message but submit the requested information for verification purposes.)

If you haven't written much WMI, then I'd suggest downloading Microsoft's Script-o-Matic tool at www.microsoft.com/downloads/
details.aspx?displaylang=en&familyid=
9ef05cbd-c1c5-41e7-9da8-212c414a7ab0
, which automates the enumeration of a WMI class.

A commercial scripting tool from PrimalScript (http://www.primalscript.com) also has a WMI scripting engine and also includes support for VBScript syntax coloring and class expansion.

There's a three-part WMI tutorial from the Microsoft Scripting Guys that helps introduce WMI techniques and syntax. Go to www.microsoft.com/scripting and look for the WMI Scripting Clinic links. The same authors have a book called "Microsoft Windows 2000 Scripting Guide" that's available online at www.microsoft.com/technet/treeview/default.asp?
url=/technet/scriptcenter/scrguide/sagsas_overview.asp
.

If you intend on doing a lot of WMI scripting, you should also take a look at Developing WMI Solutions by Craig Tunstall and Gwyn Cole. It's a great resource for putting together really useful scripts. The best price I found was at Bookpool at www.bookpool.com/.x/37xjoikv50/sm/0201616130.

And, my editor reminds me that I should put in a plug for MCPmag's own Chris Brooke, who writes a monthly scripting column; you can catch the latest one at http://mcpmag.com/columns/scripting/

If you're wondering how I knew which class to choose for collecting network data, I absolutely assure you that I don't have them memorized. I used CIM Studio to search for any classes that contain the word "network," then went down the list of Win32 classes until I found one that had the properties I wanted. Download CIM Studio as part of the WMI Tools bundle, which includes a WMI Object Browser and WMI Event Viewer, at www.microsoft.com/downloads/details.aspx?familyid=6430f853-1120-
48db-8cc5-f2abdc3ed314&displaylang=en
.

Hope this helps.

About the Author

Contributing Editor Bill Boswell, MCSE, is the principal of Bill Boswell Consulting, Inc. He's the author of Inside Windows Server 2003 and Learning Exchange Server 2003 both from Addison Wesley. Bill is also Redmond magazine's "Windows Insider" columnist and a speaker at MCP Magazine's TechMentor Conferences.

comments powered by Disqus
Most   Popular