Problem: Engineers that are working on systems don’t have the ability in SCOM to schedule maintenance modes.
Business case: As we use SCOM and PRTG and we needed to schedule MM not just for windows servers but for unix and for Business Critical Unix applications known as clustered packages.
Research: Found the MM scheduler tool but as this was built for just windows and unix server and was built by a someone else, I need to be able to add additional features and integrate with PRTG. So either spend the time to backward engineer someone else’s solution or build it from scratch.
Scripted Solution with 2 parts.
1. Back end service that stores and executes maintenance modes when needed.
2. Script shared with the business to schedule.
How it all works:
I outlined the workflow for how I wanted it all to work.
For V1 of my solution I’m sticking with command line. Its the fastest way for me to deliver the solution and easiest to fix any bugs.
I used Power Shell to script a service and installing it on the SCOM Management server. I packaged the Power Shell script as an executable service using a power shell command that was developed by Daniel Sorlov. You can find his module here. Also he posted a youtube video on how to package it. Check it out here.
The service checks a file share on the SCOM management server and if any xml files exist processes them.
The XML contained details like customer, server, start date time, duration, frequency, frequency data, end date time, reason and comment.
The service checks if there are any errors in the xml, if the server is already in maintenance mode and if its a unix package. This last check is what make this different than the other SCOM maintenance mode schedulers, it intergrates also with PRTG and pauses the PRTG sensors for the specif packages. This is done by extracting the sensor ID’s for each package and placing them into a CSV where the service checks for what sensors it needs to place into maintenance mode. PRTG’s API make this easy to achieve.
The second component is the interface. So as I said earlier V1 was just a command line tool that generates the xml.
I found that the most difficult part of this process was getting my head around how to get the weekly and monthly frequency working. I did this by representing the frequency data for weekly as: (snip-it from my help file)
If Frequency is “Weekly” you must set the position flag to 1 for the corresponding day of the week and the 24 time
in “HH:mm” format. Format is “0000000 HH:mm”
Monday Flag 1000000 HH:mm
Tuesday Flag 0100000 HH:mm
Wednesday Flag 0010000 HH:mm
Thursday Flag 0001000 HH:mm
Friday Flag 0000100 HH:mm
Saturday Flag 0000010 HH:mm
Sunday Flag 0010001 HH:mm
Note: Combinations can also be used EG Monday and Fridays you can use 1000100
Example “1010000 HH:mm” eg Monday and Wednesday at 2pm is “1010000 14:00”
and for Monthly:
If Frequency is “Monthly” you must specify which week of the month (1-5), which day of the week (0-6) and what
time “HH:mm” in 24 hour time format.
Format is “Week Number” “Weekday” “Time” looks like “2 3 21:00” eg 2nd Wednesday of the Month at 21:00
The Week Number flag represents the week of the month:
1 – First week of Month
2 – Second week of Month
3 – Third week of Month
4 – Fourth week of Month
5 – Fifth week of Month
The Weekday flag represents the week day you are after:
So it been running for a few weeks now and after finding a couple of small bugs, i haven’t had any issues with crashing or maintenance modes not being applied. This was an enjoyable learning curve for me as this was weeks worth of effort and I was able to deliver a solution that I was confident about.
Wouldn’t call myself a programmer just yet, but im liking being a script kiddy!
As this was made specifically for my employer and is customized sharing all the source code wont benefit you but on request I can help you develop or share the necessary functions to help you build your own solution.