Scripts for Monitoring System Performance
A reader shares two VBScript files for automating performance monitoring.
December 10, 2006
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.
About the Author
You May Also Like