Showing posts with label Rules. Show all posts
Showing posts with label Rules. Show all posts

Friday, January 23, 2015

[OpsMgr 2012] Effective configuration dashboard : What Rule and Monitors are running on my server ? (#Dashboard #SCOM2012 #OpsMgr)

All SCOM professsionals have already been asked "What Rule and Monitors are running on my server ?" and there is no easy way to answer ! In SCOM 2007 there was a Resource kit "effective Configuration viewer" and for SCOM 2012, a new cmdlet has been introduced : Export-SCOMEffectiveMonitoringConfiguration but the result is not user friendly !

PS C:\> $Members = (Get-SCOMGroup –DisplayName "All Windows Computers").GetRelatedMonitoringObjects()
PS C:\> $Members | ForEach-Object { Export-SCOMEffectiveMonitoringConfiguration –Instance $_ -Path "C:\temp\$($_.DisplayName).csv" } –RecurseContainedObjects }



Thom Davis have studied the question and created a Dashboard. Here are the 2 articles that explain how it's made :



His Dashboard also is able to list :
  • Objects and classes on a selected computer
  • Active alerting Rules and Monitors for the selected computer
  • Active non-alerting Rules and Monitors for the selected computer
  • Non-active Rules and Monitors for the selected computer
Download is free here and you are invited to provide feedback, comments, suggestions and dialogue !

This posting is provided "AS IS" with no warranties.

Wednesday, May 22, 2013

[OpsMgr 2007 R2][OpsMgr 2012] Retrieve in one click all knowledge articles for rules and monitors for provided MPs


Hey !

For my own need, I've developed a script to export all knowledge articles from MPs in my SCOM environment. All 'MAMLContent' and 'HTML content' for rules and monitors are exported to HTML files. All files are now shared on my Google drive. 

You want to know what has been written for a monitor or a rule or monitor, why it's generating an alert, What Microsoft gives to fix the issue reported by the alert, just open the MP Knowledge Articles page in the menu on my blog or click on this link : MP Knowledge Articles.


A small issue has been detected : some rules / monitors don't have a Name or DisplayName (Bad provided MPs) and link in the index to page corresponding to the rule / monitor is not available.  Issue is now fixed - I've to re-share all the sources... 

Let me know if you have trouble to use this knowledge extract !

This posting is provided "AS IS" with no warranties.

Thursday, January 31, 2013

[OpsMgr 2007 R2][OpsMgr 2012] Get Rule/Monitor full information from Rule/Monitor name - Powershell script



Today, I've had a request to retrieve all informations for a rule that was generating too much alerts. The rule was give, by it's name and the name was not really user friendly : _08C092E8_FD6F_48b2_BA1E_473C3B84A2F3_.RaiseAlert

Thanks to the Exchange Server 2010 Management pack developper team :)

So I've create a short powershell function to add to my powershell profile :

  1. Function RuleInfo  ([string]$RuleName)
  2. {
  3. get-rule | where {$_.Name -eq $RuleName} | select-object @{Name="MP";Expression={ foreach-object {$_.GetManagementPack().DisplayName }}}, @{Name="MP Version";Expression={ foreach-object {$_.GetManagementPack().Version }}}, Name, DisplayName, XmlTag, Enabled, Category, Target, ConfirmDelivery, Remotable, Priority, DiscardLevel, ConditionDetection, DataSourceCollection, WriteActionCollection, Id, Description, Comment, Status, LastModified, TimeAdded
  4. }
Then I've launch it in my powershell console using the line :

RuleInfo  _08C092E8_FD6F_48b2_BA1E_473C3B84A2F3_.RaiseAlert

Result is like :



 Well done ! :)


I've also created the same function for monitors :

  1. Function MonitorInfo  ([string]$MonitorName)
  2. {
  3. get-monitor | where {$_.Name -eq $MonitorName} | select-object @{Name="MP";Expression={ foreach-object {$_.GetManagementPack().DisplayName }}}, @{Name="MP Version";Expression={ foreach-object {$_.GetManagementPack().Version }}}, Name, DisplayName, XmlTag, Enabled, Category, Configuration, Id, ConfirmDelivery, OperationalStateCollection, Target, ParentMonitorID, Remotable, Priority, RunAs, AlertSettings, Accessibility, Description, LanguageCode, Comment, Status, LastModified, TimeAdded
  4. }
Have fun !

This posting is provided "AS IS" with no warranties.

Monday, April 2, 2012

Responses that are scheduled by the OpsMgr2007 agent are not run at the specified time

