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


December 11, 2006

Scripts for Monitoring System Performance

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

Download the Code Here

A common task for system administrators is real-time performance monitoring, especially when diagnosing problems. Although you can use Microsoft Task Manager to manually monitor performance, using scripts saves time and effort. To simplify performance monitoring, I wrote two VBScript files, which you can download at Instant-Doc ID 94349.

Perf_prcss_detail.vbs. If you discover an unidentifiable process running on your system, you need to determine what the process is doing, if anything. When an application hangs, you might want to examine the process before you terminate it. You might also want to test a new version of a program to compare its performance characteristics with the previous version. Task Manager isn't designed to focus on a particular process. I wrote the Perf_prcss_detail.vbs script so that I can easily monitor one process and obtain detailed performance statistics.

The script outputs four columns and displays the following information:

  • Value of the counter at the time the script started
  • Value of the counter in the latest sample
  • Change in the counter since the script started
  • Change in the counter during the latest sample interval

Because the script outputs a column showing the change in the counter since the script first started running, you can observe changes in the counters over a long time interval. An interesting characteristic of Windows Management Instrumentation (WMI) is that you can query the performance statistics of a process after it has stopped. This feature lets you start a program, use the script to initiate monitoring, and see the statistics after the program has finished. Thus, you can, for example, determine how much CPU or I/O a batch program used.

Perf_prcss_detail.vbs also lets you easily monitor a process on another system. You don't need to start a Windows 2000 Server Terminal Services session, log on, and start Task Manager on the system you want to monitor.

When you run the Perf_prcss _detail.vbs script, it prompts you for the name of the target system (the default is the current system), the sample interval in seconds (the default is 3 seconds), and the process identifier (PID) of the process of interest (the default is 0 for _Total, or all processes). The script displays a list showing the name and PID of all the currently running processes so that you can easily identify the one you're interested in. If you specify a sample interval of 0 seconds, the script doesn't automatically generate output. You must instead press Enter to see updated statistics. This option lets you reduce the overhead that collecting performance statistics generates.

You must use CScript to run the script from a command prompt. The system on which you run the script and the target system must be running Windows Server 2003, Windows XP, or Win2K. To terminate the script, press Ctrl+C.

Perf_prcss_max.vbs. Sometimes your system experiences a heavy I/O load but you don't know which process is responsible. Task Manager doesn't easily provide this information; although Task Manager's Process view includes columns for cumulative I/O operations or bytes, the program doesn't show the corresponding deltas (i.e., changes during the last sample interval).

To determine which processes on my systems generate the most I/O, I wrote the script Perf_prcss_max.vbs. The script reports CPU and memory usage for comprehensive performance monitoring. The script also lets you easily obtain performance statistics without requiring you to use Terminal Services to run Task Manager on the system you want to monitor.

When you run the script, it prompts you for the name of the target system (the default is the current system), the sample interval in seconds (the default is 3 seconds), and the performance counter of interest (the default is CPU). If you specify a sample interval of 0 seconds, the script won't automatically generate output. You need to press Enter to see updated statistics.

You must use CScript to run Perf_prcss_max.vbs from a command prompt, and the system on which you run the script and the target system must be running Windows 2003, XP, or Win2K. To terminate the script, press Ctrl+C.

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
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...

2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...


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

Related Events Cutting Costs with Client Management

7 Ways To Get More From Your SharePoint Deployment Now

Introduction to Identity Lifecycle Manager "2"

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting 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.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement