AutomoxAutomox

Pulling Policy Schedules From API

MinnesotaJoe
March 2, 2020 at 7:02 pm UTC

I am looking at building out some automation in presenting patching schedules and alerting the team that an upcoming patching window is approaching.

In the API I know I get get a policies settings and when I look at what is presented, it isn’t something easily understandable.

4 lines
  "schedule_days": 64,
  "schedule_weeks_of_month": 4,
  "schedule_months": 8190,
  "schedule_time": "02:00",

That info somehow translates to every month, on the 2nd Saturday at 2AM. Is there a way of understanding/translating this to be able to actually read the policy schedule?

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack

Replies (3)

MinnesotaJoeMarch 2, 2020
#1

In doing some digging I found the following.

  • Monday = 2
  • Tuesday = 4
  • Wednesday = 8
  • Thursday = 16
  • Friday = 32
  • Saturday = 64
  • Sunday = 128

So I am guessing schedule_weeks_of_month work the same way. Week 1 is 2, Week 2 is 4 and so on. Figuring out the math on how to tell if say Monday and Friday are picked will take some doing.

Rich-AutomoxMarch 2, 2020
#2

Hey Joe, you’re on the right track here. There’s some more explanation on how it works here

https://docs.automox.com/api/policies/create-a-new-policy#note-schedules

It is essentially a binary representation of the day of week, or week of month, or month of year converted to decimal.

MinnesotaJoeMarch 2, 2020
#3

Rich,
Thanks that makes it so much easier. I was looking at the policy part in the API doc, didn’t think to look at creating a new policy to get the info.