processor monitor updated.
This commit is contained in:
parent
43c32b7af1
commit
d3f8882e22
|
@ -35,7 +35,7 @@ double Common::GetCounterValue(const wchar_t * fullCounterPath)
|
||||||
return counterValue.doubleValue;
|
return counterValue.doubleValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Common::GetCounterValueWithSleep(const wchar_t * fullCounterPath,int idleTime)
|
double Common::GetCounterValueWithIdle(const wchar_t * fullCounterPath,int idleTime)
|
||||||
{
|
{
|
||||||
HQUERY hquery;
|
HQUERY hquery;
|
||||||
PDH_STATUS status;
|
PDH_STATUS status;
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Common
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static double GetCounterValue(const wchar_t * fullCounterPath);
|
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> GetInstanceName(const wchar_t * objectName);
|
||||||
static list<wstring> GetCounterList(const wchar_t * objectName);
|
static list<wstring> GetCounterList(const wchar_t * objectName);
|
||||||
};
|
};
|
|
@ -15,6 +15,12 @@ class MONITOR_API Processor
|
||||||
public:
|
public:
|
||||||
static list<wstring> GetInstances();
|
static list<wstring> GetInstances();
|
||||||
static list<wstring> GetCounterList();
|
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
|
class MONITOR_API ProcessorInformation
|
||||||
|
|
|
@ -14,18 +14,85 @@ list<wstring> Processor::GetCounterList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// % Processor Time
|
// % 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
|
// % 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
|
// % 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
|
// 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
|
// % 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
|
// % 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
|
// DPCs Queued/sec
|
||||||
|
|
||||||
// DPC Rate
|
// DPC Rate
|
||||||
|
|
||||||
// % Idle Time
|
// % Idle Time
|
||||||
|
|
||||||
// % C1 Time
|
// % C1 Time
|
||||||
|
|
||||||
// % C2 Time
|
// % C2 Time
|
||||||
|
|
||||||
// % C3 Time
|
// % C3 Time
|
||||||
|
|
||||||
// C1 Transitions/sec
|
// C1 Transitions/sec
|
||||||
|
|
||||||
// C2 Transitions/sec
|
// C2 Transitions/sec
|
||||||
|
|
||||||
// C3 Transitions/sec
|
// C3 Transitions/sec
|
|
@ -9,4 +9,10 @@ class MONITOR_API Processor
|
||||||
public:
|
public:
|
||||||
static list<wstring> GetInstances();
|
static list<wstring> GetInstances();
|
||||||
static list<wstring> GetCounterList();
|
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);
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,12 +41,13 @@ list<wstring> ProcessorInformation::GetCounterList()
|
||||||
// % Privileged Time
|
// % Privileged Time
|
||||||
// % User Time
|
// % User Time
|
||||||
|
|
||||||
|
// % Processor Time
|
||||||
double ProcessorInformation::GetProcessorTimePercent(wchar_t * instanceName, int idleTime)
|
double ProcessorInformation::GetProcessorTimePercent(wchar_t * instanceName, int idleTime)
|
||||||
{
|
{
|
||||||
wstring fullCounterPath(L"");
|
wstring fullCounterPath(L"");
|
||||||
fullCounterPath+=L"\\Processor Information(";
|
fullCounterPath+=L"\\Processor Information(";
|
||||||
fullCounterPath+=instanceName;
|
fullCounterPath+=instanceName;
|
||||||
fullCounterPath+=L")\\% Processor Time";
|
fullCounterPath+=L")\\% Processor Time";
|
||||||
double ret=Common::GetCounterValueWithSleep(fullCounterPath.c_str(),idleTime);
|
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
|
@ -15,6 +15,12 @@ class MONITOR_API Processor
|
||||||
public:
|
public:
|
||||||
static list<wstring> GetInstances();
|
static list<wstring> GetInstances();
|
||||||
static list<wstring> GetCounterList();
|
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
|
class MONITOR_API ProcessorInformation
|
||||||
|
|
|
@ -15,6 +15,12 @@ class MONITOR_API Processor
|
||||||
public:
|
public:
|
||||||
static list<wstring> GetInstances();
|
static list<wstring> GetInstances();
|
||||||
static list<wstring> GetCounterList();
|
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
|
class MONITOR_API ProcessorInformation
|
||||||
|
|
|
@ -16,7 +16,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
printf("%lf\n",ProcessorInformation::GetProcessorTimePercent(L"_Total",1500));
|
printf("%lf\n",Processor::GetInterruptTimePercent(L"_Total",1500));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue