bench4q/Bench4Q-Monitor/WindowsMonitor/Monitor/Process.cpp

323 lines
9.0 KiB
C++
Raw Permalink Normal View History

2013-07-07 13:02:33 +08:00
#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");
}
// % Processor Time
2013-07-08 12:17:14 +08:00
double Process::GetProcessorTimePercent(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Processor Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % User Time
2013-07-08 12:17:14 +08:00
double Process::GetUserTimePercent(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% User Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// % Privileged Time
2013-07-08 12:17:14 +08:00
double Process::GetPrivilegedTimePercent(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\% Privileged Time";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// Virtual Bytes Peak
2013-07-08 12:17:14 +08:00
double Process::GetVirtualBytesPeak(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Virtual Bytes Peak";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Virtual Bytes
2013-07-08 12:17:14 +08:00
double Process::GetVirtualBytes(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Virtual Bytes";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Page Faults/sec
2013-07-08 12:17:14 +08:00
double Process::GetPageFaultsPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Page Faults/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// Working Set Peak
2013-07-08 12:17:14 +08:00
double Process::GetWorkingSetPeak(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Working Set Peak";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Working Set
2013-07-08 12:17:14 +08:00
double Process::GetWorkingSet(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Working Set";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Page File Bytes Peak
2013-07-08 12:17:14 +08:00
double Process::GetPageFileBytesPeak(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Page File Bytes Peak";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Page File Bytes
2013-07-08 12:17:14 +08:00
double Process::GetPageFileBytes(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Page File Bytes";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Private Bytes
2013-07-08 12:17:14 +08:00
double Process::GetPrivateBytes(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Private Bytes";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Thread Count
2013-07-08 12:17:14 +08:00
double Process::GetThreadCount(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Thread Count";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Priority Base
2013-07-08 12:17:14 +08:00
double Process::GetPriorityBase(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Priority Base";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Elapsed Time
2013-07-08 12:17:14 +08:00
double Process::GetElapsedTime(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Elapsed Time";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// ID Process
2013-07-07 19:02:56 +08:00
double Process::GetProcessId(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\ID Process";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Creating Process ID
2013-07-08 12:17:14 +08:00
double Process::GetCreatingProcessId(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Creating Process ID";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Pool Paged Bytes
2013-07-08 12:17:14 +08:00
double Process::GetPoolPagedBytes(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Pool Paged Bytes";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Pool Nonpaged Bytes
2013-07-08 12:17:14 +08:00
double Process::GetPoolNonpagedBytes(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Pool Nonpaged Bytes";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// Handle Count
2013-07-08 12:17:14 +08:00
double Process::GetHandleCount(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Handle Count";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}
// IO Read Operations/sec
2013-07-08 12:17:14 +08:00
double Process::GetIOReadOperationsPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\IO Read Operations/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// IO Write Operations/sec
2013-07-08 12:17:14 +08:00
double Process::GetIOWriteOperationsPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\IO Write Operations/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// IO Data Operations/sec
2013-07-08 12:17:14 +08:00
double Process::GetIODataOperationsPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\IO Data Operations/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// IO Other Operations/sec
2013-07-08 12:17:14 +08:00
double Process::GetIOOtherOperationsPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\IO Other Operations/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// IO Read Bytes/sec
2013-07-08 12:17:14 +08:00
double Process::GetIOReadBytesPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\IO Read Bytes/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// IO Write Bytes/sec
2013-07-08 12:17:14 +08:00
double Process::GetIOWriteBytesPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\IO Write Bytes/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// IO Data Bytes/sec
2013-07-08 12:17:14 +08:00
double Process::GetIODataBytesPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\IO Data Bytes/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// IO Other Bytes/sec
2013-07-08 12:17:14 +08:00
double Process::GetIOOtherBytesPerSecond(const wchar_t * instanceName, int idleTime)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\IO Other Bytes/sec";
double ret=Common::GetCounterValueWithIdle(fullCounterPath.c_str(),idleTime);
return ret;
}
// Working Set - Private
double Process::GetPrivateWorkingSet(const wchar_t * instanceName)
{
wstring fullCounterPath(L"");
fullCounterPath+=L"\\Process(";
fullCounterPath+=instanceName;
fullCounterPath+=L")\\Working Set - Private";
double ret=Common::GetCounterValue(fullCounterPath.c_str());
return ret;
}