다음을 통해 공유


Creating the ‘Contained Objects’ Widget in SCOM

Disclaimer: Due to changes in the MSFT corporate blogging policy, I’m moving all of my content to the following location. Please reference all future content from that location. Thanks.

The SCOM product team has been pretty good about providing all sorts of interesting widgets to use to display dashboards inside of SCOM.  Most are very easy to toss together, and with a few simple clicks, you have a nice working dashboard.  However, I came across one that is used on the state tiles view that does not exist as a widget in SCOM.

The state tiles is a pretty nice view when using objects directly, as there’s a ‘contained objects’ view which allows you to see all the hosted objects on a Windows computer that are being monitored by SCOM.  I get asked a lot “What are you monitoring on XYZ system?” and the answer is often somewhat vague, as each system is different and the answer can range to the simple such as disk, CPU, and RAM, to application level items such as SQL SPNs, Exchange DAGs, etc.  This little view is really nice in that it tells you precisely what is contained at the object.  The problem, however with the state tiles view is that it only really does this when you scope each object individually.  When scoped as a group, the contained objects view only shows the objects contained inside of the group, and most of the other views offer little info.  Here is my state tiles example.

image

I’m not a huge tile person personally, but as you can see, I have a single tile for a SQL server, SharePoint server, and then the all windows computer group.  I click on the tile for all windows computers, and this is what I see.

image

I see a nice alert summary, but not much in the health, the host information, or even the object details.  My contained objects has a nice summary of what is contained in the group, but nothing useful about what is in the object itself.

For my SQL server, I have much more useful information. I can see that I’m watching the SQL object, local drive, report console, Ethernet, etc.  I can see what is monitored, and even items that are discovered but not being actively monitored.  In short, I can see everything on this server.

image

Creating a state tiles dashboard for a handful of servers really isn’t that big of a deal in the long run, but doing something like that for several dozen servers suddenly  becomes much more cumbersome.  I had a client who wanted something at an AD site level, which in their case was more than 70 servers.  Scoping by a group was completely useless.  To make that work, I needed to find the “contained objects” or “contextual contained objects” wizard, but alas, there isn’t one there.

Obviously, this is doable as we see it in this dashboard, but searching on the internet revealed absolutely nothing, until I came across this nice little script written by Daniel Savage.  It’s designed to work with the “PowerShell Grid Widget in SCOM”.  Simply add the widget and paste his code into there, and you have it.  By the way, this site has a few other PowerShell related dashboard snippets which can be very useful.

Now perhaps you don’t want to see the non-monitored components.  Well, that’s just as easy.  It’s the same code, with one more if statement (see below).

Param($globalSelectedItems)

foreach ($globalSelectedItem in $globalSelectedItems){   $globalSelectedItemInstance = Get-SCOMClassInstance -Id $globalSelectedItem["Id"]    foreach ($relatedItem in $globalSelectedItemInstance.GetRelatedMonitoringObjects())   {     if ($relatedItem.HealthState -ne 'Uninitialized')     {             $dataObject = $ScriptContext.CreateFromObject($relatedItem, "Id=Id,State=HealthState,DisplayName=DisplayName", $null)             $dataObject["ParentRelatedObject"] = $globalSelectedItemInstance.DisplayName             $ScriptContext.ReturnCollection.Add($dataObject)          }   }}

In the end, it’s pretty easy to do.  Here’s an example.  I have a state widget on the top scoped to my “All Windows Computer” group, as I showed above, but I’ve added my contained objects code and a contextual alert widget just for grins.

image

As you can see, I now have a simple dashboard with much more useful information.

Technorati Tags: Contained objects,widget,powershell grid

Comments

  • Anonymous
    March 06, 2017
    Morning, I like your post, it is just what I have been looking to do. Would you have a post that walks through doing just as you describe above.Thanks,Tony
    • Anonymous
      March 06, 2017
      Hi Tony, all you need to do is setup a grid based dashboard and add the code on my page to the powershell grid widget.