PercentIdleTime problem on _Total instance

  • Thread starter =?ISO-8859-1?Q?DETOURNIERE_Fran=E7ois-Xavier?=
  • Start date
?

=?ISO-8859-1?Q?DETOURNIERE_Fran=E7ois-Xavier?=

Hi,

I have a strange behaviour using WMI to get PercentIdleTime information
from Win32_PerfRawData_PerfOS_Processor.

The Idle value is correct for all processors but is not retrieved for
"_Total" instance.

I have the following code (return checks have been removed to reduce
code size but calls always returns a SUCCESS) - nb_cpus contains the
number of CPUs of the system :

-----------------------------------------------------------------------
IEnumWbemClassObject* pEnumerator = NULL;
pSvc->ExecQuery(bstr_t("WQL"),
bstr_t("SELECT * FROM
Win32_PerfRawData_PerfOS_Processor"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);

IWbemClassObject *pclsObj;
VARIANT vtProp;
VariantInit(&vtProp);
int nCtr = 0;
while (nCtr <= nb_cpus) {
pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
pclsObj->Get(L"PercentPrivilegedTime", 0, &vtProp, 0, 0);
printf("System : %u\n", _wtol(vtProp.bstrVal));
VariantClear(&vtProp);

pclsObj->Get(L"PercentIdleTime", 0, &vtProp, 0, 0);
printf("Idle : %u \n", _wtol(vtProp.bstrVal));
VariantClear(&vtProp);
nCtr++;
}
-----------------------------------------------------------------------

So, in this example, the variant is not modified when calling "Get" on
"PercentIdleTime" for "_Total" instance ==> the variant for
"PercentIdleTime" of "_Total" instance will contains
"PercentPrivilegedTime" of "_Total" instance.
To be a bit clearer, this program returns :
System : 582256554
Idle : 2412260904
System : 2672932422
Idle : 4253136928
System : 1627594488 <=====
Idle : 1627594488 <=====

Does anybody have an idea of the possible cause of this problem ?

Thanks in Advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top