How to un-discover your discovery data


Recently, I developed a MP that needed different discovery options to discover the same entities:

  1. I needed to discover on fixed schedule, let’s say the most common discovery type
  2. I needed to discover based on an event in the event log
  3. I needed to discover on demand via a console task

Once I tested the solution I realized that while new class instances are always added by every discovery type implemented, the instance removal seemed odd. Sometimes it seemed to work, sometimes not. After some debugging I realized that class instances are associated to the discovery rule that created them and they can only be removed by that specific rule.

For example if I have instance 1 discovered by discovery A, then I delete Instance 1 and run the on demand discovery B, Instance 1 won’t be removed until discovery A runs. I developed a test MP to verify this hypothesis, it will discover two instances of ClassA with two different disocvery rules, and then undiscover the two instances with just one of the discovery rules. The net result is that the two instances were not removed and the database view was the following:
select distinct * from dbo.DiscoverySourceToTypedManagedEntity D
inner join dbo.DiscoverySource DS on DS.DiscoverySourceId=D.DiscoverySourceId
inner join dbo.TypedManagedEntity TME on TME.TypedManagedEntityId = D.TypedManagedEntityId
inner join dbo.ManagedType MT on MT.ManagedTypeId=TME.ManagedTypeId
inner join dbo.BaseManagedEntity ME on ME.BaseManagedEntityId=TME.BaseManagedEntityId
where  MT.TypeName = ‘QND.Test.DiscoveryRemoval.ClassA’

image

As you can see every instance is associated to its discovery rule and can be deleted only by that disocvery rule.

I conclude that having more discovery rules to discover the same instances it’s not a good idea.

Given this constrain hos could I implement my requirements?

My solution has been the following:

  1. I created one discovery rule, it runs every time event X is logged in the OpsMgr event log
  2. I created a scheduler based monitoring rule that writes event X
  3. I created a monitoring rule that when event A appears in the application log writes event X
  4. I created a console task that when runs writes event X

In this way I have just one discovery rule and I’m able to implement all my scenarios:

  1. the scheduled discovery is implemented via topic 2.
  2. the even based discovery is implemented via topic 3
  3. the on demand discovery is implemented via topic 4

– Daniele

This posting is provided "AS IS" with no warranties, and confers no rights.

About these ads
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 329 other followers

%d bloggers like this: