Kicking off SMA Runbooks from SCSM Part 2: Creating the SMA Monitor Runbook

Author by Duncan Lindquist

In this blog post we will be covering how to create a base Monitor runbook in SMA. You will be able to use this as a starting point for monitoring SCSM and many other things. The next blog post will show how we will target the specific activities that we want inside of SCSM and kick of their specific runbooks.

Creating the SMA Monitor Runbook

The first step will be to create our runbook in SMA. To do this open your WAP admin site and click on the Automation section then click the +New button. 9-New SMA Runbook   Next click Runbook then quick create. Give your monitor a name and description then click create. 10-Create RB   Now we need to open the runbook. To do this click on your runbook from the list on the automation tab. Next click Author then Draft. 11-Open RB   Now that we have our runbook open we are going to add our Base Monitor Script into the workflow section. Below is the PowerShell to add to the workflow.
<#Paramaters MonitorFrequency - The interval in seconds that you want to monitor SCSM #> param ( [int]$MonitorFrequency ) $StartTime = Get-Datewhile($true) { Checkpoint-Workflow $NewStartTime = Get-Datestart-sleep $MonitorFrequency }
Once you have added the PowerShell in it should look like this: 12- SMA Runbook1   Now lets walk through what the script is doing. First we have the while($true) loop set so that it will continually loop through whatever PowerShell we put in it. This will be where we will put our code to get the service manager objects and kick off the runbooks (the methods for this will be in the next blog post). Next we have the start-sleep $MonitorFrequency this allows us to set the how often we want the loop to run. So for this example it will be how often it checks for new runbooks. You may have also noticed the two start time variables in the script. I was using these for some testing and will be using them for logging in the future. This is the base monitor script and will be modified and updated in the future. Those updates will be posted to the blog. Now we have SMA runbooks ready in SCSM as well as our base monitor configured. In the next blog post we will add the PowerShell to get our SCSM activities and Kick of the proper SMA runbook. Stay tuned!
Author

Duncan Lindquist

Service Management & Automation Solution Lead