How to create a custom service monitor and automatically restart it

 

 

For this little demo, we will be using the Print Spooler service and targeting Windows Operating System

 

This will target all version of Server and Client OS but I won’t go into rollups here

 

 

In SCOM Console

 

Authoring > Monitors > Create a Monitor > Unit Monitor

 

image

 

 

Take a look at the varying out of the box options, many different monitor types available.

 

We select > Basic Service Monitor

 

image

 

Make sure you choose an appropriate Management Pack to save the monitor into.

I recommend having a Custom Management Pack per Imported Management Pack to ensure you don’t cross the streams…

 

For this demo in my lab I am choosing my capture all monitors management pack

 

image

 

Enter a distinguishable name that meets your naming convention.

 

Select the Monitor Target

 

Choose parent monitor

 

And I recommend you disable the monitor by default

 

image

 

Search and select the class target

 

image

 

Enter the service name or ideally search for it.

 

image

 

Choose the computer name you know has the service you are targeting to get the correct name

 

image

 

The monitor conditions for service monitors are static

 

image

 

Enable the Alerts and Auto resolve.

 

Check the Alert name and align the priority and severity accordingly

 

image

 

Click Create

 

image

 

 

Ok, great… The Monitor and Alert is created.

 

Next is to create the recovery task.

 

Find the newly created Monitor

notice I have limited my search scope to the management pack object defined in the monitor

 

image

 

Right-click and choose properties.

 

The pertinent tab is the Diagnostic and Recovery tab

 

image

 

 

Add > Recovery for critical health state

 

image

 

Choose Run Command

 

image

 

Define the name. Again follow your naming conventions and keep it clear

 

For this task, I am opting to recalculate monitor state

 

image

 

To start a service, we need to run the ‘net start %servicename%’

 

Hint: not sure on the command.. run it from cmd on a server with the service… i.e. ‘net start spooler’ is the pertinent command.

 

image

 

Create!

 

image

 

After a moment, the task will appear in the recovery tasks field

 

image

 

Ok…

 

image

Leave A Comment