What Monitors, Rules and Discoveries are running on an OpsMgr Agent?
How often do you get the question: “What Monitors, Rules and Discoveries are running on an OpsMgr Agent?” from your co-workers? Especially when they don’t have a clue what is being monitored for their servers.
Most of the time you just use the EffectiveConfigurationViewer from the OpsMgr Resource Kit. It let’s you pick different objects, besides the Agents you are monitoring with OpsMgr.
It’s shows quite some interesting information and let’s you export the result to an XML file. But that’s not always your co-workers want’s to see. IMO they often want to have an Excel sheet with all the Monitors and Rules running on a specific Agent. That’s what they understand and can easily read.
What options do you have now?
- You can try to build some wrapper around the exported XML file, with PowerShell.
- Use a third-party tool, like MP Studio to export the Monitors, Rules and Discoveries (workflows) running on an Agents
- Create a PowerShell script that does the magic
Let’s look at the options.
Build some wrapper around the exported XML file
This is possible, but would not give us all the information we would like to see. It can only give us the Monitor/Rule or Discovery Name and it’s state. We are interested in much more, like: Name, Description, Type, Management Pack, Overrides, etc.
So let’s skip this option.
Use a third-party tool
In the next version of MP Studio a new feature called Silect’s Agent Explorer will be added. I’m lucky to be able to test the latest evaluation version of MP Studio and it will be able to give you almost all the information you probably need.
If you want to see what Monitors, Rules and Discoveries are running on an Agent, you can use the Explore workflow tasks feature (Agent Explorer) to view all workflows running on all agents or a specific server.
It will give you an overview of all Workflows running on a specified Agent and you can export the result to Excel.
This is almost what I want to see. The only thing I’m missing in the current Agent Explorer feature is if there are overrides configured for a Monitor, Rule or Discovery. I talked with Randy Roffey from Silect about this, and he told me that would be challenge, because there can be be multiple override settings for the same workflow. Good point, but it would be nice to see if there are any overrides for a workflow, than you can always manually check the configured overrides later.
PowerShell script that does the magic
The last option we have is to create a PowerShell script that does all we want. And what do we want? We want an Excel sheet with all Monitors, Rules and Discoveries running on an Agent, with their Type, DisplayName, Description, possible Override and ManagementPack.
Here you can see again 768 workflows running on the OpsMgr Agent (just like in MP Studio) but it also shows if there is an Override* being configured for the Monitor, Rule or Discovery. This still does not mean that the override is applicable for the Agent though.
* Retrieving the Override information can be a time (CPU and Memory) consuming exercise, so I commented that part of the PowerShell script.
Drawback I found using this script is the impact on the CPU and Memory when running this script and the time it takes before this script finishes. So you may take that into consideration when you run this script. First it retrieves all the Monitors, Rules and Discoveries and saves that in Memory and loops through this data in memory for finding the workflow information.
When I tested this script in my small OpsMgr 2007 R2 environment it took 1:47 seconds to run.
But it can also take much longer , like 27 minutes in another larger OpsMgr 2007 R2 environment.
If you are still interested to give the script a try, here it is:
|
Disclaimer
This sample is not supported under any Microsoft standard support program or service. This sample is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of this sample and documentation
remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of this sample be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use this sample or documentation, even if Microsoft has been advised of the possibility of such damages.
Comments
- Anonymous
January 01, 2003
Here's one of the errors Method invocation failed because [System.Object[]] doesn't contain a method named 'getman agementpack'. At C:tempscomgetinfo.ps1:118 char:36
- $mp = $monitor.getmanagementpack <<<< () + CategoryInfo : InvalidOperation: (getmanagementpack:String) [], RuntimeEx ception + FullyQualifiedErrorId : MethodNotFound
Anonymous
January 01, 2003
Sorry that didn't make sense. I need a dump of all monitors and rules running for a Linux server that is monitored by SCOM. I have made some progess. I figured out that I need to use the healthservice for the Management Server that is the proxy for the Linux servers. Here is my curent problem. I am monitoring 60 Linux servers with this MS. When I run the report (which takes 4 hours) I get 60 instances of each monitor, I assume one for each server. My question now is this. Is there a way to display which Linux server each rule or monitor is for. For Example: Monitor : Logical Disk % Free Space : Red Hat Enterprise Linux Server 4 Logical Disk % Free Space Monitor : Red Hat Enterprise Linux Server 4 Operating System : <Linux Server name>Anonymous
January 01, 2003
Ran OK on my laptop connecting to my slow dev RMS, took about 20 min. I've enabled the overrides part of the script and am re-running it, it's been chewing over an hour now!Anonymous
January 01, 2003
Hi Alyssa, I've not had time to look into this. Hope Dom has found a way and shares his info. /StefanAnonymous
January 01, 2003
Hi Alan, Thanks for the tip! Not thought about using the -criteria paramater. When I've some more time, I'll try to write an update. But if you have some time you can always try to improve the script yourself :-) /StefanAnonymous
January 01, 2003
Hi Dom, Great to hear you like it. /StefanAnonymous
January 01, 2003
Here is a less complicated script that will show running workflows on either the RMS or an Agent.
==============================================================================================
Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 2011
NAME: ps.getAgentWorkflows.ps1
AUTHOR: microsoft provided.
DATE : 5/24/2012
COMMENT: used to see whats running from the Agent health service
==============================================================================================
$server = "Your_RMS" Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"-ErrorVariable errSnapin; Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin;new-managementGroupConnection -ConnectionString:$server -ErrorVariable errSnapin; Set-Location $server -ErrorVariable errSnapin;
Create the Task object
$taskobj = Get-Task | Where-Object {$_.Name -eq "Microsoft.SystemCenter.GetAllRunningWorkflows"}
Grab HealthService class object
$hsobj = Get-MonitoringClass -name "Microsoft.SystemCenter.HealthService" #Specify the Server $server = "Server_You_want_to_check"
Find HealthService object defined for named server
$monobj = Get-MonitoringObject -MonitoringClass $hsobj | Where-Object {$_.DisplayName -match $server}
See what tasks are running
$taskOut = Start-Task -Task $taskobj -TargetMonitoringObject $monobj [xml]$taskXML = $taskOut.OutPut $ruleCount = $taskXML.DataItem.Count $taskOut.OutPut | Out-File c:output1.xml
Anonymous
January 01, 2003
Hi ? Cannot remember if I used some code about the overrides from a script from Daniele, but we work ofter together so it could be;-) Sorry if I forgot to mention Daniele...Anonymous
January 01, 2003
Finished after 3+ hrs with the overrides enabled and it failed. I will re-run it and capture the error for you.Anonymous
January 01, 2003
Is ther a way to modify this for Linux (RHEL)?Anonymous
January 01, 2003
Hi BHansen, I don't understand what you mean by "is there a way to modify this for Linux (RHEL)?" Could you please explain?Anonymous
January 01, 2003
Hi Andy, Yes it's performance intensive :-) Talked to James Brundage yesterday evening and asked for some pointers on performance improvements, but have not had time to look into them. And I warned you ;-) StefanAnonymous
December 02, 2010
Hi Andy, I've seen that error before. That will happen when there are some monitors with the same name. That's why I added -unique for the discoveries (that's where I had seen that error before). Maybe I also need to that for the monitors and rules. Because when there are multiple monitors with the same name it will became an array. Technical story ;-) Will look into that. Maybe you can try to add #Retrieve Monitors $monitors = get-monitor | select-object -Unique #Retrieve Rules $rules = get-rule | select-object -Unique #Retrieve Discoveries" #Used the Group-object because there are some discovery rules with the same DisplayName $discoveries = get-discovery | select-object -Unique Thanks for testing this...Anonymous
December 03, 2010
Very nice Stefan. I really hope we see some progress in this on OM vNext. I also wanted to mention that several of this script looks very much alike to an overrides script Daniele Muscetta did a few months ago. Was some of this maybe sourced from Daniele also? See "Command Shell: Dumping all overrides in Operations Manager 2007 (Script) " - www.systemcentercentral.com/.../Default.aspx. This was also enhanced to create a proper overrides report at www.systemcentercentral.com/.../Default.aspxAnonymous
May 06, 2011
Can we use SQL query to determine the data? If so , can i have the Query.Anonymous
May 18, 2012
Hello Stefan, Is it possible to output a couple more pieces of information using your PowerShell script as follows: 1: Wheather or not the Monitor or Rule is currently configured to "Generate Alert" 2: If an override is configured the value or the override/s in question I will have a go at adjusting the powershell script, however I would be grateful if you would let me know the answer/code to the above two questions. Thank you in advance Ernie [removed email address]Anonymous
May 24, 2012
The comment has been removedAnonymous
April 04, 2013
Have you thought of not querying all the monitors, rules and discoveries? If you use the -criteria parameter when getting these objects instead of using where, you'll certeinly use much less CPU and memory with the same results! Guess I'll need to do this, so if I really do, I'll post it here :) Great post, by the way!Anonymous
August 01, 2013
Hello, Excellent script thanks a lot I got all the monitors and rules listed with threshold also which is really good. Now I need the link to the server name...Still looking Thanks, DomAnonymous
August 21, 2013
I also found this script to be almost perfect. One question - how do I get the agent name listed with each row? Dominique, did you find a way? Thanks in advance, --AlyssaAnonymous
January 17, 2014
A small, but usefull link collection to use for configuration and upgrading System Center OperationsAnonymous
February 07, 2014
Hi Stefan. This looks like an excellent script. Is there any way to get this to work in SCOM 2012? I'm a SCOM novice and I don't think I'm competent enough just yet to change the cmdlets and make it work. Or maybe there's another way to make it work in 2012 that I haven't found yet? Thanks, /Erik