윈도우 성능 카운터 응용 프로그램 (5 부)

윈도우 성능 카운터 응용 프로그램 (PART1)

윈도우 성능 카운터 응용 프로그램 (PART2)

윈도우 성능 카운터 응용 프로그램 (PART3)

윈도우 성능 카운터 응용 프로그램 (PART4)

{ 

// PerformanceCounter (범주, CounterName, 인스턴스 이름)

performanceNetCounterCategory = newPerformanceCounterCategory ( "네트워크 인터페이스");

인터페이스 performanceNetCounterCategory.GetInstanceNames = ();

INT 길이 = interfaces.Length;

경우 (길이> 0)

{

trafficSentCounters = newPerformanceCounter [길이];

trafficReceivedCounters = newPerformanceCounter [길이];

}

에 대해 INT (I = 0; I <길이; 나는 ++)

{

// 새로운 읽기 전용 인스턴스 PerformanceCounter 클래스를 초기화합니다.

// 첫 번째 인수 : "categoryName이"- 성능 카운터 성능 카운터 범주 (성능 개체)와 관련된 이름을 입력합니다.

// 두 번째 인수 : "CounterName"- 성능 카운터의 이름입니다.

// 세 번째 매개 변수 : "여기서 instanceName"- 성능 카운터 클래스 인스턴스의 이름, 빈 문자열 경우 ( "")에 대한 단일 인스턴스를 포함하는 범주.

trafficReceivedCounters [I] = 새로운 PerformanceCounter ( "네트워크 인터페이스", "보낸 바이트 / 초"인터페이스 [I]); 

trafficSentCounters [I] = 새로운 PerformanceCounter ( "네트워크 인터페이스", "보낸 바이트 / 초"인터페이스 [I]);

}

 

//网络接口所有名称的列表

대 (나는하는 int = 0; I <길이; I ++)

{

Console.WriteLine ( "이름 netInterface : {0}"performanceNetCounterCategory.GetInstanceNames () [I]);

}

}

공개 무효 getProcessorCpuTime ()

{

플로트 cpuProcessorTime.NextValue TMP = ();

CPUProcessorTime = (플로트) (Math.Round ((더블) TMP, 1));

// Environment.ProcessorCount :返回内核总数

}

공공 무효 getCpuPrivilegedTime ()

{

플로트의 tmp = cpuPrivilegedTime.NextValue ();

CPUPrivilegedTime = (플로트) (Math.Round ((더블) TMP, 1));

}

공개 무효 getCpuinterruptTime ()

{

플로트 cpuInterruptTime.NextValue TMP = ();

CPUInterruptTime = (플로트) (Math.Round ((더블) TMP, 1));

}

공개 무효 getcpuDPCTime ()

{

플로트 cpuDPCTime.NextValue TMP = ();

CPUDPCTime = (플로트) (Math.Round ((더블) TMP, 1));

}

공개 무효 getPageFile ()

{

페이지 파일 pageFile.NextValue = ();

}

공개 무효 getProcessorQueueLengh ()

{

ProcessorQueueLengh processorQueueLengh.NextValue = ();

}

공개 무효 getMemAvailable ()

{

MEMAvailable memAvailable.NextValue = ();

}

공개 무효 getMemCommited ()

{

MEMCommited memCommited.NextValue = () / (1024 * 1024);

}

공공 무효 getMemCommitLimit ()

{

MEMCommitLimit memCommitLimit.NextValue = () / (1024 * 1024);

}

공개 무효 getMemCommitedPerc ()

{

플로트 memCommitedPerc.NextValue TMP = ();

// 반환 메모리의 값이 커밋 제한

MEMCommitedPerc = (플로트) (Math.Round ((더블) TMP, 1)); 

}

공개 무효 getMemPoolPaged ()

{

플로트 memPollPaged.NextValue TMP = () / (1024 * 1024);

MEMPoolPaged = (플로트) (Math.Round ((더블) TMP, 1));

}

공개 무효 getMemPoolNonPaged ()

{

플로트 memPollNonPaged.NextValue TMP = () / (1024 * 1024);

MEMPoolNonPaged = (플로트) (Math.Round ((더블) TMP, 1));

}

공공 무효 getMemCachedBytes ()

{

// 캐시 된 메모리의 MB의 값을 반환

MEMCached = memCached.NextValue() / (1024 * 1024); 

}

public void getDiskQueueLengh()

{

DISCQueueLengh = diskQueueLengh.NextValue();

}

public void getDiskRead()

{

float tmp=diskRead.NextValue()/1024;

DISKRead = (float)(Math.Round((double)tmp,1));

}

public void getDiskWrite()

{

float tmp=diskWrite.NextValue()/1024;

DISKWrite = (float)(Math.Round((double)tmp,1)); // round 1 digit decimal

}

public void getDiskAverageTimeRead()

{

float tmp = diskAverageTimeRead.NextValue() * 1000;

DISKAverageTimeRead = (float)(Math.Round((double)tmp, 1)); // round 1 digit decimal

}

public void getDiskAverageTimeWrite()

{

float tmp = diskAverageTimeWrite.NextValue()*1000;

DISKAverageTimeWrite = (float)(Math.Round((double)tmp, 1)); // round 1 digit decimal

}

public void getDiskTime()

{

float tmp = diskTime.NextValue();

DISKTime = (float)(Math.Round((double)tmp, 1));

}

public void getHandleCountCounter()

{

HANDLECountCounter = handleCountCounter.NextValue();

}

public void getThreadCount()

{

THREADCount = threadCount.NextValue();

}

public void getContentSwitches()

{

CONTENTSwitches = (int)Math.Ceiling(contentSwitches.NextValue());

}

public void getsystemCalls()

{

SYSTEMCalls = (int)Math.Ceiling(systemCalls.NextValue());

}

public void getCurretTrafficSent()

{

int length = interfaces.Length;

float sendSum = 0.0F;

for (int i = 0; i < length; i++)

{

sendSum += trafficSentCounters[i].NextValue();

}

float tmp = 8 * (sendSum / 1024);

NetTrafficSend = (float)(Math.Round((double)tmp, 1));

}

public void getCurretTrafficReceived()

{

int length = interfaces.Length;

float receiveSum = 0.0F;

for (int i = 0; i < length; i++)

{

receiveSum += trafficReceivedCounters[i].NextValue();

}

float tmp = 8 * (receiveSum / 1024);

NetTrafficReceive = (float)(Math.Round((double)tmp, 1));

}

public void getSampleTime()

{

SamplingTime =DateTime.Now;

}

}

Windows性能计数器应用(PART1)

Windows性能计数器应用(PART2)

Windows性能计数器应用(PART3)

Windows性能计数器应用(PART4)

Windows性能计数器应用(PART6)

추천

출처blog.51cto.com/djclouds/2475534