Windows performance counters application (PART4)

Windows performance counters application (PART1)

Windows performance counters application (PART2)

Windows performance counters application (PART3)

SysField.XML PerformanceCounter file specified in the log file is stored (the value of the sampling time of all required parameters and performance counters).

: File an application to store log files.

: File name of the log file.

: Specify a Boolean value

: The maximum number of records in a single log file is saved

The PerformanceCounter () sampling interval

To generate a log file every day, we need to MaxNumberRecordsInLogFile set equal to:

MaxNumberRecordsInLogFile = (the second day) / PollingSysParamsInterval

which is

If we sampled every 1 second (PollingSysParamsInterval = 1), the MaxNumberRecordsInLogFile = 86400secondi / (1 sec) = 86400

Parameter stored in the app.config we can define the structure to be included in the performance parameters and sampling performance counters (sequence).

App.config complete structure of the report is as follows:

<?xml version =“ 1.0”?>

<Start>

<ADD key=“ NodeName”value=“ false” />

<ADD key=“ CPUProcessorTime”value=“ true” />

<ADD key=“ CPUPrivilegedTime”value=“ true” />

<ADD key =“ MEMPoolNonPaged” value =“ true” />

<ADD key =“ DISKTime” value =“ true” />

<ADD key =“ HANDLECountCounter” value =“ true” />

<ADD key =“ THREADCount” value =“ true“ />

<ADD key =“ CONTENTSwitches” value =“ true” />

<ADD key =“ SYSTEMCalls” value =“ true” />

<ADD key =“ NumProcess” value =“ true” />

<ADD key =“ NetTrafficSend” value = “ true” /

The key implication is quite clear, the values ​​associated with each key is a Boolean value:

  • Value is equal to "true" represents the value of the tracking performance counter
  • Equal to "false" value indicates performance counter values ​​may be skipped  

When you compile your application, Visual Studio will automatically create a <your application name> .exe.config file named bin \ debug folder. When the application is compiled, app.config content will be automatically copied to this new profile. When an application delivered to the end user, you must deliver exe and named <your application name> .exe.config new configuration file, instead of app.config. Users can modify the data in <your application name> .exe.config after the restart, files and applications to read data from the configuration file. Change in the app.config (key, value) of the print order may be determined in other orders, and performance counters to the console log file.

The project uses public class called SysParams to store all performance counters.

public  class SysParams

{

public string NodeName { get; set; }

public float CPUProcessorTime { get; set; }

public float CPUPrivilegedTime { get; set; }

public float CPUInterruptTime { get; set; }

public float CPUDPCTime { get; set; }

public float MEMAvailable { get; set; }

public float MEMCommited { get; set; }

public float MEMCommitLimit { get; set; }

public float MEMCommitedPerc { get; set; }

public float MEMPoolPaged { get; set; }

public float MEMPoolNonPaged { get; set; }

public float MEMCached { get; set; }

public float PageFile { get; set; }

public float ProcessorQueueLengh { get; set; }

public float DISCQueueLengh { get; set; }

public float DISKRead {get; set;}

public float DISKWrite { get; set; }

public float DISKAverageTimeRead { get; set; }

public float DISKAverageTimeWrite { get; set; }

public float DISKTime { get; set; }

public float HANDLECountCounter { get; set; }

public float THREADCount { get; set; }

public int CONTENTSwitches { get; set; }

public int SYSTEMCalls { get; set; }

public float NetTrafficSend { get; set; }

public float NetTrafficReceive { get; set; }

public DateTime SamplingTime { get; set; }

 

private PerformanceCounter cpuProcessorTime = new PerformanceCounter("Processor", "% Processor Time", "_Total");

private PerformanceCounter cpuPrivilegedTime = new PerformanceCounter("Processor", "% Privileged Time", "_Total");

private PerformanceCounter cpuInterruptTime = new PerformanceCounter("Processor", "% Interrupt Time", "_Total");

private PerformanceCounter cpuDPCTime = new PerformanceCounter("Processor", "% DPC Time", "_Total");

private PerformanceCounter memAvailable = new PerformanceCounter("Memory", "Available MBytes", null);

private PerformanceCounter memCommited = new PerformanceCounter("Memory", "Committed Bytes", null);

private PerformanceCounter memCommitLimit = new PerformanceCounter("Memory", "Commit Limit", null);

private PerformanceCounter memCommitedPerc = new PerformanceCounter("Memory", "% Committed Bytes In Use", null);

private PerformanceCounter memPollPaged = new PerformanceCounter("Memory", "Pool Paged Bytes", null);

private PerformanceCounter memPollNonPaged = new PerformanceCounter("Memory", "Pool Nonpaged Bytes", null);

private PerformanceCounter memCached = new PerformanceCounter("Memory", "Cache Bytes", null);

private PerformanceCounter pageFile = new PerformanceCounter("Paging File", "% Usage", "_Total");

private PerformanceCounter processorQueueLengh = new PerformanceCounter("System", "Processor Queue Length", null);

private PerformanceCounter diskQueueLengh = new PerformanceCounter("PhysicalDisk", "Avg. Disk Queue Length", "_Total");

private PerformanceCounter diskRead = new PerformanceCounter("PhysicalDisk", "Disk Read Bytes/sec", "_Total");

private PerformanceCounter diskWrite = new PerformanceCounter("PhysicalDisk", "Disk Write Bytes/sec", "_Total");

private PerformanceCounter diskAverageTimeRead = new PerformanceCounter("PhysicalDisk", "Avg. Disk sec/Read", "_Total");

private PerformanceCounter diskAverageTimeWrite = new PerformanceCounter("PhysicalDisk", "Avg. Disk sec/Write", "_Total");

private PerformanceCounter diskTime = new PerformanceCounter("PhysicalDisk", "% Disk Time", "_Total");

private PerformanceCounter handleCountCounter = new PerformanceCounter("Process", "Handle Count", "_Total");

private PerformanceCounter threadCount = new PerformanceCounter("Process", "Thread Count", "_Total");

private PerformanceCounter contentSwitches = new PerformanceCounter("System", "Context Switches/sec", null);

private PerformanceCounter systemCalls = new PerformanceCounter("System", "System Calls/sec", null);

private PerformanceCounterCategory performanceNetCounterCategory;

private PerformanceCounter[] trafficSentCounters;

private PerformanceCounter[] trafficReceivedCounters;

private string[] interfaces = null;

public void initNetCounters()

Windows performance counters application (PART1)

Windows performance counters application (PART2)

Windows performance counters application (PART3)

Windows performance counters application (PART5)

Guess you like

Origin blog.51cto.com/djclouds/2475521