Measuring Foreign Computers

If you are providing an extended object that is returning data from a non-Windows NT computer (as shown in Figure 13.2), there are a few additional considerations.

Figure 13.2 Collecting performance data from a non-Windows NT computer

Unlike other applications with extended object types, you will not know at Open time what computers you have been asked to monitor. This will only become known to you at Collection time when you extract the name of the computer following the keyword "Foreign" in the lpwszValue parameter. After you extract the computer name, you should look up in a table whether you have opened communication with that computer. Please do not reconnect to the computer on every data collection, or you will render Performance Monitor's speed glacial. If you have never connected with that computer and you need to before you request data, connect, and then store the computer's "handle" or id in your own system lookup table. Next time data is requested you'll find its handle in the table and shoot off the request for data straight away.

Once you get the data, you will have to construct a PERF_DATA_BLOCK as the first thing in *lppData. This is because you are the computer returning data in this case, and you must provide the required information such as the time at the system you are measuring, and so on. If the system you are measuring is not courteous enough to give it to you, you can fake this stuff out any way you like. You should use values from the local system for time and counter frequency if they are not provided remotely. You may need to use the PERF_OBJECT_TYPE.PerfTime and .PerfFreq for some counters as well. Do this if they use a different time base and if the remote system time is unknown so that you have to use the local times in the PERF_DATA_BLOCK. This may take a bit of thought, but usually something can be worked out. Hey, that's why they pay you the big bucks!

The remainder of your response to the Collect function is just like that for other applications. You may return multiple objects, of course.

There is nothing that exploits the real power of Windows NT Performance Monitor more than retrieving and displaying statistics from foreign computers. Your work will be richly rewarded. Well, we can hope.