In Chapter 2 we introduced the facility for establishing Performance Monitor as a service running on any computer. This keeps network traffic for performance monitoring to a minimum, allows unattended automatic alerting and logging, and permits you to control when log or alert data move across the network. A principal feature of this approach is that data from each computer will appear in its own log file and application event log.
The utilities for establishing the Performance Monitor service are included on the floppy disk or CD-ROM provided with this book. Let's take a quick look at how we set up the service on some computer, which we'll call the "target" computer, named \\TARGET.
First you need to determine what counters you want to set alerts on, if any, and what events you want to trigger when those alerts occur. You do this using our good old friend Performance Monitor, and selecting the target computer in the Add to Alert dialog. You may also elect to log certain objects, again pointing the Add to Log dialog at the target computer. Be sure the path that you set up for the log file exists on the target computer. Set your time interval for logging by the service, but don't start logging. You may then save your settings in a workspace settings file, which we'll call TARGET.PMW.
You'll need to copy both DATALOG.EXE and TARGET.PMW to the %SystemRoot%\System32 directory on \\TARGET. You can then use the monitor.exe utility to control the service. The monitor.exe utility is a command line application created just for this purpose. It has the following syntax:
monitor [\\computername] [command]
If \\computername is omitted, the local computer is assumed. If command is omitted, the current setup and status of the service are reported. The following list shows the commands you can use as a command in the monitor command line:
setup | Sets up the Performance Monitor service registry variables and installs the service in the Service Controller |
filename.pmw | Establishes the file as the current workspace settings file |
start | Starts the service |
stop | Stops the service |
pause | Sends a pause control to the service, and data collection is suspended |
continue | Sends a continue control to the service, and data collection is resumed |
automatic | Sets the service to start automatically when the computer starts |
manual | Sets the service to require a manual start using the Control Panel's Services applet or the monitor START command (this is the default) |
disable | Disables the service: commands like start will be ignored; reset this mode by using automatic or manual |
If you want to watch for alerts or log data to a log file automatically, you can establish the Performance Monitor as an unattended service on the computers you want to monitor. The Performance Monitor service can be set up to start automatically when the computer starts.
The Performance Monitor service, called DATALOG.EXE, always runs locally on the computer on which it is started. Alerts are watched locally on that computer, so no data needs to travel across the network. You can also set up logging on any computer running the service. The log file is usually located on the same computer. The data can remain there until you wish to scan the data using the Performance Monitor, or pull it to another computer when the network is not busy.
You can enhance your control of the service with the use of the at command. (For the at command to operate, you must first start the Schedule service using the Control Panel's Services applet.) For example suppose you only want to log data during the morning hours of peak usage. You might issue the following commands:
at \\TARGET 9:30 /date:M,T,W,Th,F "monitor START"
at \\TARGET 11:00 /date:M,T,W,Th,F "monitor STOP"
Of course you can scale this up to handle many computers instead of just one. The thought of all those computers automatically filling their disks with data just makes us giggle. Until the boss gives us the bill for a new disk drive for each one. So let's take a look at managing all this performance data. It won't really matter whether it's gathered by the Performance Monitoring Service or the actual Performance Monitor: the log file is the same, and manage it we must.