SCOM VSAE Authoring–Part 2: Classes and Discoveries

An object class defines what the object is, its properties and how it relates to other objects in terms of hierarchy and inheritance. For my example class, I will try and discover servers that have the task scheduler service to start automatically.

Let’s define a new Class of objects called StdMPTemplate.FEHSE.Scheduler.Service:

image

image

Give it a name before you hit ok!

image

Ok, don’t panic. It is XML, all colourful and cheerful.. Take a deep breath and let’s take a look at what we see. The XML example brings some comments that will help you filling up the gaps. If you never did SCOM authoring before, it will be challenging, but not impossible. Happens that most of the time, what we want is what the snippet brings for us, with a few modifications needed:

image

Let’s change this what we really want now:

image

Note that I changed the class to be “Public” and to be “hosted”. To be hosted means that is will be hosted by another object, meaning the computer that will have the task scheduler service and also that I can refer to the host’s properties when needed.I have also changed the Base class to LocalApplication (typically used for services and other local applications).

Finally, I have added the Display Strings for the Class and the property:

image

Now, if you build your solution (Ctrl-Shift-B), you should get something like this:

image

And your debug folder should contain the XML file for the MP:

image

If you don’t have a good ‘build’ read the messages carefully. They will look like gibberish in the first few times, but you’ll eventually get them. Smile

So, now, what we need to do is to find a server that has the service we want, in this case, the task scheduler one.

Discoveries can be done basically in three different ways:

Registry – the fastest and less expensive in terms of computing power;

WMI – more expensive and dependent on WMI’s health

Script – more complex and expensive, but very flexible

For this case, we could pick any of the ones above, but since we know services appear in registry, we can use the first one for convenience.

image

 

So, let’s take a look at how the Discovery template works:

image

image

image

You’ll have a few things to fill up:

image

The part you won’t be able to pick from a list is the configuration part.

When you click on Configuration XML, you’ll get a bit of an empty window:

image

It is context sensitive, so, it will only allow you to enter things that are valid, as above. Nevertheless, it won’t be easy to pick the same way as you would in the old Authoring Console.

Here’s how I’ve configured it:

<ComputerName>$Target/Property[Type=”Windows!Microsoft.Windows.Computer”]/NetworkName$</ComputerName>
<RegistryAttributeDefinitions>
<RegistryAttributeDefinition>
<AttributeName>Service</AttributeName>
<Path>SYSTEMCurrentControlSetServicesSchedule</Path>
<PathType>0</PathType>
<AttributeType>0</AttributeType>
</RegistryAttributeDefinition>
<RegistryAttributeDefinition>
<AttributeName>Started</AttributeName>
<Path>SYSTEMCurrentControlSetServicesScheduleStart</Path>
<PathType>1</PathType>
<AttributeType>2</AttributeType>
</RegistryAttributeDefinition>
<RegistryAttributeDefinition>
<AttributeName>OSVersion</AttributeName>
<Path>SOFTWAREMicrosoftWindows NTCurrentVersionCurrentVersion</Path>
<PathType>1</PathType>
<AttributeType>3</AttributeType>
</RegistryAttributeDefinition>
</RegistryAttributeDefinitions>
<Frequency>900</Frequency>
<ClassId>$MPElement[Name=”StdMPTemplate.FEHSE.Scheduler.Service”]$</ClassId>
<InstanceSettings>
<Settings>
<Setting>
<Name>$MPElement[Name=”StdMPTemplate.FEHSE.Scheduler.Service”]/ComputerName$</Name>
<Value>$Target/Property[Type=”Windows!Microsoft.Windows.Computer”]/NetworkName$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name=”Windows!Microsoft.Windows.Computer”]/PrincipalName$</Name>
<Value>$Target/Property[Type=”Windows!Microsoft.Windows.Computer”]/PrincipalName$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name=”System!System.Entity”]/DisplayName$</Name>
<Value>$Target/Property[Type=”Windows!Microsoft.Windows.Computer”]/PrincipalName$</Value>
</Setting>
</Settings>
</InstanceSettings>
<Expression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type=”String”>Values/Service</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type=”String”>True</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type=”String”>Values/Started</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type=”String”>2</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type=”String”>Values/OSVersion</XPathQuery>
</ValueExpression>
<Operator>GreaterEqual</Operator>
<ValueExpression>
<Value Type=”String”>6.2</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</Expression>

To end this post, let’s take a look at the configuration piece by piece:

The registry definitions:

image

Is the equivalent of this:

image

The frequency for the discovery:

image

The instance settings:

image

equivalent to:

image

The expression:

image

Is equivalent to:

image

As you can see, you may need to sometimes resort to previous references, but once you have some,you will start to create a library and be able to re-purpose them.

After importing it, the discovery starts and you should see something like this:

image

On our next episode, I will continue with a group discovery and then for some monitoring!

 

Hope this helps!