Creating performance counters
-
I realise this is a very advanced question! I have a server application which I'm trying to add performance counters to, to allow the server's performance to be monitored using standard tools, such as the System Monitor ActiveX control (most users will know this as part of the Performance management console in Administrative Tools). There's a reasonable amount of documentation on actually creating your performance counters, and I'm using a chunk of code that came with my copy of 'Programming Server-Side Applications for Windows' by Jeff Richter and Jason Clark. I've already got a number of simple counters (those using PERF_COUNTER_COUNTER and PERF_COUNTER_RAWCOUNT) running. My problem is that I've got a piece of data I want to expose and no idea how to define this counter. I'd like to be able to show the average percentage utilisation of a set of worker objects, defined as the average amount of time they were used in the sample period. The value shown should be ((current sample - last sample) / (number of objects)) / (current sample time - last sample time). Doing this allows me to simply add the duration of an operation to the counter. It doesn't look like this is possible, though, certainly with the standard counter types. The actual server is written in VB6 so I'd like to avoid 64-bit counters and timers if at all possible! I'm writing the performance counter values using a C++ DLL which the VB6 code calls into. I can divide the time elapsed by the number of objects myself, but this obviously loses accuracy, since it's an integer division. Any ideas greatly appreciated. Stability. What an interesting concept. -- Chris Maunder
-
I realise this is a very advanced question! I have a server application which I'm trying to add performance counters to, to allow the server's performance to be monitored using standard tools, such as the System Monitor ActiveX control (most users will know this as part of the Performance management console in Administrative Tools). There's a reasonable amount of documentation on actually creating your performance counters, and I'm using a chunk of code that came with my copy of 'Programming Server-Side Applications for Windows' by Jeff Richter and Jason Clark. I've already got a number of simple counters (those using PERF_COUNTER_COUNTER and PERF_COUNTER_RAWCOUNT) running. My problem is that I've got a piece of data I want to expose and no idea how to define this counter. I'd like to be able to show the average percentage utilisation of a set of worker objects, defined as the average amount of time they were used in the sample period. The value shown should be ((current sample - last sample) / (number of objects)) / (current sample time - last sample time). Doing this allows me to simply add the duration of an operation to the counter. It doesn't look like this is possible, though, certainly with the standard counter types. The actual server is written in VB6 so I'd like to avoid 64-bit counters and timers if at all possible! I'm writing the performance counter values using a C++ DLL which the VB6 code calls into. I can divide the time elapsed by the number of objects myself, but this obviously loses accuracy, since it's an integer division. Any ideas greatly appreciated. Stability. What an interesting concept. -- Chris Maunder
Have you tried breaking the calculation up into seperate lines of code and using casts to correct the data types between each operation.
Darka [Xanya]
-
I realise this is a very advanced question! I have a server application which I'm trying to add performance counters to, to allow the server's performance to be monitored using standard tools, such as the System Monitor ActiveX control (most users will know this as part of the Performance management console in Administrative Tools). There's a reasonable amount of documentation on actually creating your performance counters, and I'm using a chunk of code that came with my copy of 'Programming Server-Side Applications for Windows' by Jeff Richter and Jason Clark. I've already got a number of simple counters (those using PERF_COUNTER_COUNTER and PERF_COUNTER_RAWCOUNT) running. My problem is that I've got a piece of data I want to expose and no idea how to define this counter. I'd like to be able to show the average percentage utilisation of a set of worker objects, defined as the average amount of time they were used in the sample period. The value shown should be ((current sample - last sample) / (number of objects)) / (current sample time - last sample time). Doing this allows me to simply add the duration of an operation to the counter. It doesn't look like this is possible, though, certainly with the standard counter types. The actual server is written in VB6 so I'd like to avoid 64-bit counters and timers if at all possible! I'm writing the performance counter values using a C++ DLL which the VB6 code calls into. I can divide the time elapsed by the number of objects myself, but this obviously loses accuracy, since it's an integer division. Any ideas greatly appreciated. Stability. What an interesting concept. -- Chris Maunder
Well, in case anyone else finds this: My solution is to use a counter of type PERF_100NSEC_TIMER, which is the type used by, for example, the Processor\% Idle Time counter. I'm still supplying the time in milliseconds but have extended my DLL to multiply up the value I pass in by 10000, to convert from 1ms to 100ns intervals. I'm dividing the value I pass by the number of objects, which leads to a degree of inaccuracy for objects used very infrequently but with a long execution time (showing 300% at one point using a 1s sample period) but since I'm more interested in the long-term average, this is acceptable. Stability. What an interesting concept. -- Chris Maunder