Recently, I developed a MP that needed different discovery options to discover the same entities:
- I needed to discover on fixed schedule, let’s say the most common discovery type
- I needed to discover based on an event in the event log
- 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’
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:
- I created one discovery rule, it runs every time event X is logged in the OpsMgr event log
- I created a scheduler based monitoring rule that writes event X
- I created a monitoring rule that when event A appears in the application log writes event X
- 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:
- the scheduled discovery is implemented via topic 2.
- the even based discovery is implemented via topic 3
- the on demand discovery is implemented via topic 4
This posting is provided "AS IS" with no warranties, and confers no rights.