LS Registrar Dependency Discovery for LS Peer Connection Component

Microsoft.LS.2013.Discovery.Registrar.PeerConnection (Discovery)

Knowledge Base article:

Summary

This object enables the discovery of instance based performance counter 'PeerConnection'

Element properties:

TargetMicrosoft.LS.2013.Component.Registrar
EnabledTrue
Frequency14400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:
Discovered relationships and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
Microsoft.LS.2013.Discovery.Dependency.PeerConnection.DS DataSource Microsoft.LS.2013.Discovery.Dependency.DS Default

Source Code:

<Discovery ID="Microsoft.LS.2013.Discovery.Registrar.PeerConnection" Enabled="true" Target="Microsoft.LS.2013.Component.Registrar" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.LS.2013.Dependency.Registrar.PeerConnection"/>
<DiscoveryRelationship TypeID="Microsoft.LS.2013.Relationship.RegistrarHostsPeerConnection"/>
</DiscoveryTypes>
<DataSource ID="Microsoft.LS.2013.Discovery.Dependency.PeerConnection.DS" TypeID="Microsoft.LS.2013.Discovery.Dependency.DS">
<IntervalSeconds>14400</IntervalSeconds>
<DependencyId>PeerConnection</DependencyId>
<DependencyDisplayName>Peer Connection</DependencyDisplayName>
<ScriptBody><Script>
$DiscoveryData = GetDiscoveryData

$perfCategory = 'LS:SIP - Peers'
$displayName = 'Peer Connection'

# Split the list with ',' and trim the spaces from beginning and end.
# E.g. 'test1, test2, test3, test4 ' = {test1,test2,test3,test4}
$ExcludedInstances = 'clients'.Split(',') | % {$_.TrimStart().TrimEnd()}

$perf = New-Object System.Diagnostics.PerformanceCounterCategory($perfCategory);

if ($perf.CategoryType -eq 'MultiInstance')
{
$connections = $perf.GetInstanceNames();
TRACE('Found Multi Instance Performance Counter {0}' -f $perfCategory)

$component = $DiscoveryData.CreateClassInstance('$MPElement[Name='Microsoft.LS.2013.Component.Registrar']$')
$component.AddProperty('$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$', $TargetComputer)

foreach ($instance in strip-null($connections))
{
# Skip below instances:
# 1. Make sure the instance name is not empty and exclude '_total'
# 2. We have seen cases where there is an empty string and causing discovery to fail.
# 3. Exclude the performance counter instances in the exclusion list.
if (![string]::IsNullOrEmpty($instance) -and ($instance -ne '_total') -and ($ExcludedInstances -notcontains $instance))
{
TRACE('Found Connection {0}' -f $instance)
$connection = $DiscoveryData.CreateClassInstance('$MPElement[Name='Microsoft.LS.2013.Dependency.Registrar.PeerConnection']$')
$connection.AddProperty('$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$', $TargetComputer)
$connection.AddProperty('$MPElement[Name='Microsoft.LS.2013.Dependency']/Id$', $instance)
$connection.AddProperty('$MPElement[Name='System!System.Entity']/DisplayName$', ('{0} [{1}]' -f $displayName , $instance))
$DiscoveryData.AddInstance($connection)

$componentHostsDepedencyRelationship =
$DiscoveryData.CreateRelationshipInstance('$MPElement[Name='Microsoft.LS.2013.Relationship.RegistrarHostsPeerConnection']$');
$componentHostsDepedencyRelationship.Source = $component;
$componentHostsDepedencyRelationship.Target = $connection;
$DiscoveryData.AddInstance($componentHostsDepedencyRelationship);
}
}
}</Script></ScriptBody>
</DataSource>
</Discovery>