System Context Switches per Second Windows Server 2016 and above

Microsoft.Windows.Server.10.0.OperatingSystem.SystemContextSwitchesPerSec.Collection (Rule)

Collection rule for the performance counter System\Context Switches/sec

Knowledge Base article:

Summary

This rule collects performance data for the System\Context Switches/sec performance counter.

The System\Context Switches/sec performance counter exposes the combined rate at which all processors on the computer are switched from one thread to another. Context switches occur when a running thread voluntarily relinquishes the processor, is preempted by a higher priority ready thread, or switches between user-mode and privileged (kernel) mode to use an Executive or subsystem service. It is the sum of Thread\\Context Switches/sec for all threads running on all processors in the computer and is measured in numbers of switches. There are context switch counters on the System and Thread objects. This counter displays the difference between the values observed in the last two samples, divided by the duration of the sample interval.

Element properties:

TargetMicrosoft.Windows.Server.10.0.OperatingSystem
CategoryPerformanceCollection
EnabledFalse
Instance NameSystem
Counter NameContext Switches/sec
Frequency300
Alert GenerateFalse
RemotableTrue

Member Modules:

ID Module Type TypeId RunAs 
PerformanceDS DataSource System.Performance.OptimizedDataProvider Default
WriteToDB WriteAction Microsoft.SystemCenter.CollectPerformanceData Default
WriteToDW WriteAction Microsoft.SystemCenter.DataWarehouse.PublishPerformanceData Default

Source Code:

<Rule ID="Microsoft.Windows.Server.10.0.OperatingSystem.SystemContextSwitchesPerSec.Collection" Enabled="false" Target="ServervNext!Microsoft.Windows.Server.10.0.OperatingSystem">
<Category>PerformanceCollection</Category>
<DataSources>
<DataSource ID="PerformanceDS" TypeID="SystemPerf!System.Performance.OptimizedDataProvider">
<ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
<CounterName>Context Switches/sec</CounterName>
<ObjectName>System</ObjectName>
<InstanceName/>
<AllInstances>false</AllInstances>
<Frequency>300</Frequency>
<Tolerance>50</Tolerance>
<ToleranceType>Absolute</ToleranceType>
<MaximumSampleSeparation>12</MaximumSampleSeparation>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="WriteToDB" TypeID="SC!Microsoft.SystemCenter.CollectPerformanceData"/>
<WriteAction ID="WriteToDW" TypeID="SCDW!Microsoft.SystemCenter.DataWarehouse.PublishPerformanceData"/>
</WriteActions>
</Rule>