processor monitor updated.

This commit is contained in:
Zhen Tang 2013-07-07 00:12:18 +08:00
parent 43c32b7af1
commit d3f8882e22
9 changed files with 97 additions and 5 deletions

View File

@ -35,7 +35,7 @@ double Common::GetCounterValue(const wchar_t * fullCounterPath)
return counterValue.doubleValue;
}
double Common::GetCounterValueWithSleep(const wchar_t * fullCounterPath,int idleTime)
double Common::GetCounterValueWithIdle(const wchar_t * fullCounterPath,int idleTime)
{
HQUERY hquery;
PDH_STATUS status;

View File

@ -4,7 +4,7 @@ class Common
{
public:
static double GetCounterValue(const wchar_t * fullCounterPath);
static double GetCounterValueWithSleep(const wchar_t * fullCounterPath,int idleTime);
static double GetCounterValueWithIdle(const wchar_t * fullCounterPath,int idleTime);
static list<wstring> GetInstanceName(const wchar_t * objectName);
static list<wstring> GetCounterList(const wchar_t * objectName);
};

View File

@ -15,6 +15,12 @@ class MONITOR_API Processor
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
static double GetUserTimePercent(wchar_t * instanceName, int idleTime);
static double GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
};
class MONITOR_API ProcessorInformation

View File

@ -14,18 +14,85 @@ list<wstring> Processor::GetCounterList()
}
// % Processor Time
double Processor::GetProcessorTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Processor Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % User Time
double Processor::GetUserTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% User Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % Privileged Time
double Processor::GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Privileged Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// Interrupts/sec
double Processor::GetInterruptsPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Interrupts/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % DPC Time
double Processor::GetDpcTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% DPC Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % Interrupt Time
double Processor::GetInterruptTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Interrupt Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// DPCs Queued/sec
// DPC Rate
// % Idle Time
// % C1 Time
// % C2 Time
// % C3 Time
// C1 Transitions/sec
// C2 Transitions/sec
// C3 Transitions/sec
// C3 Transitions/sec

View File

@ -9,4 +9,10 @@ class MONITOR_API Processor
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
static double GetUserTimePercent(wchar_t * instanceName, int idleTime);
static double GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
};

View File

@ -41,12 +41,13 @@ list<wstring> ProcessorInformation::GetCounterList()
// % Privileged Time
// % User Time
// % Processor Time
double ProcessorInformation::GetProcessorTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Processor Time";
double ret=Common::GetCounterValueWithSleep(fullCounterPath.c_str(),idleTime);
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}

View File

@ -15,6 +15,12 @@ class MONITOR_API Processor
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
static double GetUserTimePercent(wchar_t * instanceName, int idleTime);
static double GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
};
class MONITOR_API ProcessorInformation

View File

@ -15,6 +15,12 @@ class MONITOR_API Processor
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
static double GetProcessorTimePercent(wchar_t * instanceName, int idleTime);
static double GetUserTimePercent(wchar_t * instanceName, int idleTime);
static double GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptsPerSecond(wchar_t * instanceName, int idleTime);
static double GetDpcTimePercent(wchar_t * instanceName, int idleTime);
static double GetInterruptTimePercent(wchar_t * instanceName, int idleTime);
};
class MONITOR_API ProcessorInformation

View File

@ -16,7 +16,7 @@ int _tmain(int argc, _TCHAR* argv[])
while(1)
{
printf("%lf\n",ProcessorInformation::GetProcessorTimePercent(L"_Total",1500));
printf("%lf\n",Processor::GetInterruptTimePercent(L"_Total",1500));
}
return 0;
}