Scheduling a custom rule to run during specific hours – without a degree in XML

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

image

3) Using the authoring console, I connected and did a tools, Import MP from Management Pack

image

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.

image

6) Searched on schedule, and typed in “System.ScheduledFilter” below:

image 

7) Edited the condition detection to set my scheduling configuration for the rule.

image

8) Clicked on the configure button shown below.

image

9) There are multiple options available but for my configuration I wanted the option to “Process data except during the specified time”.

image

10) Next I specified my timeframe (every day of the week between 12:00 am – 7:00 am).

image

11) Here’s where the trick hit. If you skip this step the scheduling will not work. Click on the edit tab shown below:

image

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:

image

Replace:

<TimeXPathQuery>TimeXPathQuery</TimeXPathQuery>

With:

<UseCurrentTime>true</UseCurrentTime>

(results shown below)

image

13) Save the change and it will alter the screen as shown below: (note the UseCurrentTime true)
image

14) Export the management pack back to the management group.

image

15) Now if you edit the rule in the Operations Manager console it adds the Condition which can now be edited or renamed.

image

16) If you use the edit button this should look really familiar!

image

 

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

http://blogs.msdn.com/b/steverac/archive/2009/11/17/creating-rules-and-monitors-with-a-schedule-understanding-xml-internals.aspx – By Steve Rachui

0 thoughts on “Scheduling a custom rule to run during specific hours – without a degree in XML

  1. Cameron Fuller Post author

    Thank you Stefan! I agree it would be much nicer if all of this was available from the Operations Manager console authoring section. And for anyone who gets the full RSS feed it appears that the < >TimeXPathQuery< > takes out the tags so it looks like just TimeXPathQuery and < >true< > shows up only as true. See the full article for the actual text changes in XML.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.