add #id to instances with the same name
This commit is contained in:
parent
5e966d7470
commit
a3f24672c3
|
@ -96,9 +96,35 @@ list<wstring> Common::GetInstanceName(const wchar_t * objectName)
|
|||
if(status == ERROR_SUCCESS)
|
||||
{
|
||||
wchar_t * instance = instanceListBuffer;
|
||||
int count=0;
|
||||
wstring last;
|
||||
for(; *instance != 0; instance += lstrlen(instance) + 1)
|
||||
{
|
||||
ret.push_back(wstring(instance));
|
||||
if(instance==instanceListBuffer)
|
||||
{
|
||||
last=wstring(instance);
|
||||
ret.push_back(wstring(instance));
|
||||
count=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(last==wstring(instance))
|
||||
{
|
||||
count++;
|
||||
wchar_t buffer[10];
|
||||
_itow_s(count,buffer,10);
|
||||
wstring toInsert(instance);
|
||||
toInsert+=L"#";
|
||||
toInsert+=buffer;
|
||||
ret.push_back(toInsert);
|
||||
}
|
||||
else
|
||||
{
|
||||
last=wstring(instance);
|
||||
ret.push_back(wstring(instance));
|
||||
count=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,4 +92,5 @@ class MONITOR_API Process
|
|||
public:
|
||||
static list<wstring> GetInstances();
|
||||
static list<wstring> GetCounterList();
|
||||
static double Process::GetProcessId(wchar_t * instanceName);
|
||||
};
|
|
@ -11,4 +11,43 @@ list<wstring> Process::GetInstances()
|
|||
list<wstring> Process::GetCounterList()
|
||||
{
|
||||
return Common::GetCounterList(L"Process");
|
||||
}
|
||||
}
|
||||
|
||||
// % Processor Time
|
||||
// % User Time
|
||||
// % Privileged Time
|
||||
// Virtual Bytes Peak
|
||||
// Virtual Bytes
|
||||
// Page Faults/sec
|
||||
// Working Set Peak
|
||||
// Working Set
|
||||
// Page File Bytes Peak
|
||||
// Page File Bytes
|
||||
// Private Bytes
|
||||
// Thread Count
|
||||
// Priority Base
|
||||
// Elapsed Time
|
||||
// ID Process
|
||||
double Process::GetProcessId(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
|
||||
// Pool Paged Bytes
|
||||
// Pool Nonpaged Bytes
|
||||
// Handle Count
|
||||
// IO Read Operations/sec
|
||||
// IO Write Operations/sec
|
||||
// IO Data Operations/sec
|
||||
// IO Other Operations/sec
|
||||
// IO Read Bytes/sec
|
||||
// IO Write Bytes/sec
|
||||
// IO Data Bytes/sec
|
||||
// IO Other Bytes/sec
|
||||
// Working Set - Private
|
|
@ -9,4 +9,5 @@ class MONITOR_API Process
|
|||
public:
|
||||
static list<wstring> GetInstances();
|
||||
static list<wstring> GetCounterList();
|
||||
static double Process::GetProcessId(wchar_t * instanceName);
|
||||
};
|
|
@ -92,4 +92,5 @@ class MONITOR_API Process
|
|||
public:
|
||||
static list<wstring> GetInstances();
|
||||
static list<wstring> GetCounterList();
|
||||
static double Process::GetProcessId(wchar_t * instanceName);
|
||||
};
|
|
@ -92,4 +92,5 @@ class MONITOR_API Process
|
|||
public:
|
||||
static list<wstring> GetInstances();
|
||||
static list<wstring> GetCounterList();
|
||||
static double Process::GetProcessId(wchar_t * instanceName);
|
||||
};
|
|
@ -17,7 +17,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||
|
||||
while(1)
|
||||
{
|
||||
printf("%lf\n",Processor::GetC3TransitionsPerSecond(L"_Total",1500));
|
||||
printf("%lf\n",Process::GetProcessId(L"svchost#6"));
|
||||
Sleep(500);
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue