Troubleshooting SMA (Service Management Automation) – Part 2
This is the 2nd part of a 3 blog post series on troubleshooting SMA.
See here for Part 1
In this post, I’ll focus on troubleshooting job states and worker issues.
If you read Part 1, then you should be aware how SMA distributes the jobs to the available workers.
While this mechanism ensures fair sharing of runbook jobs it may also introduce some issues.
##
What’s the matter?
- Workers with assigned jobs can go down, or have other serious problems preventing them from executing jobs
- Jobs may hang in a queued or starting state because of an error described above
While there are runbooks, you don’t care to start them over and over again if they failed, others will be sensitive to states from connected interfaces like Service Manager. You really want to keep the invoked runbook and having it executed properly even if the assigned runbook worker has an issue. So how can you spot on runbooks being in a problem state?
To help me out with housekeeping and troubleshooting SMA, I’ve created a little Powershell Module (SMAHouseKeeping.psm1) to perform the following tasks:
- List Jobs and their assignment to workers (can be helpful to identify a worker with problems)
- Move Jobs from a worker to another worker (can be used to transfer queued or starting jobs to another worker)
Where to get the module
https://gallery.technet.microsoft.com/Module-to-troubleshoot-and-ebafca16
How to use the module
To use the module you need
- to unzip and unblock the downloaded files
- read/write access to the SMA DB
When importing the module you have to pass SQL Server and DB Name as Arguments for the module
Examples:
**Importing the module
(prevent this module from autoloading)
Import-Module C:\Scripts\SMAHouseKeeping\SMAHouseKeeping.psm1 -ArgumentList SQLSERVER01,SMA
(where “SQLSERVER” is the SQL Host and “SMA” is the name of the SMA database)
Listing job to worker assignments
Get-SMAJobAssignment -JobState suspended Get-SMAJobAssignment -JobState queued Get-SMAJobAssignment -JobState starting Get-SMAJobAssignment -JobState stopped Get-SMAJobAssignment -JobState running Get-SMAJobAssignment -JobState completed
Moving queued jobs to another runbook worker
Move-SMAJobQueue -SourceWorker worker1 -TargetWorker worker2 -JobState queued
Canceling a stuck job
Set-SMAJobState -JobID 848ecc75-d5bc-4ef7-b6ac-9335b86a269b -JobState failed
And BTW….
THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER