Action Execution 'Run Only When' patch window open

I am attempting to run an Action so that when an endpoint reaches its scheduled maintenance window, the system will start patching as scheduled.
I have been just setting the ‘Starts on…’ and ‘Ends on…’ date and times and it has been working flawlessly. However, scheduling over 80 patching actions per month due to varying maintenance windows throughout each week of the month, day of the week and hour of the day/night takes up entirely too much of my time that could be spent doing more productive things.
I found a way to do this by setting variables on each endpoint to set a ‘Patch Window Open’ variable to either True or False. If the system is within the maintenance window, it evaluates to True. If it’s not within the window, it’s evaluates to False.
The variables specify the ‘Patch_Week’ of the month (0-5) beginning with the first Monday as the start of Week 1, the ‘Patch_Day’ (Monday thru Sunday), the ‘Patch_Start_Time’ (4 digit 24-hour time - i.e. 2200 = 10pm), and ‘Patch_End_Time’ (4 digit 24-hour time).
For example:
image
If the relevance (below) equates to ‘True’, the variable of ‘Patch Window Open’ is set to True, meaning the system is within the maintenance window and can begin patching. The relevance statement is as follows:

===========================================================
if (if current date < (first monday of current month_and_year) then “0” else if current date >= (first monday of current month_and_year) and current date < ((first monday of current month_and_year) + (7*day)) then “1” else if current

date >= ((first monday of current month_and_year) + (7day)) and current date < ((first monday of current month_and_year) + (14day)) then “2” else if current date >= ((first monday of current month_and_year) + (14*day)) and current date

< ((first monday of current month_and_year) + (21day)) then “3” else if current date >= ((first monday of current month_and_year) + (21day)) and current date < ((first monday of current month_and_year) + (28*day)) then “4” else if

current date >= ((first monday of current month_and_year) + (28*day)) then “5” else “Undefined”) = (if exist values of settings “Patch_Week” of client then value of setting “Patch_Week” of client else error “not set”) and day_of_week of

current date as string = (if exist values of settings “Patch_Day” of client then value of setting “Patch_Day” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time (local time

zone) of it) of now >= (if exist values of settings “Patch_Start_Time” of client then value of setting “Patch_Start_Time” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time

(local time zone) of it) of now <= (if exist values of settings “Patch_End_Time” of client then value of setting “Patch_End_Time” of client else error “not set”) then True else False

This works well and functions properly as long as the maintenance window does not cross over midnight into a new day (i.e. - the maintenance window starts at 10pm and runs until 2am). There are several server groups where this is the case, and thus cannot use the relevance as is currently in place.

I would like to modify the relevance statement to account for a ‘Patch_Start_Day’ and ‘Patch_Start_Time’ as well as a ‘Patch_End_Day’ and ‘Patch_End_Time’ to allow for a window crossing over midnight.
The relevance I currently have for this is not functioning properly and is as follows:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

if (if current date < (first monday of current month_and_year) then “0” else if current date >= (first monday of current month_and_year) and current date < ((first monday of current month_and_year) + (7day)) then “1” else if current date >= ((first monday of current month_and_year) + (7day)) and current date < ((first monday of current month_and_year) + (14day)) then “2” else if current date >= ((first monday of current month_and_year) + (14day)) and current date < ((first monday of current month_and_year) + (21day)) then “3” else if current date >= ((first monday of current month_and_year) + (21day)) and current date < ((first monday of current month_and_year) + (28day)) then “4” else if current date >= ((first monday of current month_and_year) + (28day)) then “5” else “Undefined”) = (if exist values of settings “Patch_Week” of client then value of setting “Patch_Week” of client else error “not set”) and day_of_week of current date as string = (if exist values of settings “Patch_Start_Day” of client then value of setting “Patch_Start_Day” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now >= (if exist values of settings “Patch_Start_Time” of client then value of setting “Patch_Start_Time” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now <= (if exist values of settings “Patch_End_Day” of client then value of setting “Patch_End_Day” of client else error “not set”) and ((two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now >= (if exist values of settings “Patch_End_Time” of client then value of setting “Patch_End_Time” of client else error “not set”) then True else False

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Example screenshot: image

I’m no relevance expert by any stretch of the imagination, and would appreciate assistance to get this to function properly.

TIA
Lance

I’ve done something very similar, only in my case I use a Client Setting for the maintenance window because I don’t have a regular schedule (it varies every month).

I’d suggest you start by reading @brolly33’s excellent blog post at https://www.ibm.com/developerworks/community/blogs/e9d21113-aa93-467e-ac77-a0d20a21eaec/entry/Simple_Answers_Maintenance_Window_related?lang=en

You might also be served by setting a duration for the patch window rather than an end time. So you could compare (now > defined start time and now < defined start time + defined duration) and not have to worry about midnight rollovers.

2 Likes

This is something we are also looking into, using brolly33’s excellent blog as a guideline (we currently use client lockstate to prevent actions running but that does have some drawbacks) . We have a different set of configuration options that you but using data from the registry that defines the allowed maintenance window, we then have a property evaluate as either True or False which we would then use as a constraint for either actions or baseline deployments. Take into account the constraints operators relate to numerical values depending what operators you use (@strawgate gives some extremely helpful details about this on Using “run only when” to contrain actions). We developed a configurator fixlet using HTML combo boxes so we can deploy the maintenance windows configuration to selected endpoints

1 Like

Would anyone be able to help with the relevance for the properties in the screenshot from this thread?

image

Anyone have the link to the new location of @brolly33 post? The IBM link is not working anymore

Perhaps you can find some useful information in this post: https://www.linkedin.com/pulse/bigfix-tips-tricks-part-4-dynamic-patch-maintenance-using-consuegra/

I checked the internet archive, but it looks like brolly33’s post was not captured there.