2015-12-14

Windows PerfCounters and Powershell - Network and Contention perf data

In previous blog, I covered DISK/IO counters. This blog will briefly touch on Network, Threading and Contention.

Other counters:


Network I/O

COUNTER: Network Interface\Bytes Total/sec
TYPE: Instantaneous
USAGE:
#Get Instances
PS > (New-Object Diagnostics.PerformanceCounterCategory("Network Interface")).GetInstanceNames("")

Intel[R] Centrino[R] Advanced-N 6205
Microsoft Virtual WiFi Miniport Adapter _2
Microsoft Virtual WiFi Miniport Adapter
Intel[R] 82579LM Gigabit Network Connection

PS > New-Object Diagnostics.PerformanceCounter("Network Interface",
"Bytes Total/sec", "Intel[R] 82579LM Gigabit Network Connection")

CategoryName     : Network Interface
CounterHelp      : Bytes Total/sec is the rate at which bytes are sent and received over each network adapter,
including framing characters. Network Interface\Bytes Total/sec is a sum of Network Interface\Bytes Received/sec
and Network Interface\Bytes Sent/sec.
CounterName      : Bytes Total/sec
CounterType      : RateOfCountsPerSecond64
InstanceLifetime : Global
InstanceName     : Intel[R] 82579LM Gigabit Network Connection
ReadOnly         : True
MachineName      : .
RawValue         : 0
Site             : 
Container        : 

PS > (New-Object Diagnostics.PerformanceCounter("Network Interface",
"Bytes Total/sec", "Intel[R] 82579LM Gigabit Network Connection")).NextValue("")
0

MEANING:This counter indicates the rate at which bytes are sent and received over each network adapter. It helps you know whether the traffic at your network adapter is saturated and if you need to add another network adapter. How quickly you can identify a problem depends on the type of network you have as well as whether you share bandwidth with other applications.
THRESHOLD:Sustained values of more than 80 percent of network bandwidth.

COUNTER: Network Interface\Bytes Received/sec
TYPE: Instantaneous
USAGE: See above.
MEANING:This counter indicates the rate at which bytes are received over each network adapter. You can calculate the rate of incoming data as a part of total bandwidth. This will help you know that you need to optimize on the incoming data from the client or that you need to add another network adapter to handle the incoming traffic.
THRESHOLD:No specific value.

COUNTER: Network Interface\Bytes Sent/sec
TYPE: Instantaneous
USAGE: See above.
MEANING:This counter indicates the rate at which bytes are sent over each network adapter. You can calculate the rate of incoming data as a part of total bandwidth. This will help you know that you need to optimize on the data being sent to the client or you need to add another network adapter to handle the outbound traffic.
THRESHOLD:No specific value.


Threading and Contention

COUNTER: .NET CLR LocksAndThreads\Contention Rate / sec
TYPE: Instantaneous
USAGE:
#Get Instances
PS > (New-Object Diagnostics.PerformanceCounterCategory(".NET CLR LocksAndThreads")).GetInstanceNames("")

_Global_
powershell_ise
PresentationFontCache
dataserv
pcee4

PS > (New-Object Diagnostics.PerformanceCounter(".NET CLR LocksAndThreads",
"Contention Rate / sec", "_Global_")).NextSample("")

RawValue         : 310
BaseValue        : 0
SystemFrequency  : 2533369
CounterFrequency : 0
CounterTimeStamp : 0
TimeStamp        : 47774751876
TimeStamp100nSec : 130927572465737721
CounterType      : RateOfCountsPerSecond32

PS > (New-Object Diagnostics.PerformanceCounter(".NET CLR LocksAndThreads",
"Contention Rate / sec", "_Global_")).NextValue("")
0

PS > (New-Object Diagnostics.PerformanceCounter(".NET CLR LocksAndThreads",
"Contention Rate / sec", "powershell_ise")).NextValue("")
0

MEANING:This counter displays the rate at which the runtime attempts to acquire a managed lock but without a success. Sustained non-zero values may be a cause of concern. You may want to run dedicated tests for a particular piece of code to identify the contention rate for the particular code path.
THRESHOLD:No specific value.

COUNTER: .NET CLR LocksAndThreads\Current Queue Length
TYPE: Instantaneous
USAGE: See above.
MEANING:This counter displays the last recorded number of threads currently waiting to acquire a *managed* lock in an application. You may want to run dedicated tests for a particular piece of code to identify the average queue length for the particular code path. This helps you identify inefficient synchronization mechanisms.
THRESHOLD:No specific value.

COUNTER: Thread\% Processor Time
TYPE: Instantaneous
USAGE:
PS > Get-CimInstance win32_perfformatteddata_perfproc_thread | Select IDProcess, PercentProcessorTime |
Sort PercentProcessorTime -Descending | Group -Property PercentProcessorTime |
Select -ExpandProperty Group | Select -First 5

IDProcess                           PercentProcessorTime
---------                           --------------------
        0                                            100
     3820                                             96
        0                                             84
        0                                             84
        0                                             46
MEANING:This counter gives you the idea as to which thread is actually taking the maximum processor time. If you see idle CPU and low throughput, threads could be waiting or deadlocked. You can take a stack dump of the process and compare the thread IDs from test data with the dump information to identify threads that are waiting or blocked. Or examine Thread State and Thread Wait Reason counters.
THRESHOLD:No specific value.


PS > Get-CimInstance win32_perfformatteddata_perfproc_thread | Select -First 1 | FL *
Caption               : 
Description           : 
Name                  : Idle/0
Frequency_Object      : 
Frequency_PerfTime    : 
Frequency_Sys100NS    : 
Timestamp_Object      : 
Timestamp_PerfTime    : 
Timestamp_Sys100NS    : 
ContextSwitchesPersec : 0
ElapsedTime           : 13092759167
IDProcess             : 0
IDThread              : 0
PercentPrivilegedTime : 0
PercentProcessorTime  : 0
PercentUserTime       : 0
PriorityBase          : 0
PriorityCurrent       : 0
StartAddress          : 59492592
ThreadState           : 2
ThreadWaitReason      : 0
PSComputerName        : 
CimClass              : root/cimv2:Win32_PerfFormattedData_PerfProc_Thread
CimInstanceProperties : {Caption, Description, Name, Frequency_Object...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties


PS > (New-Object Diagnostics.PerformanceCounterCategory("Thread")).GetCounters("") | 
  Select CounterName | Sort CounterName

CounterName
-----------
% Privileged Time
% Processor Time
% User Time
Context Switches/sec
Elapsed Time
ID Process
ID Thread
Priority Base
Priority Current
Start Address
ThreadState
Thread Wait Reason

PS > (New-Object Diagnostics.PerformanceCounterCategory(".NET CLR LocksAndThreads")).GetCounters("") |
  Select CounterName | Sort CounterName

CounterName
-----------
# of current logical Threads
# of current physical Threads
# of current recognized threads
# of total recognized threads
Contention Rate / sec
Current Queue Length
Queue Length / sec
Queue Length Peak
rate of recognized threads / sec
Total # of Contentions


Next blog will be the last in the Windows PerfCounters series where I will put all of this to work writing Top script for Windows.

In this series:
BLOG 1: PerfCounters infrastructure
BLOG 2: PerfCounters Raw vs. Formatted values
BLOG 3: PerfCounters, fetching the values
BLOG 4: PerfCounters, CPU perf data
BLOG 5: PerfCounters, Memory perf data
BLOG 6: PerfCounters, Disk/IO perf data
BLOG 7: PerfCounters, Network and Contention perf data

No comments:

Post a Comment