How about Advanced instead of just Simple (System.SimpleScheduler)

Monitoring configurations that require being active on a specific schedule can be dealt in various ways.

One possibility is to take care of the scheduling while implementing the Monitor Type, inserting System.SchedulerFilter condition detection modules in the regular detections for monitor states. Depending on what workflows you are configuring, this might be the right and only approach.

But sometimes, if you can control your starting point (data source), you would be better off (read efficient) having the scheduling implemented right there, at beginning. To explain a bit better, with an example: instead of performing a check with a script at a certain interval and then drop the findings because outside of the schedule, the propose is to execute the script according to the active schedule and not waste resources for nothing, when results do not matter anyhow.

The System.Library Management Pack does not have such Datasource module, but it does provide the right building blocks to create one.
Use the following module to initiate a workflow at a regular interval, on a schedule of your choice.

<DataSourceModuleType ID="System.AdvancedScheduler" Accessibility="Public" Batching="false">
	<Configuration>
	  <IncludeSchemaTypes>
		<SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
	  </IncludeSchemaTypes>
	  <xsd:element name="IntervalSeconds" type="xsd:int"/>
	  <xsd:element name="SyncTime" type="xsd:string"/>
	  <xsd:element name="Schedule" type="PublicSchedulerType" />
	</Configuration>
	<OverrideableParameters>
	  <OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
	  <OverrideableParameter ID="SyncTime" ParameterType="string" Selector="$Config/SyncTime$"/>
	</OverrideableParameters>
	<ModuleImplementation Isolation="Any">
	  <Composite>
		<MemberModules>
		  <DataSource TypeID="System!System.SimpleScheduler" ID="DS1">
			<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
			<SyncTime>$Config/SyncTime$</SyncTime>
		  </DataSource>
		  <ConditionDetection ID="OnScheduleCD" TypeID="System!System.SchedulerFilter">
			<SchedulerFilter>
			  <ProcessDataMode>OnSchedule</ProcessDataMode>
			  <Schedule>$Config/Schedule$</Schedule>
			  <UseCurrentTime>true</UseCurrentTime>
			</SchedulerFilter>
		  </ConditionDetection>
		</MemberModules>
		<Composition>
		  <Node ID="OnScheduleCD">
			<Node ID="DS1"/>
		  </Node>
		</Composition>
	  </Composite>
	</ModuleImplementation>
	<OutputType>System!System.TriggerData</OutputType>
</DataSourceModuleType> 

And here is an example of usage: the rule below will log an event in Application log every 5 minutes on Mon and Tue between 8-9pm and Fri between 10-11pm. Not exactly useful other than getting you started in the right direction.

<Rule ID="Testing.System.AdvancedScheduler" Enabled="true" Target="SystemCenter!Microsoft.SystemCenter.RootManagementServer" ConfirmDelivery="false" Remotable="true" Priority="Normal" DiscardLevel="100">
	<Category>Custom</Category>
	<DataSources>
	  <DataSource ID="Scheduler" TypeID="System.AdvancedScheduler">
		<IntervalSeconds>300</IntervalSeconds>
		<SyncTime></SyncTime>
		<Schedule>
		  <WeeklySchedule>
			<Windows>
			  <Daily>
				<Start>20:00</Start>
				<End>21:00</End>
				<DaysOfWeekMask>6</DaysOfWeekMask>
			  </Daily>
			  <Daily>
				<Start>22:00</Start>
				<End>23:00</End>
				<DaysOfWeekMask>32</DaysOfWeekMask>
			  </Daily>
			</Windows>
		  </WeeklySchedule>
		  <ExcludeDates/>
		</Schedule>
	  </DataSource>
	</DataSources>
	<WriteActions>
	  <WriteAction ID="ExecuteCommand" TypeID="System!System.CommandExecuter">
		<ApplicationName>c:\windows\system32\eventcreate.exe</ApplicationName>
		<WorkingDirectory>c:\windows\system32</WorkingDirectory>
		<CommandLine>/T Information /ID 1 /L Application /D "Testing System.AdvancedScheduler"</CommandLine>
		<TimeoutSeconds>15</TimeoutSeconds>
		<RequireOutput>true</RequireOutput>
		<Files />
	  </WriteAction>
	</WriteActions>
</Rule>
Advertisements

2 responses to “How about Advanced instead of just Simple (System.SimpleScheduler)

  1. Igor Kuznetsov September 23, 2016 at 5:17 am

    God damn, thank you a lot for

    I think a lot how to pass config to scheduler filter …its so easy..just use PublicSchedulerType…

    Like

  2. jaspervd86 July 6, 2017 at 1:03 pm

    Hey just wanted to say this helped me as well, thanks for the post!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: