processor information monitor completed.
This commit is contained in:
parent
a3f24672c3
commit
89347b8d9d
|
@ -22,7 +22,7 @@ double Common::GetCounterValue(const wchar_t * fullCounterPath)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PDH_FMT_COUNTERVALUE counterValue;
|
PDH_FMT_COUNTERVALUE counterValue;
|
||||||
status=PdhGetFormattedCounterValue(counter,PDH_FMT_DOUBLE,NULL,&counterValue);
|
status=PdhGetFormattedCounterValue(counter,PDH_FMT_DOUBLE|PDH_FMT_NOSCALE|PDH_FMT_NOCAP100,NULL,&counterValue);
|
||||||
if(status!=ERROR_SUCCESS)
|
if(status!=ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -64,7 +64,7 @@ double Common::GetCounterValueWithIdle(const wchar_t * fullCounterPath,int idleT
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
PDH_FMT_COUNTERVALUE counterValue;
|
PDH_FMT_COUNTERVALUE counterValue;
|
||||||
status=PdhGetFormattedCounterValue(counter,PDH_FMT_DOUBLE,NULL,&counterValue);
|
status=PdhGetFormattedCounterValue(counter,PDH_FMT_DOUBLE|PDH_FMT_NOSCALE|PDH_FMT_NOCAP100,NULL,&counterValue);
|
||||||
if(status!=ERROR_SUCCESS)
|
if(status!=ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -37,6 +37,33 @@ class MONITOR_API ProcessorInformation
|
||||||
public:
|
public:
|
||||||
static list<wstring> GetInstances();
|
static list<wstring> GetInstances();
|
||||||
static list<wstring> GetCounterList();
|
static list<wstring> GetCounterList();
|
||||||
|
static double GetPerformanceLimitFlags(wchar_t * instanceName);
|
||||||
|
static double GetPerformanceLimitPercent(wchar_t * instanceName);
|
||||||
|
static double GetPrivilegedUtilityPercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorUtilityPercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorPerformancePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetIdleBreakEventsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetAverageIdleTime(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetClockInterruptsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorStateFlags(wchar_t * instanceName);
|
||||||
|
static double GetPercentageOfMaximumFrequency(wchar_t * instanceName);
|
||||||
|
static double GetProcessorFrequency(wchar_t * instanceName);
|
||||||
|
static double GetParkingStatus(wchar_t * instanceName);
|
||||||
|
static double GetPriorityTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC3TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC2TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC1TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetIdleTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetDpcRate(wchar_t * instanceName);
|
||||||
|
static double GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetUserTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
|
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,43 +14,147 @@ list<wstring> ProcessorInformation::GetCounterList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Performance Limit Flags
|
// Performance Limit Flags
|
||||||
|
double ProcessorInformation::GetPerformanceLimitFlags(wchar_t * instanceName)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\Performance Limit Flags";
|
||||||
|
double ret=Common::GetCounterValue(fullCounterPath.c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// % Performance Limit
|
// % Performance Limit
|
||||||
|
double ProcessorInformation::GetPerformanceLimitPercent(wchar_t * instanceName)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\% Performance Limit";
|
||||||
|
double ret=Common::GetCounterValue(fullCounterPath.c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// % Privileged Utility
|
// % Privileged Utility
|
||||||
|
double ProcessorInformation::GetPrivilegedUtilityPercent(wchar_t * instanceName, int idleTime)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\% Privileged Utility";
|
||||||
|
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// % Processor Utility
|
// % Processor Utility
|
||||||
|
double ProcessorInformation::GetProcessorUtilityPercent(wchar_t * instanceName, int idleTime)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\% Processor Utility";
|
||||||
|
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// % Processor Performance
|
// % Processor Performance
|
||||||
|
double ProcessorInformation::GetProcessorPerformancePercent(wchar_t * instanceName, int idleTime)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\% Processor Performance";
|
||||||
|
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Idle Break Events/sec
|
// Idle Break Events/sec
|
||||||
|
double ProcessorInformation::GetIdleBreakEventsPerSecond(wchar_t * instanceName, int idleTime)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\Idle Break Events/sec";
|
||||||
|
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Average Idle Time
|
// Average Idle Time
|
||||||
|
double ProcessorInformation::GetAverageIdleTime(wchar_t * instanceName, int idleTime)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\Average Idle Time";
|
||||||
|
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Clock Interrupts/sec
|
// Clock Interrupts/sec
|
||||||
|
double ProcessorInformation::GetClockInterruptsPerSecond(wchar_t * instanceName, int idleTime)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\Clock Interrupts/sec";
|
||||||
|
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Processor State Flags
|
// Processor State Flags
|
||||||
|
double ProcessorInformation::GetProcessorStateFlags(wchar_t * instanceName)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\Processor State Flags";
|
||||||
|
double ret=Common::GetCounterValue(fullCounterPath.c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// % of Maximum Frequency
|
// % of Maximum Frequency
|
||||||
|
double ProcessorInformation::GetPercentageOfMaximumFrequency(wchar_t * instanceName)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\% of Maximum Frequency";
|
||||||
|
double ret=Common::GetCounterValue(fullCounterPath.c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Processor Frequency
|
// Processor Frequency
|
||||||
|
double ProcessorInformation::GetProcessorFrequency(wchar_t * instanceName)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\Processor Frequency";
|
||||||
|
double ret=Common::GetCounterValue(fullCounterPath.c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Parking Status
|
// Parking Status
|
||||||
|
double ProcessorInformation::GetParkingStatus(wchar_t * instanceName)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\Parking Status";
|
||||||
|
double ret=Common::GetCounterValue(fullCounterPath.c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// % Priority Time
|
// % Priority Time
|
||||||
|
double ProcessorInformation::GetPriorityTimePercent(wchar_t * instanceName, int idleTime)
|
||||||
|
{
|
||||||
|
wstring fullCounterPath(L"");
|
||||||
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
|
fullCounterPath+=instanceName;
|
||||||
|
fullCounterPath+=L")\\% Priority Time";
|
||||||
|
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// C3 Transitions/sec
|
// C3 Transitions/sec
|
||||||
double ProcessorInformation::GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime)
|
double ProcessorInformation::GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime)
|
||||||
|
|
|
@ -9,6 +9,19 @@ class MONITOR_API ProcessorInformation
|
||||||
public:
|
public:
|
||||||
static list<wstring> GetInstances();
|
static list<wstring> GetInstances();
|
||||||
static list<wstring> GetCounterList();
|
static list<wstring> GetCounterList();
|
||||||
|
static double GetPerformanceLimitFlags(wchar_t * instanceName);
|
||||||
|
static double GetPerformanceLimitPercent(wchar_t * instanceName);
|
||||||
|
static double GetPrivilegedUtilityPercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorUtilityPercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorPerformancePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetIdleBreakEventsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetAverageIdleTime(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetClockInterruptsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorStateFlags(wchar_t * instanceName);
|
||||||
|
static double GetPercentageOfMaximumFrequency(wchar_t * instanceName);
|
||||||
|
static double GetProcessorFrequency(wchar_t * instanceName);
|
||||||
|
static double GetParkingStatus(wchar_t * instanceName);
|
||||||
|
static double GetPriorityTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
|
|
@ -37,6 +37,33 @@ class MONITOR_API ProcessorInformation
|
||||||
public:
|
public:
|
||||||
static list<wstring> GetInstances();
|
static list<wstring> GetInstances();
|
||||||
static list<wstring> GetCounterList();
|
static list<wstring> GetCounterList();
|
||||||
|
static double GetPerformanceLimitFlags(wchar_t * instanceName);
|
||||||
|
static double GetPerformanceLimitPercent(wchar_t * instanceName);
|
||||||
|
static double GetPrivilegedUtilityPercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorUtilityPercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorPerformancePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetIdleBreakEventsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetAverageIdleTime(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetClockInterruptsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorStateFlags(wchar_t * instanceName);
|
||||||
|
static double GetPercentageOfMaximumFrequency(wchar_t * instanceName);
|
||||||
|
static double GetProcessorFrequency(wchar_t * instanceName);
|
||||||
|
static double GetParkingStatus(wchar_t * instanceName);
|
||||||
|
static double GetPriorityTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC3TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC2TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC1TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetIdleTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetDpcRate(wchar_t * instanceName);
|
||||||
|
static double GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetUserTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
|
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,33 @@ class MONITOR_API ProcessorInformation
|
||||||
public:
|
public:
|
||||||
static list<wstring> GetInstances();
|
static list<wstring> GetInstances();
|
||||||
static list<wstring> GetCounterList();
|
static list<wstring> GetCounterList();
|
||||||
|
static double GetPerformanceLimitFlags(wchar_t * instanceName);
|
||||||
|
static double GetPerformanceLimitPercent(wchar_t * instanceName);
|
||||||
|
static double GetPrivilegedUtilityPercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorUtilityPercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorPerformancePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetIdleBreakEventsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetAverageIdleTime(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetClockInterruptsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetProcessorStateFlags(wchar_t * instanceName);
|
||||||
|
static double GetPercentageOfMaximumFrequency(wchar_t * instanceName);
|
||||||
|
static double GetProcessorFrequency(wchar_t * instanceName);
|
||||||
|
static double GetParkingStatus(wchar_t * instanceName);
|
||||||
|
static double GetPriorityTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC3TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC2TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetC1TimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetIdleTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetDpcRate(wchar_t * instanceName);
|
||||||
|
static double GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
|
static double GetUserTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
|
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,9 @@
|
||||||
|
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int _tmain(int argc, _TCHAR* argv[])
|
||||||
{
|
{
|
||||||
list<wstring> counterList=Process::GetCounterList();
|
|
||||||
list<wstring> instances=Process::GetInstances();
|
|
||||||
list<wstring>::iterator iter;
|
|
||||||
std::wcout.imbue(std::locale("chs"));
|
|
||||||
//for(iter=counterList.begin();iter!=counterList.end();iter++)
|
|
||||||
//{
|
|
||||||
// wcout<<(*iter).c_str()<<endl;
|
|
||||||
//}
|
|
||||||
for(iter=instances.begin();iter!=instances.end();iter++)
|
|
||||||
{
|
|
||||||
wcout<<(*iter).c_str()<<endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
printf("%lf\n",Process::GetProcessId(L"svchost#6"));
|
printf("%lf\n",ProcessorInformation::GetPriorityTimePercent(L"_Total",1000));
|
||||||
Sleep(500);
|
Sleep(500);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue