processor information monitor updated.

This commit is contained in:
Zhen Tang 2013-07-07 13:02:33 +08:00
parent d40dcc35f8
commit 5e966d7470
10 changed files with 240 additions and 6 deletions

View File

@ -418,6 +418,7 @@
<ClInclude Include="MonitorApi.h" />
<ClInclude Include="NetworkInterface.h" />
<ClInclude Include="PhysicalDisk.h" />
<ClInclude Include="Process.h" />
<ClInclude Include="Processor.h" />
<ClInclude Include="ProcessorInformation.h" />
<ClInclude Include="stdafx.h" />
@ -469,6 +470,7 @@
<ClCompile Include="Memory.cpp" />
<ClCompile Include="NetworkInterface.cpp" />
<ClCompile Include="PhysicalDisk.cpp" />
<ClCompile Include="Process.cpp" />
<ClCompile Include="Processor.cpp" />
<ClCompile Include="ProcessorInformation.cpp" />
<ClCompile Include="stdafx.cpp">

View File

@ -54,6 +54,9 @@
<ClInclude Include="LogicalDisk.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Process.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@ -92,5 +95,8 @@
<ClCompile Include="LogicalDisk.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Process.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -82,6 +82,13 @@ public:
class MONITOR_API LogicalDisk
{
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
};
class MONITOR_API Process
{
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();

View File

@ -0,0 +1,14 @@
#include "stdafx.h"
#include "Monitor.h"
#include "Common.h"
#include "Process.h"
list<wstring> Process::GetInstances()
{
return Common::GetInstanceName(L"Process");
}
list<wstring> Process::GetCounterList()
{
return Common::GetCounterList(L"Process");
}

View File

@ -0,0 +1,12 @@
#pragma once
#include "Monitor.h"
#include <list>
#include <string>
using namespace std;
class MONITOR_API Process
{
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
};

View File

@ -14,32 +14,197 @@ list<wstring> ProcessorInformation::GetCounterList()
}
// Performance Limit Flags
// % Performance Limit
// % Privileged Utility
// % Processor Utility
// % Processor Performance
// Idle Break Events/sec
// Average Idle Time
// Clock Interrupts/sec
// Processor State Flags
// % of Maximum Frequency
// Processor Frequency
// Parking Status
// % Priority Time
// C3 Transitions/sec
double ProcessorInformation::GetC3TransitionsPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\C3 Transitions/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// C2 Transitions/sec
double ProcessorInformation::GetC2TransitionsPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\C2 Transitions/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// C1 Transitions/sec
double ProcessorInformation::GetC1TransitionsPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\C1 Transitions/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % C3 Time
double ProcessorInformation::GetC3TimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% C3 Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % C2 Time
double ProcessorInformation::GetC2TimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% C2 Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % C1 Time
double ProcessorInformation::GetC1TimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% C1 Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % Idle Time
double ProcessorInformation::GetIdleTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Idle Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// DPC Rate
double ProcessorInformation::GetDpcRate(wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\DPC Rate";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// DPCs Queued/sec
double ProcessorInformation::GetDpcsQueuedPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\DPCs Queued/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % Interrupt Time
double ProcessorInformation::GetInterruptTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Interrupt Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % DPC Time
double ProcessorInformation::GetDpcTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% DPC Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// Interrupts/sec
double ProcessorInformation::GetInterruptsPerSecond(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Interrupts/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % Privileged Time
double ProcessorInformation::GetPrivilegedTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Privileged Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % User Time
double ProcessorInformation::GetUserTimePercent(wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Processor Information(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% User Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % Processor Time
double ProcessorInformation::GetProcessorTimePercent(wchar_t * instanceName, int idleTime)

View File

@ -9,5 +9,19 @@ class MONITOR_API ProcessorInformation
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
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);
};

View File

@ -82,6 +82,13 @@ public:
class MONITOR_API LogicalDisk
{
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
};
class MONITOR_API Process
{
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();

View File

@ -82,6 +82,13 @@ public:
class MONITOR_API LogicalDisk
{
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();
};
class MONITOR_API Process
{
public:
static list<wstring> GetInstances();
static list<wstring> GetCounterList();

View File

@ -2,14 +2,14 @@
int _tmain(int argc, _TCHAR* argv[])
{
list<wstring> counterList=LogicalDisk::GetCounterList();
list<wstring> instances=LogicalDisk::GetInstances();
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=counterList.begin();iter!=counterList.end();iter++)
//{
// wcout<<(*iter).c_str()<<endl;
//}
for(iter=instances.begin();iter!=instances.end();iter++)
{
wcout<<(*iter).c_str()<<endl;