In MOM 2005 it was pretty straightforward to create a rule which would occur only during specific hours of the day. With Operations Manager 2007 this became a lot more complex to accomplish. There are some great discussions out there about how to add scheduling but each of them relies upon a level of comfort of editing XML which I just don’t have (I could have lived a full life without ever having even seen XML). There are some great blog articles out there about this topic but none of them seemed to address my question head-on: “How do I take a rule that I created in the Operations Console and schedule it to run during specific hours without hacking through XML?”. While I understand that it’s not best practice to design rules in the Operations Manager console it is often a way to quickly generate a rule or monitor so it’s used relatively often from what I have seen to perform tasks like this. My requirement was to create a rule which would not fire if the condition was found between midnight and 7:00 am.
I had previously created rules in the Operations Manager console and thought I could just edit them in the authoring console and add a schedule to make it work. It wasn’t until I read through Steve Rachui’s article (the link at the end of this blog article) that I had the lightbulb moment. While adding the schedule to the rule via the authoring console would have worked there was a step that I had missed! Here’s a summary of the steps that I took to add scheduling to an existing rule:
1) Created a management pack in the Operations Manager console
2) Created a rule which fired when an event 1000 was found in the event log and stored it in my new management pack
3) Using the authoring console, I connected and did a tools, Import MP from Management Pack
4) I chose my custom management pack and after locating any management packs it was dependant upon (look in the %programfiles%\System Center Operations Manager 2007 folder, or it is really helpful to use the management pack download capabilities within the Operations Manager console to download all management packs from the catalog into a temporary directory like c:\temp) I was able to find and edit my rule (under Health Model, Rules).
5) Edit the rule, on the model tab and do a create for the Condition Detection section.
6) Searched on schedule, and typed in “System.ScheduledFilter” below:
7) Edited the condition detection to set my scheduling configuration for the rule.
8) Clicked on the configure button shown below.
9) There are multiple options available but for my configuration I wanted the option to “Process data except during the specified time”.
10) Next I specified my timeframe (every day of the week between 12:00 am – 7:00 am).
11) Here’s where the trick hit. If you skip this step the scheduling will not work. Click on the edit tab shown below:
12) Editing brings up the actual XML in notepad – but all we need to do here is a quick substitution and we’re out of XML territory. We originally see something like the following:
(results shown below)
14) Export the management pack back to the management group.
15) Now if you edit the rule in the Operations Manager console it adds the Condition which can now be edited or renamed.
16) If you use the edit button this should look really familiar!
Summary: If you are looking for a simple way to change a rule to run only during specific hours (or to exclude specific hours) open the management pack in the authoring console, add a condition to the rule to use the System.SchedulerFilter and configure the scheduler as needed, edit the XML to replace “<TimeXPathQuery>TimeXPathQuery</TimeXPathQuery>” with “<UseCurrentTime>true</UseCurrentTime>” and export the updated management pack back into the management group! Once you have done this a couple of times this is literally a couple of minutes to take an existing rule and give it the ability to be run on a schedule.
The following are great readings to go through on this topic which have really helped me out:
http://nocentdocent.wordpress.com/2009/05/01/opsmgr-r2-authoring-console-business-hours-monitor/ – Written by Daniele Grandini