Why are my counters returning negative values?
This document (7010545) is provided subject to the disclaimer at the end of this document.
One point to note is that when we get a return type of PDH_CALC_NEGATIVE_DENOMINATOR then it is to be understood that the present raw counter value is subtracted from the previous raw counter value and a negative result was detected. API’s such as PdhFormatFromRawValue, PdhGetFormattedCounterValue those try to format the raw counter values usually need to calculate the denominator. For example the % processor time performance counter is the percentage of time that the processor is running a non-Idle thread. The calculation is done as follows:
When the application calls the PdhGetFormattedCounterValue PDH function, the calculation shown above is performed to calculate the % Processor Time. Since there is a requirement to calculate the denominator (Y1 – Y0) so if a negative denominator is detected the API PdhGetFormattedCounterValue will return PDH_CALC_NEGATIVE_DENOMINATOR.
If the function PdhGetFormattedCounterValue() fails, the return value is a system error code or a PDH error code. In case of an error, the following are *possible* values returned by PdhGetFormattedCounterValue():
• PDH_INVALID_HANDLE ERROR
• PDH_INVALID_ARGUMENT ERROR
• PDH_INVALID_DATA ERROR
This means there is a possibility that you might get a return value other than PDH_INVALID_ARGUMENT, PDH_INVALID_DATA or PDH_INVALID_HANDLE, and the return values are stated at PDH error code.
The return values like PDH_CALC_NEGATIVE_DENOMINATOR can occur because of either bug in the provider or overflow of values in data storage. In these situations, you have an option to ignore this return value and retry a bit later like 1 second to get the new values. This is not a fatal error that application can’t continue correctly, like INVALID_HANDLE or INVALID_DATA.
This Support Knowledgebase provides a valuable tool for NetIQ/Novell/SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:7010545
- Creation Date:01-AUG-12
- Modified Date:06-JUN-13
Did this document solve your problem? Provide Feedback