Multiple Counters for Performance Counter OpsMgr SDK Service/Client Connections on OpsMgr 2012 Console
You are wondering why you see multiple Performance Counter form SDK Service/Client Connections on OpsMgr 2012 Console?
In my test environment with just one single MS I would expect to see only one single entry in the performance view Client Connections, because there is only one SDK Service running in my environment.
But checking the performance view I see more than 20 entries, but only one graph. Why?
Looking into the collection rule data source points me to the right direction.
Looking into Performance Monitor I saw that the performance counter name contains a process ID
That means each time if the SDK restarts, it get a new process ID and the Performance Counter Instance name is different. So this will result in multiple graphs in OpsMgr console.
Over time you will get more and more entries there.
Hmm, ok but.... how can I fix this? And primarily how can I get rid of the multiple empty entries?
Let's start with the second question first.
- Remove the multiple old empty entries form this view by removing the MP "System Center Operations Manager Data Access Service Monitoring" manually or by using Powershell
get-SCOMManagementpack -name "Microsoft.SystemCenter.OperationsManager.DataAccessService" | Remove-SCOMManagementpack
After removing the original MP your multiple performance counter entries are gone.
To fix this behavior until this might be fixed in a future MP update, you can create your own performance collection rule.
- You can create your own rule, based on a PowerShell script. The following script provides you the actual value of SDK Client Connections and returns it as an OpsMgr PropertyBag.
$ID = (get-process -name Microsoft.Mom.Sdk.ServiceHost).ID
$CookedValue = (Get-Counter -Counter "\OpsMgr SDK Service(microsoft.mom.sdk.servicehost-pid$ID)\Client Connections").CounterSamples | Select -ExpandProperty Cookedvalue
$Value = ([math]::Round($CookedValue, 2))
$Value
$oAPI = new-object -comObject "MOM.ScriptAPI"
# Create the property bag
$pb = $oAPI.CreatePropertyBag()
# Populate the property bag with data from the registy
$pb.AddValue("Value", $Value)
$pb
- Here is a MP Example how you can create a powershell performance collection rule:
<?xml version="1.0" encoding="utf-8"?><ManagementPack ContentReadable="true" SchemaVersion="2.0" OriginalSchemaVersion="1.0" xmlns:xsd="<www.w3.org/2001/XMLSchema>" xmlns:xsl="<www.w3.org/1999/XSL/Transform>">
<Manifest>
<Identity>
<ID>SDKConnectionCount.FixMP</ID>
<Version>1.0.0.0</Version>
</Identity>
<Name>SDKConnectionCount.FixMP</Name>
<References>
<Reference Alias="MicrosoftSystemCenterInternal">
<ID>Microsoft.SystemCenter.Internal</ID>
<Version>7.0.8427.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="MicrosoftSystemCenterDataWarehouseLibrary">
<ID>Microsoft.SystemCenter.DataWarehouse.Library</ID>
<Version>7.0.8427.1</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="SystemCenter">
<ID>Microsoft.SystemCenter.OperationsManager.DataAccessService</ID>
<Version>7.0.8560.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="Windows">
<ID>Microsoft.Windows.Library</ID>
<Version>7.5.8501.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="SystemCenter1">
<ID>Microsoft.SystemCenter.NTService.Library</ID>
<Version>7.0.8560.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="Performance">
<ID>System.Performance.Library</ID>
<Version>7.0.8427.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="System">
<ID>System.Library</ID>
<Version>7.5.8501.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="SC">
<ID>Microsoft.SystemCenter.Library</ID>
<Version>7.0.8427.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
<Reference Alias="Health">
<ID>System.Health.Library</ID>
<Version>7.0.8427.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
</Manifest>
<TypeDefinitions>
<ModuleTypes>
<DataSourceModuleType ID="SDKConnectionCount.FixMP.TimedPowershellScript" Accessibility="Internal" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>Windows!Microsoft.Windows.PowerShellSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element minOccurs="1" name="Interval" type="xsd:integer" xmlns:xsd="<www.w3.org/2001/XMLSchema>" />
<xsd:element minOccurs="1" name="ScriptName" type="xsd:string" xmlns:xsd="<www.w3.org/2001/XMLSchema>" />
<xsd:element minOccurs="1" name="ScriptBody" type="xsd:string" xmlns:xsd="<www.w3.org/2001/XMLSchema>" />
<xsd:element minOccurs="1" name="TimeoutSeconds" type="xsd:integer" xmlns:xsd="<www.w3.org/2001/XMLSchema>" />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Interval" Selector="$Config/Interval$" ParameterType="int" />
<OverrideableParameter ID="Timeout" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="Scheduler" TypeID="System!System.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval>$Config/Interval$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates />
</Scheduler>
</DataSource>
<ProbeAction ID="PS" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>$Config/ScriptName$</ScriptName>
<ScriptBody>$Config/ScriptBody$</ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PS">
<Node ID="Scheduler" />
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>
</ModuleTypes>
</TypeDefinitions>
<Monitoring>
<Rules>
<Rule ID="SDKConnectionCount.FixMP.OM2012.CollectionRule.SDKClientConnections" Enabled="true" Target="SystemCenter!Microsoft.SystemCenter.ManagementDataAccessService" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
<Category>Custom</Category>
<DataSources>
<DataSource ID="DS" TypeID="SDKConnectionCount.FixMP.TimedPowershellScript">
<Interval>300</Interval>
<ScriptName>getSDKConnections.ps1</ScriptName>
<ScriptBody>
$ID = (get-process -name Microsoft.Mom.Sdk.ServiceHost).ID
$CookedValue = (Get-Counter -Counter "\OpsMgr SDK Service(microsoft.mom.sdk.servicehost-pid$ID)\Client Connections").CounterSamples | Select -ExpandProperty Cookedvalue
$Value = ([math]::Round($CookedValue, 2))
$Value
$oAPI = new-object -comObject "MOM.ScriptAPI"
# Create the property bag
$pb = $oAPI.CreatePropertyBag()
# Populate the property bag with data from the registy
$pb.AddValue("Value", $Value)
$pb
</ScriptBody>
<TimeoutSeconds>60</TimeoutSeconds>
</DataSource>
</DataSources>
<ConditionDetection ID="cd" TypeID="Performance!System.Performance.DataGenericMapper">
<ObjectName>OpsMgr SDK Service</ObjectName>
<CounterName>Client Connections</CounterName>
<InstanceName>microsoft.mom.sdk.servicehost</InstanceName>
<Value>$Data/Property[@Name='Value']$</Value>
</ConditionDetection>
<WriteActions>
<WriteAction ID="DB" TypeID="SC!Microsoft.SystemCenter.CollectPerformanceData" />
<WriteAction ID="DW" TypeID="MicrosoftSystemCenterDataWarehouseLibrary!Microsoft.SystemCenter.DataWarehouse.PublishPerformanceData" />
</WriteActions>
</Rule>
</Rules>
<Overrides>
<RulePropertyOverride ID="OverrideForRuleMicrosoftSystemCenterDataAccessServiceCollectClientConnectionsForContextMicrosoftSystemCenterManagementDataAccessServiceaaad7b22a79b41f88df37499e1882aae" Context="SystemCenter!Microsoft.SystemCenter.ManagementDataAccessService" Enforced="false" Rule="SystemCenter!Microsoft.SystemCenter.DataAccessService.CollectClientConnections" Property="Enabled">
<Value>false</Value>
</RulePropertyOverride>
</Overrides>
</Monitoring>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
<DisplayString ElementID="SDKConnectionCount.FixMP">
<Name>SDK Connection Count MP-FIX</Name>
</DisplayString>
<DisplayString ElementID="SDKConnectionCount.FixMP.OM2012.CollectionRule.SDKClientConnections">
<Name>SDK ClientConnections Collection Rule</Name>
</DisplayString>
<DisplayString ElementID="SDKConnectionCount.FixMP.TimedPowershellScript">
<Name>Timed Powershell Script PropertyBag Datasource</Name>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPack>
This sample MP contains as well an override to disable the original collection rule.
If you want to import this sample MP you need to reimport the original "System Center Operations Manager Data Access Service Monitoring" MP of course.
Remember: The original MP provides much more than the collection rule I'm talking here. So you should definitely reimport this original MP again. ;-)
You'll find it on your SCOM 2012 Installation media in folder "Management Packs"
After importing those two MPs you will see only one graph.
Comments
- Anonymous
October 08, 2014
Hi Daniel, thanks, nice work. Saved me quite some time today :) - Anonymous
October 15, 2014
Knowing WHO logged on to SCOM WHEN , from WHERE and HOW LONG this session lasted can be very helpful