AspQPerfCounters Component - free
Last updated: 02/23/99, Initial Release
Do you currently monitor the activity of IIS with Performance Monitor? No? You should start to as you can gather really interesting information about IIS and ASP (see article at 15 Seconds)! Though Performance Monitor is really cool, it has one disadvantage - it is quite hard to get readings of the performance counters across the Net.
This is where the AspQPerfCounters component is stepping in by providing an easy interface for retrieving performance counters. It is implemented as Automation component, not using ASP intrinsic objects, therefore allowing you to use it in any application (Excel sample is included). Note that it works only on Windows NT, however, one nice feature is that if you have a standard setup, it also works under the IUSR account - no special security permissions are needed.
Related Articles 15 Seconds: Debugging Production Active Server Pages in IIS 4.0
Working With The Component
Below you can find an example how you usually call into the component:
Set objQPerfCnt = CreateObject("Softwing.AspQPerfCounters") bResult = objQPerfCnt.OpenQuery() bResult = objQPerfCnt.AddCounter("\\.\Active Server Pages\Errors During Script Runtime") bResult = objQPerfCnt.CollectQueryData() varResult = objQPerfCnt.GetFormattedCounterVal(_ "\\.\Active Server Pages\Errors During Script Runtime", 0) bResult = objQPerfCnt.CloseQuery()
After creating the object, you have to open a performance query. After this has been done, you can go about adding as many counters to the query as you like. The syntax is \\computername\object\counter - with the local computer being represented by a simple dot (\\.\). If you want to find out about the objects and counters, simply open Windows NT Performance Monitor from the Administrative Tools menu and open the Add To Chart dialog - there you can find all necessary information (see Figure).
After having added all counters, you call CollectQueryData to get the data for the performance counters. Next, use GetFormattedCounterVal to retrieve the value formatted as long (this is the only numerical format currently supported - the second parameter is reserved for this purpose). When you are done, call CloseQuery.
Note that you can call CollectQueryData multiple times to get snapshots of performance counters.
Monitoring ASP Error Counters
This example monitors the performance counters that are proposed in the 15 Seconds article:
<% @LANGUAGE=VBSCRIPT %>
Before using the component you have to register it using the regsvr32 utility: regsvr32 aspperfc.dll.
There are two possible errors you might receive when registering the component: 0x0000007e and 0x0000007f. These are related to the fact that the component relies on a helper dll (pdh.dll), that is part of the Platform SDK but not installed by default with Windows NT. The first error occurs if pdh.dll is not installed on your system at all, and the 7f error occurs if you have a version that is too old.
If you encounter this problem, then download pdh.dll (45KB) and copy it to the winnt\system32 directory and then re-register the component.
Download (size is approx. 71KB)
If you do have any questions, please feel free to send mail to Christoph Wille.
All content and images on this site are copyright. Reuse (even parts) needs our written consent.