?
=?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
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