SCOM 2012 Network Monitoring: Rename Network Adapter

Standard

Everyone who has implemented SCOM 2012 Network Monitoring will be satisfied with the improvements with respect to SCOM 2007. More and more devices can be deeply monitored with SCOM 2012. One of the downsides at this moment is the naming of the Network Adapters. The name inside SCOM does not always reflect the name on the switch. See the following example:

image

The alerts send for this network adapters will also contain the DisplayName. The subject of the alert with the above naming will be ‘Interface PORT-0.15 is flapping’. This alert is not very useful. So the idea is to change the displayname of the Network Adapter.

Before we dive into the solution. Let’s first start with the class definitions for the Network Adaptr to see if it’s possible to change in the first place:

<ClassType ID="System.NetworkManagement.NetworkAdapter" Accessibility="Public" Abstract="false" Base="System!System.NetworkAdapter" Hosted="true" Singleton="false" Extension="false">
<Property ID="ConnectionType" Type="string" AutoIncrement="false" Key="false" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="Description" Type="string" AutoIncrement="false" Key="false" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="DuplexMode" Type="string" AutoIncrement="false" Key="false" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="DuplexSource" Type="string" AutoIncrement="false" Key="false" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="Index" Type="string" AutoIncrement="false" Key="false" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="InterfaceAlias" Type="string" AutoIncrement="false" Key="false" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="InterfaceNumber" Type="string" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="38" MinLength="0" Required="false" Scale="0" />
<Property ID="IsConnector" Type="bool" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="MaxSpeed" Type="double" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="MaxTransferUnit" Type="int" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="Mib2IfType" Type="int" AutoIncrement="false" Key="false" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="Mode" Type="string" AutoIncrement="false" Key="false" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="Key" Type="string" AutoIncrement="false" Key="true" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
<Property ID="Type" Type="string" AutoIncrement="false" Key="false" CaseSensitive="true" MaxLength="256" MinLength="0" Required="false" Scale="0" />
</ClassType>

 

Based on the above Class definition it’s important to know that we can’t change the name of a Key property of a class. The good news is that the display name of the Network Adapter isn’t a key property and can be overwritten by a custom discovery. So the idea is to create a custom discovery and let this discovery change the display name of the Network Adapter. To do this we need to create a custom Management Pack with this custom discovery.

Let’s start with the References part of the custom Management Pack. We needs to a reference to the System.NetworkManagement.Library because the Network Adapter class is defined in this Management Pack. The first part of the MP will look likes this:

<?xml version="1.0" encoding="utf-8"?>
<ManagementPack SchemaVersion="2.0" ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema">   <Manifest>     <Identity>       <ID>Network.Monitoring.Custom</ID>       <Version>1.0.0.0</Version>     </Identity>     <Name>Network.Monitoring.Custom</Name>     <References>       <Reference Alias="Windows">         <ID>Microsoft.Windows.Library</ID>         <Version>7.5.8501.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="SNL">         <ID>System.NetworkManagement.Library</ID>         <Version>7.1.10226.0</Version>         <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>       </Reference>     </References>   </Manifest>

Then we need to define the custom discovery. I have decided to create a TimedPowershellDiscovery which performs the rename action. The powershell script looks like this:

# NetworkAdapterChange.ps1
# Written by Arjan Vroege. All rights reserved.

param($SourceID, $ManagedEntityID, $Key, $Description, $InterfaceAlias, $DeviceKey, $NodeSysName)

$Displayname = $NodeSysName + " -- " + $Description

$scomapi = new-object -comObject "MOM.ScriptAPI"
$DiscData = $scomapi.CreateDiscoveryData(0, $SourceID, $ManagedEntityID)

#fill out the key properties
$NetworkAdapter = $DiscData.CreateClassInstance("$MPElement[Name='SNL!System.NetworkManagement.NetworkAdapter']$")
$NetworkAdapter.AddProperty("$MPElement[Name='SNL!System.NetworkManagement.NetworkAdapter']/Key$", $Key)
$NetworkAdapter.AddProperty("$MPElement[Name='SNL!System.NetworkManagement.Node']/DeviceKey$", $DeviceKey)
$NetworkAdapter.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $Displayname)

# add the WebSite to the DiscoveryData object
$discData.AddInstance($NetworkAdapter)
$discData

A little explanation:

Let’s start with the parameters needed to create new discovery data. To create a new Discovery Data object the $sourceID and the ManagedEntityId are needed. Both parameters will be send to the script from the discovery parameters. When this new Discovery object is created we can define which ClassInstance will be discovered. In our case this will be a System.NetworkManagement.NetworkAdapter. When we have defined the class instance we can add properties the discovery data object. The key property of the Network Adapter and the Network Node are required. The most important property we want to set is the System.Entity’]/DisplayName$, this property reflects the displayname of the object. When we put the script above in a discovery the discovery will look likes this:

<Discovery ID="Network.Monitoring.Custom.Custom.NetworkAdapter.Discovery" Target="SNL!System.NetworkManagement.NetworkAdapter" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="SNL!System.NetworkManagement.NetworkAdapter" />
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime>16:00</SyncTime>
<ScriptName>NetworkAdapterChange.ps1</ScriptName>
<ScriptBody>
# NetworkAdapterChange.ps1
# Written by Arjan Vroege. All rights reserved.

param($SourceID, $ManagedEntityID, $Key, $Description, $InterfaceAlias, $DeviceKey, $NodeSysName)

$Displayname = $NodeSysName + " -- " + $Description

$scomapi = new-object -comObject "MOM.ScriptAPI"
$DiscData = $scomapi.CreateDiscoveryData(0, $SourceID, $ManagedEntityID)

#fill out the key properties
$NetworkAdapter = $DiscData.CreateClassInstance("$MPElement[Name='SNL!System.NetworkManagement.NetworkAdapter']$")
$NetworkAdapter.AddProperty("$MPElement[Name='SNL!System.NetworkManagement.NetworkAdapter']/Key$", $Key)
$NetworkAdapter.AddProperty("$MPElement[Name='SNL!System.NetworkManagement.Node']/DeviceKey$", $DeviceKey)
$NetworkAdapter.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $Displayname)

# add the WebSite to the DiscoveryData object
$discData.AddInstance($NetworkAdapter)
$discData
</ScriptBody>
<Parameters>
<Parameter>
<Name>SourceID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>ManagedEntityID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>Key</Name>
<Value>$Target/Property[Type="SNL!System.NetworkManagement.NetworkAdapter"]/Key$</Value>
</Parameter>
<Parameter>
<Name>Description</Name>
<Value>$Target/Property[Type="SNL!System.NetworkManagement.NetworkAdapter"]/Description$</Value>
</Parameter>
<Parameter>
<Name>InterfaceAlias</Name>
<Value>$Target/Property[Type="SNL!System.NetworkManagement.NetworkAdapter"]/InterfaceAlias$</Value>
</Parameter>
<Parameter>
<Name>DeviceKey</Name>
<Value>$Target/Host/Property[Type="SNL!System.NetworkManagement.Node"]/DeviceKey$</Value>
</Parameter>
<Parameter>
<Name>NodeSysName</Name>
<Value>$Target/Host/Property[Type="SNL!System.NetworkManagement.Node"]/sysName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
<StrictErrorHandling>true</StrictErrorHandling>
</DataSource>
</Discovery>

The above discovery name will use the sysName and Description of the Network Adapter for will form the display name of the adapter.

The result will look likes this:

image

So with this solution you can change the display name of the Network Adapter and also the alerts generated for this adapters will reflect this changed display name. But there are some notes which you should keep in mind:

  • A new run of the Network Discovery will change the display name of the Network Adapter to his original state. After the Network Discovery this custom discovery needs to be run the rename the adapter again. You could schedule this with settings  IntervalSeconds and SyncTime.
  • There is a performance impact with this solution. If you have your Network Discovery scheduled to run each day you need to investigate the performance impact in your SCOM environment. At this moment I do not have numbers on the performance impact of this solution.

I hope that this solution is useful for you and please test this first in your test environments before you import this solution into production.

Many thanks to Oskar Landman for the thinking and helping to define this solution!

UPDATE 25-08-2015 : The MP is now published on the Technet Script Gallery. You can find it here.

 

52 thoughts on “SCOM 2012 Network Monitoring: Rename Network Adapter

      • Santiago

        Could you send me that same email, i’ve been stuck in this for weeks now and i can seem to have a solution for it.

        thanks

        • Arjan Vroege

          Hi Santiago,
          I’ve send you the MP and instructions. Please let me know if you need anything.
          Regards, Arjan

    • Arjan Vroege

      Hi Alex,

      Check your mail. 🙂 I’ve send the MP!
      If you have any questions related this MP please let me know,

      Regards, Arjan

    • Arjan Vroege

      Hi Nick,

      I’ve send you the MP and instructions. Please let me know if you need anything.

      Regards, Arjan

    • Arjan Vroege

      Hi Jon,
      I’ve send you the MP and instructions. Please let me know if you need anything.
      Regards, Arjan

  1. Mark Kholodov

    Hi Arjan,
    That is exactly, what I am looking for. Could you advice any book, article or video about creating MP? And could you please send me your MP?

    Thank you in advance!

    • Arjan Vroege

      Hi Mark,
      I’ve send you the MP and instructions. The OpsMgr 2012 Unleashed books are a very good start.
      Please let me know if you need anything.
      Regards, Arjan

  2. John

    Hi Arjan
    That is exactly, what I am looking for. Thank you very much.
    Could you please send me the instruction and the MP?
    Regards

    • Arjan Vroege

      Hi John,
      I’ve send you the MP and instructions. Please let me know if you need anything.
      Regards, Arjan

      • John

        Hi Arjan,

        Thank you very much. The script is just great and work perfectly.
        There’s just one little thing. It would be great if it would be also possible to change the Path from the strange number 00-00-17-3C-8F40 to the Name of the Device.
        Is there a simple way to implement that?

        Regards
        Yannic

        • Arjan Vroege

          Hi Yannic,

          In my environment the path of the Network Adapter is also changed. Could you send me some screens of your problem.
          You can send the sceenshots to arjanvroege at hotmail dot com.

          Regards, Arjan

  3. Dani Kiehl

    Hi Arjan,

    could you please send me the MP and instructions? Thanks a lot!

    Kind regards!

    Dani

  4. Ildar

    Hi Arjan,

    Could you please send me the MP and instructions? Thanks a lot!

    Best regards,
    Ildar

  5. Oliver P.

    Hello Arjan,

    would you be so kind to send me the detailed instructions and the MP, too?

    Thanks a lot in advance!

    Best regards

    Oliver

    • Arjan Vroege

      You can find the step-by-step guide and the Management Pack on Technet. Link is provided in the blogpost.
      Do you need more information, if so please provide me some guidance for what information your looking for.

      Regards, Arjan

  6. Marcus

    Why do you need a MP for accomplish this? You can configure the discoveryfile located in C:\Program Files\System Center 2012\Operations Manager\Server\NetworkMonitoring\conf\Discovery\Discovery.conf
    change with the following values:

    #
    # A user can choose one of the following methods to set the DisplayName of
    # systems.
    #
    # DisplayNameFormat = “AUTOASSIGNED”
    # The DisplayName of a system is set to the value of the Name attribute.
    #
    # DisplayNameFormat = “MIBIISYSNAME”
    # The DisplayName of the system is set to the value of the MIB-II sysName
    # variable.
    #

    DisplayNameFormat = “MIBIISYSNAME”

    After the change in the Discovery.conf file, one has to rediscover all devices to make the change.

    • Arjan Vroege

      The actions you describe are for changing the DisplayName of the Network Devices. My solution is taking care of changing the DisplayName of the Network Adapters of Network Devices.

      Regards, Arjan

      • Arjan Vroege

        Hi Simon,

        It’s just this:

        After downloading the MP and importing it into SCOM and your existing Network adapters will be renamed with the following naming convention:

        $Displayname = $NodeSysName + ” — ” + $Description + ” — ” + $InterfaceAlias

        Above variables are discovered through the ‘normal’ network discovery of SCOM.

        Regards, Arjan

  7. Alex

    Hi Arjan,

    Why did you decide to change the Property? I think it can have bad influence on OpsMgr.
    For example, you have a large count of network devices and discovery runs 2 times per week. You will receive a huge amount of changes in your OperationsManager DB and DWH. Did you analyze this influence?
    Probably you need disable monitors standard monitors and create new with good Alert Description?!

    Regards, Alex

    • Arjan Vroege

      Hi Alex,

      I explain in my blogpost that this solution has a performance impact in in each SCOM environment. But you can only know the impact when you test this in your environment.

      So the choice is if you want to change the name of the Network Adapters than this solution will do that but has a performance impact on your SCOM environment.

      If you don’t want that performance impact than you have to deal with the current names of the Network Adapters. 🙂

      Regards, Arjan

      • Alex

        You are right. I did not think deeply about problem. This is only one way to get useful name in alerts. Rewriting monitor won’t help, only discovery.

        Thanks for you work!

        Regards, Alex

    • Arjan Vroege

      Hi Carlos,

      You don’t have to execute additional steps. After a new discovery run the network adapters should be renamed. If you want to change the naming you need to edit the PowerShell section and re-import the MP xml.

      Regards, Arjan

    • Arjan Vroege

      Do you see any logged errors on the Management Servers eventviewer which runs the network discovery?

      Regards, Arjan

Leave a Reply to Carlos Olivo Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.