What I've read in the Microsoft Support Site is that in Microsoft System Center Operations Manager 2007, you can configure rules to run a script on a timed basis. The rule can be further authored to synchronize at a specific time each day. However, even when you configure a rule to do this, the script may not run at the exact time that is specified in the dialog box. Instead, there may be a small delay. The delay may be anywhere from several seconds to several minutes, depending on how busy the target Health service is and the interval length between scheduled runs.

I had to create a rule that should raised an event in the application event log once per week at a specific time (the aim was to schedule maintenance mode but that is not important to know right now). When the MP has been tested, I have had a strange behaviour : Write Action was scheduled to run between a range of time and on the server, it has been executed more that 30 minutes after the end of the range time given !!!

Since I couldn't test with the MP first developped to launch maintenance mode by ctaching an event, I've recreated a single MP to reproduice the issue.

Please find my test MY here :


It contains :
- 2 write actions
      - One to create an event 9
      - A second one to create an event 10
- 2 rules based on a System.Scheduler Module to execute the 2 write actions.
To be able to test, the schedule has been configured to run each day (instead of once per week)
     - First rule : create event 9 for critical state of the monitor


     - Second rule : create event 10 for healthy state of the monitor

- 1 monitor based on the 2 events (One for healthy state, one for non healthy state)

Here are the result after on day :
- The monitor went to Critical state (event 9 catch) 4 minutes and 42 seconds after the end date given in the module System Scheduler of the rule

Date and Time:  28/03/2012 03:54:42
Log Name:  Application
Source:  SCOMTest
Event Number:  9
Level:  4
Logging Computer: MyServer
User:  NT AUTHORITY\SYSTEM

- The monitor went to Healthy state (event 10 catch) 4 minutes and 42 seconds after the end date given in the module System Scheduler of the rule

Date and Time:  28/03/2012 04:14:57
Log Name:  Application
Source:  SCOMTest
Event Number:  10
Level:  4
Logging Computer:  MyServer
User:  NT AUTHORITY\SYSTEM

Both schedule have been missed for nearly 5 minutes !! Microsoft explains this is the expected behavior because the scheduler module was designed to minimize the resource effect on the agent and was not intended for real-time accuracy. Even if the Health service agent is heavily taxed, any delays in running the response should be no more than one percent of the time since the last scheduled run.

That means that a delay of more that 14 minutes can be seen while scheduling a daily scripts or write action, 1 hour and 40 minutes if the same script or write action is scheduled once a week !

If you want to run an agent response with more accuracy, here is the workarround given by Microsoft :
  • If the response is a script, the Windows Task Scheduler service can be used to run the script at an exact time. Task Scheduler is a service that uses a completely different timing mechanism.
  • If the response is not a script, or the script cannot be run under Task Scheduler, a rule can be authored to run the response when a custom event is observed on the agent. The Windows Task Scheduler can be used to programmatically create an event in the agent’s local event log on a scheduled basis. The Operations Manager 2007 agent would run the response every time that the Task Scheduler adds this custom event to the event log.
So the only way to have more occuracy is to not use SCOM System Scheduler Module ! What a pitty, it was a good way to be able to execute a script at local time on the different servers ...

Have to find an other way...

This posting is provided "AS IS" with no warranties.

Friday, February 24, 2012

[OpsMgr 2007] Export all performances rules by using a PowerShell Script

Here is a new PowerShell script usefull to list in a CSV file all performance rules in your management group - The script use a get-rules with a criteria "Category='PerformanceCollection'". Be carefull also when you developp some MPs to well categorize the rules.

$perf_collection_rules = get-rule -criteria:"Category='PerformanceCollection'"

4 functions are needed for filtering the result :

function GetPerfCounterName ([String] $configuration) {
          $config = [xml] ("<config>" + $configuration + "</config>")
          return ($config.Config.ObjectName + "\" + $config.Config.CounterName)
}


function GetFrequency ([String] $configuration) {
          $config = [xml] ("<config>" + $configuration + "</config>")
          $frequency = $config.Config.Frequency;
          if($frequency -eq $null) {
                    $frequency = $config.Config.IntervalSeconds;
          }
          return ($frequency)
}


function GetDisplayName($performanceRule) {
          if($performanceRule.DisplayName -eq $null) {
                      return ($performanceRule.Name);
           }
          else {
                      return ($performanceRule.DisplayName);
           }
}


function GetWriteActionNames($performanceRule) {
          $writeActions = "";
          foreach($writeAction in $performanceRule.WriteActionCollection) {
                     $writeActions += " " + $writeAction.Name;
           }
           return ($writeActions);
}

You are now able to export the $perf_collection_rules in a CSV file by getting the type, the rule display name, the counter name, the frequency and the write actions.

$perf_collection_rules | select-object @{name="Type";expression={foreach-object {(Get-MonitoringClass -id:$_.Target.Id).DisplayName}}},@{name="RuleDisplayName";expression={foreach-object {GetDisplayName $_}}} ,@{name="CounterName";expression={foreach-object {GetPerfCounterName $_.DataSourceCollection[0].Configuration}}},@{name="Frequency";expression={foreach-object {GetFrequency $_.DataSourceCollection[0].Configuration}}},@{name="WriteActions";expression={foreach-object {GetWriteActionNames $_}}}  | sort Type,RuleDisplayName,CounterName | export-csv "C:\perf_collection_rules.csv" -noTypeInformation


 I don't remember having developped this script by myself - perhaps it was not mine. By the way, this is very usefull.

>>>>>>>>>> Get the PS1 file Here <<<<<<<<<<

This posting is provided "AS IS" with no warranties.

Thursday, January 26, 2012

[Powershell] Get Rules informations and Monitors informations for a spécified MP in SCOM

Here is a short powershell function that create 2 CVS files. One with Rules informations and an other one for Monitors information for a specified MP :
  1. Function RetrieveIDs()
  2. {
  3. Param ([String] $MPName, [String]$Path)
  4. If ($Path -eq "") { $Path=("C:\Temp") }
  5. $MonitorsFile = $Path + "\MonitorsIds.csv"
  6. $RulesFile = $Path + "\RulesIds.csv"
  7. "Files MonitorsIds.csv & RulesIds.csv will be generated in : " + $Path
  8. If ($MPName -eq "") { $MPName=(Read-Host "Enter a Management Pack Name ") }
  9. $mp=Get-ManagementPack | where {$_.name -eq $MPName}
  10. if ($mp -eq $null) {
  11.       "The ManagementPack you have put in argument is incorrect or not found"
  12.       "Here is a list of available MP:"
  13.       Get-ManagementPack | sort -property Name | ft Name
  14.       break
  15.       }
  16. $mp.Getmonitors() | select DisplayName, XMLTag,Category,Name,id, @{name="Description";expression={foreach-object {$_.Description -replace "\n","-"}}}  | export-csv -noTypeInformation -path $MonitorsFile
  17. $mp.Getrules() | select DisplayName,  XMLTag,Category,Name,id, @{name="Description";expression={foreach-object {$_.Description -replace "\n","-"}}} | export-csv -noTypeInformation -path $RulesFile
  18. }
3 ways to use the function :
  •  Just launch the command with no parameter:
PS Microsoft.EnterpriseManagement.OperationsManager.Client\OperationsManagerMonitoring::> retrieveIDs

No cvs files will be created since no MP Name is given. The output of the script will be the list of available MP.

  • Launch the command with 1 parameter that should be a MP Name:
PS Microsoft.EnterpriseManagement.OperationsManager.Client\OperationsManagerMonitoring::> retrieveIDs MyMPName

The cvs files MonitorsIds.csv & RulesIds.csv will be created in the default folder that is C:\Temp. You will retrieve information for the rules and monitors for the MyMPName MP.


  • Launch the command with 2 parameter that should be a MP Name and the path where to create the files :
PS Microsoft.EnterpriseManagement.OperationsManager.Client\OperationsManagerMonitoring::> retrieveIDs MyMPName C:\MyPath

The cvs files MonitorsIds.csv & RulesIds.csv will be created in the C:\MyPath folder. You will retrieve information for the rules and monitors for the MyMPName MP.

This posting is provided "AS IS" with no warranties.

Friday, January 13, 2012

[Powershell] Get Rules information or Monitors information for all MP in SCOM

Here is a short powershell command to list in a .CSV file Rules information for all SCOM MP using a powershell script :

Get Rules Informations :
  1. get-rule | select-object @{Name="MP";Expression={ foreach-object {$_.GetManagementPack().DisplayName }}}, @{Name="MP Version";Expression={ foreach-object {$_.GetManagementPack().Version }}}, Name, DisplayName, XmlTag, Enabled, Category |
    sort-object -property MP | export-csv "C:\Allrules-MyMgtGroupName.csv"
Get Monitors Informations :
  1. get-monitor | select-object @{Name="MP";Expression={ foreach-object {$_.GetManagementPack().DisplayName }}}, @{Name="MP Version";Expression={ foreach-object {$_.GetManagementPack().Version }}}, Name, DisplayName, XmlTag, Enabled, Category, Configuration  | Sort-object -property MP | export-csv "C:\AllMonitors-MyMgtGroupName.csv"
 With the same way, you can imagine listing all classes for all MP : see http://tetris38.blogspot.com/2012/01/powershell-get-classes-information-for.html

This posting is provided "AS IS" with no warranties.