Comic Credit: Abstruse Goose
MP Authoring Series (For an explanation of this series read this post first.)
Real World Issue: Customer is seeing a lot of Critical alerts for Mirrored Databases in a Disconnected state, but only Warning alerts for Mirrored Databases in Suspended state. In this customer’s environment brief disconnects are common and not necessarily indicative of a Critical issue, whereas a mirrored database in a Suspended state is always Critical for this customer. The customer wants to swap the default states such that Disconnected will now be Warning and Suspended will be Critical.
There are three Mirrored Database Mirror Status Monitors
When we dig into the properties
We see the three states as well as the corresponding Statuses that map to those states.
When we check Overrides we find there is nothing we can override to meet the customer needs:
So to accommodate this request we need to do a little custom authoring in Visual Studio + VSAE.
The process isn’t too complex, however, it is much easier to absorb via video than the many page article that would result if I tried to document the steps by hand:
Once you have your final successful build you will find your files in the bin–Debug folder of your project:
Once you import your custom MP into SCOM you will have a cloned monitor with your modified behavior:
It would be wrong to start off any discussion of SCOM authoring without pointing out some of the great resources that do exist on this topic:
-The MSDN Operations Manager Development Kit (Excellent for those of the developer persuasion, but less friendly for those whom PowerShell is much more comfortable than C#)
-Steve Wilson’s classic AuthorMP blog posts. (A bit dated, but they remain a source of some the most insightful posts on various aspects of OpsMgr)
-If you happen to be a Microsoft Premier customer there is a great workshop on SCOM Authoring with Visual Studio that came out last year
-And countless members of the community like Tao Yang & Raphael Burri who have written high quality MPs that can serve as a primer to those who want to dig in and start authoring. (Since I started writing this post awhile back I believe Tao has hosted some MP authoring training, I haven’t gotten a chance to look at it yet, but once I do I will add a link.)
But despite all that great content out there. Management Pack authoring can be an extremely difficult skill to acquire. At least from my own perspective – starting out in MP Authoring was really hard. Even after having read the vast majority of the published info on MP authoring, and watching all the videos that are out there I can’t say that I felt particularly confident to wade into Visual Studio and start writing management packs. I understood the basic mechanics, but I lacked the ability to fill in the inevitable gaps of knowledge to be able to author custom MPs that met real enterprise level business needs.
Unfortunately, a lot of the best how-to examples and step-by-step tutorials tend to be a little generic. I suspect this is done intentionally to minimize complexity as much as possible. The hope being that a budding MP author can learn the fundamentals and then extrapolate from the excellent guide on “how to author a custom MP that no one would ever import into their real environment”, and later apply this knowledge to some real-world problem.
My brain tends to not work that way. It is easily distracted by shiny objects and Wikipedia. To learn I need concrete real-world examples, problems, deadlines. For me the most valuable training in MP authoring came not from all the guides and links referenced above, but from a single one hour Lync call with a senior colleague at Microsoft. I had a specific question that I didn’t know how to solve and step-by-step over the course of an hour he walked me through how to build an MP that addressed that request.
I really wish there were a ton of Authoring videos like that call out there following the simple formula:
Real-world enterprise monitoring problem that is not currently addressed by a Management Pack + Screen capture video that walks through the process every step of the way.
Sadly as fun as it would be to simply complain, I think there might be some small value in me adding what little I know about MP authoring to the general ether following the format above.
I had toyed with the idea of doing Livecoding.tv or live Twitch.tv sessions, but my home internet connection these days is DSL so the upload streaming experience is lacking, so these will be pre-recorded sessions with some light editing.
The first installment can be found here:
I have about 10 videos planned so far and if the first few are of any use to the community I will shoot for publishing a new video every two weeks until I run out of ideas.
For some background. The question that led to this post was in regard to being able to access properties that SCOM was discovering in order to detect config drift in some networking hardware. Normally when I get a question like this my first answer is don’t use SCOM for this–use OMS, SCCM, or some other tool designed specifically for this purpose. With that said, they had a specific use case that made sense, and SCOM was already collecting all the properties they cared about as part of a 3rd party Management Pack so the primary goal became giving the customer a better picture of where this data gets stored and the easiest way to access it.
First way of getting at discovered property data is via the OperastionsManager Database (The usual caveats about directly querying the OpsDB not being recommended or supported apply.)
There are tables called Dbo.MT which contain the various properties associated with a certain class of object.
If I look at something like SQL 2014 Databases I find the following: (There are more properties, but they get truncated off screen)
Select * from dbo.MT_Microsoft$SQLServer$2014$Database
To make this a little more meaningful we need to pick which tables we are interested in and join FullName from BaseManagedEntityID so we can understand which systems these databases are associated with. For this I wrote the following query:
MT.DatabaseName_3AD1AB73_FD77_E630_3CDE_2CA224473213 As ‘DB Name’,
MT.DatabaseAutogrow_E32D36C4_7E11_62BE_D5B4_B77C841DCCA1 As ‘DB Autogrow’,
MT.RecoveryModel_772240AD_E512_377C_8986_E4F8369BDC21 As ‘DB RecoveryModel’,
MT.LogAutogrow_75D233F6_0569_DB26_0207_8894057F498C As ‘LogAutogrow’,
MT.Collation_4BC5C384_34F3_4C3F_A398_2298DBA85BCD As ‘Collation’,
FROM dbo.MT_Microsoft$SQLServer$2014$Database MT
JOIN dbo.BaseManagedEntity BME On BME.BaseManagedEntityID = MT.BaseManagedEntityId
Which gives this output:
You could also get at similar data through the SDK via PowerShell (This would technically be the officially supported technique, though sometimes not as flexible as SQL). To do this you would use something like:
$WindowsServerClass= Get-SCOMClass -Name Microsoft.SQLServer.2014.Database
$ServerObjects = Get-SCOMClassInstance -Class $WindowsServerClass | Select Fullname, *.DatabaseName,*.RecoveryModel,*.DatabaseAutogrow,*.LogAutogrow,*.Collation
This will give you results that look as follows: (I just arbitrarily picked a few properties, there are more available that you can look at with either I get-member or | Select *
From there we can make things a little more readable with the following:
$WindowsServerClass= Get-SCOMClass -Name Microsoft.SQLServer.2014.Database
$ServerObjects = Get-SCOMClassInstance -Class $WindowsServerClass
$ServerObjectsB = $ServerObjects | Select *.DatabaseName, *.RecoveryModel, *.DatabaseAutogrow, *.LogAutogrow, *.Updateability, *.UserAccess, *.Collation, *.Owner, *.ResourcePool | FT
From there we started playing around with ways to quickly identify differences:
This is still a work in progress, but I figured I would share in case this can be of use to anyone.