Authoring Management Pack Software Xplat

SCOM 2012 – Unix/Linux Dynamic Grouping Using VSAE Authoring

SCOM is a great tool for monitoring cross platform systems as for example Linux or other Unix derivate. Although Microsoft invested a lot in cross platform monitoring, one thing I am missing is a way for dynamic grouping Unix/Linux systems in SCOM.

What is the problem?

As you might know in SCOM you can create attributes (registry or WMI discoveries) which extend a selected class. This extended class can be used in a dynamic group where you filter for the appropriate attribute. Kevin Holman has written long time ago a very good blog post about these steps. Well something similar I am missing in SCOM for Unix/Linux systems. Because of that I decided to create a test management pack / solution using Visual Studio Authoring Extensions (VSAE).

I found some fundamental steps on TechNet where some cross platform authoring is well explained. Of course if you want to know more about authoring management packs using VSAE there is the best Authoring Guide from Brian Wren on TechNet Wiki. I highly recommend this guide for starting MP authoring!

How does the this solution look like at the end?

Before you can start, your Linux systems need to be monitored by SCOM 2012. If you need some help, I created some time ago a few blog posts about Linux monitoring.

If your Linux monitoring works create a text file in /tmp called type.txt…

image

and write PRODUCTION

image

save the changes and quit.

After a minute you will have an extended Linux class with an additional custom attribute…

image

You can now use this attribute to dynamically group the Linux servers…

image

Isn’t that cool, huh :)?

How does it work?

First I created a custom class Linux.Dynamic.Group.ComputerRole with two additional properties OperatingSystem and Attribute…

<ClassType ID=Linux.Dynamic.Group.ComputerRole Accessibility=Public Abstract=false Base=MLSL!Microsoft.Linux.SUSE.Computer Hosted=false Singleton=false Extension=false>
<Property ID=OperatingSystem Type=string AutoIncrement=false Key=false CaseSensitive=false MaxLength=256 MinLength=0 Required=false Scale=0 />
<Property ID=Attribute Type=string AutoIncrement=false Key=false CaseSensitive=false MaxLength=256 MinLength=0 Required=false Scale=0 />
</ClassType>

Next we need to discover the Linux systems and create instances of your custom class. Therefore I created a discovery Linux.Dynamic.Group.Computer.Discovery which is going to discover all SUSE Linux system and map the caption value to the OperatingSystem property. Note here the “SUSE” FilterValue which will scan the caption entry on each system of the Microsoft.Unix.Computer class…

<FilterProperty>//*[local-name()=”Caption”]</FilterProperty>
<FilterValue>SUSE</FilterValue>
<ClassId>$MPElement[Name=”Linux.Dynamic.Group.ComputerRole”]$</ClassId>
<InstanceSettings>
<Settings>
<Setting>
<Name>$MPElement[Name=”Unix!Microsoft.Unix.Computer”]/PrincipalName$</Name>
<Value>$Target/Property[Type=”Unix!Microsoft.Unix.Computer”]/PrincipalName$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name=”Linux.Dynamic.Group.ComputerRole”]/OperatingSystem$</Name>
<Value>$Data///*[local-name()=”Caption”]$</Value>
</Setting>
</Settings>
</InstanceSettings>

At this moment we have an instance of the Microsoft.Linux.SUSE.Computer class created and have an additional attribute OperatingSystem “attached”.

The next step is to find a way to read some information from our newly created Linux instance and attach (extend) this information to our object. I found the easiest way is to read a text file and get the information from this text file.
As an example, we create a text file called type.txt on the Linux server in the directory /tmp and write for example PRODUCTION into this type.txt file. Now we need another discovery to read this information from the text file. For that purpose I created a discovery called Linux.Dynamic.Group.Computer.Discovery.Attribute which executes the command cat /tmp/type.txt and returns the string PRODUCTION. This string is mapped to the Attribute value of our custom class. It looks like this…

<InvokeAction>ExecuteCommand</InvokeAction>
<Input><![CDATA[ <p:ExecuteCommand_INPUT xmlns:p=”http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem”><p:command>cat /tmp/type.txt</p:command><p:timeout>10</p:timeout></p:ExecuteCommand_INPUT>]]></Input>
<FilterProperty>//*[local-name()=”StdErr”]</FilterProperty>
<FilterValue>No such file or directory</FilterValue>
<ClassId>$MPElement[Name=”Linux.Dynamic.Group.ComputerRole”]$</ClassId>
<InstanceSettings>
<Settings>
<Setting>
<Name>$MPElement[Name=”Unix!Microsoft.Unix.Computer”]/PrincipalName$</Name>
<Value>$Target/Property[Type=”Unix!Microsoft.Unix.Computer”]/PrincipalName$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name=”Linux.Dynamic.Group.ComputerRole”]/Attribute$</Name>
<Value>$Data///*[local-name()=”StdOut”]$</Value>
</Setting>
</Settings>
</InstanceSettings>

Finally we have our custom class extended with information from both discoveries…

image

How does it look in the SCOM console?

If you go to Object Discoveries in your SCOM console and filter the scope by typing “SCOMFAQ” you will find the two discoveries. The first discovery is targeted at Unix/Linux Computer class (Linux Dynamic Group Computer Discovery) and the second discovery is targeted at the Linux Computer Class Extended (Linux Dynamic Group Computer Discovery Attribute). The default discovery interval for both discoveries is set to 60 seconds which is NOT for production(!) just for testing. You can override the intervals as needed.

image

If you open Properties for Linux Dynamic Group Computer Discovery Attribute discovery and choose to override the discovery for the Linux Computer Class Extended, you can override the path to the text file which is being discovered on the Linux server for the attribute. This allows you to customize a location for your type.txt file which is appropriate for you…

image

If go to Discovered Inventory and select the custom class Linux computer Class Extended you will see this…

image

Visual Studio Authoring Extensions (VSAE)

To create the MP I used the Visual Studio Authoring Extensions. You can download the extensions here and make sure you have the Visual Studio 2010 Professional installed before installing the extensions.

If you open the solution you will find the following fragments and templates…

  • Classes.mpx => This contains custom classes and descriptions
  • Discoveries.mptg => Discovery template for the 2 discoveries discussed above
  • DSDiscoveryAttribute.mpx => Data source and modules for the custom discovery Linux.Dynamic.Group.Computer.Discovery.Attribute
  • ManagementPack.mpx => Metadata about the MP (display name etc.)

image

What is the purpose?

As I mentioned before by extending the Linux class through attributes your are able to utilize this attribute to create dynamic groups in SCOM. Building those dynamic groups is the same, as you would build dynamic groups for a Windows system. These groups can be used to scope down views or overrides for production, preproduction or development systems in SCOM. You also could group the Linux system according to some other criteria you just need to specify the appropriate string in the type.txt file.

For example this Extended Linux Attribute can be used to filter state views…

image

image

And there are many more use cases…

Where can I download the MP?

Please keep in mind this MP works, but you need to adapt it to your needs. For example adjust the discoveries and intervals as it fits your requirements. The MP is unsealed and is meant for testing and as a starting point for building final solutions.

For your convenience you can download the the unsealed MP or the entire VSAE solution.

I hope this helps you and if you have any additional ideas or suggestions please let me know!

14 Replies to “SCOM 2012 – Unix/Linux Dynamic Grouping Using VSAE Authoring

  1. Hi,

    Informative post! Just a quick question, I’m trying to adapt this MP to use on Red Hat systems rather then SUSE. Would changing the caption bit to Redhat, and altering the dependent MP to Microsoft.Linux.RedHat.Library be enough?

    1. Hi Bas

      I haven’t tested RedHat but from my Point of view yes, should be enough. You need to Change the FilterValue “SUSE” to something like “RedHat”, Reference the RedHat Library and Change the “class <ClassType ID="Linux.Dynamic.Group.ComputerRole" Accessibility="Internal" Abstract="false" Base="MLSL!Microsoft.Linux.SUSE.Computer” Hosted=”false” Singleton=”false” Extension=”false”>” to the RedHat.

      Let me know if it works 🙂

      Cheers,

      Stefan

      1. Well…that didn’t quite work out 🙁

        Edited the XML based unsealed MP, haven’t tried the VSAE package yet. Anyway, after changing the SUSE references in the MP to the RedHat ones (find/replace SUSE > RedHat and the classtype to I tried to import the XML and got the following error:

        Error 1:
        Found error in 1|SCOMFAQ.Linux.Dynamic.Group.RedHat|1.0.0.0|DisplayString,ElementReference=000c5e1f-3bf7-2571-f458-f846b06ccd9c,LanguageID=ENU|| with message:
        Element Info with Identity DisplayString.ElementReference=000c5e1f-3bf7-2571-f458-f846b06ccd9c,LanguageID=ENU refers to an invalid element SCOMFAQ.Linux.Dynamic.Group.

        Thankfully, the reference ID isn’t to be found in the XML, so on to the VSAE project it goes!

        1. Just replace the 3 things I mentioned before manually. Don’t rename the MP yet. And Import the MP although it might not fit your naming convention yet.

          Did you Import the MP before? If so, delete first the MP in SCOM.

  2. That did the trick, also had to change the alias of the referenced MP from MLSL to MLRL.

    Just a quick question, if you add multiple lines to the type.txt file it would read all the lines? And you could base a group on a part of the line?

    We got a scenario here where we basically have 2 attributes:
    – Location
    – Role

    Or copy the MP and change the file to somehting like Loc.txt?

    1. Cool.

      Yeah it would display all content of the file. Hmm there are different approaches, either you put everything in one line and separate it by e.g. a “;” and the use dynamic group and RegEx to parse the string. Or you type every information on a new line in the txt file and use cat -n to number the lines. Then you could create a dynamic group which Looks for something like the line number e.g. 2 *.

      Cheers,

      Stefan

  3. Any idea why I am getting this build error?

    Error 24 Failed to verify CompositeModuleType:
    Microsoft.Unix.WSMan.TimedCommandExecution.DiscoveryData
    :
    Could not load management pack [ID=Microsoft.SystemCenter.WSManagement.Library,
    KeyToken=31bf3856ad364e35, Version=7.0.9500.0]. The management pack was not found
    in the store.
    An object of class ManagementPack with name Microsoft.SystemCenter.WSManagement.Library
    was not found. (Path = Microsoft.Unix.WSMan.TimedCommandExecution.DiscoveryData)
    DSDiscoveryAttribute.mpx 9 8 SCOMFAQ.Linux.Dynamic.Group

    1. Hi

      Make sure you referenced the Microsoft.SystemCenter.WSManagement.Library MP in VSAE with at least Version 7.0.9500.0. YOu can find the MP in the SCOM source CD if it is not in the VSAE reference directory.

      Cheers,

      Stefan

      1. That’s it.. the DLL included in the VSAE path is an older version. I found the newer version of 2013 on the extracted ISO/CD files. Thanks!

  4. If I want to discover all Linux/Unix machines, Do I just remove the Filter expression?
    SUSE

  5. Hi I tried to import the XML file and am getting an error

    This management pack cannot be imported.

    : XSD verification failed for the management pack. [Line: 13, Position: 27]
    The ‘PublicKeyToken’ element is invalid – The value ” is invalid according to its datatype ‘ManagementPackKeyToken’ – The Pattern constraint failed.The Pattern constraint failed.

Leave a Reply

Your email address will not be published. Required fields are marked *

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