Automatic start/restart recovery action for Windows Service in SCOM 2007


I am not sure if I am missing something, or simply nobody has thought of an easier way of doing this but I have run into this issue twice already. I am setting up SCOM 2007 (once with RTM +SP1 and once with R2) and I setup standard Windows service monitoring, so that I am notified when a Windows service stops or dies. The issue is that there seems to be no EASY way to create an automatic recovery action for the monitor to restart the service if it goes down.

If you try to modify to default monitor “Service Running State” from the Windows Service Library management pack and add a recovery action to it to start the service if the monitor goes into a Critical state, you would get this pleasant error:

Date: 1/28/2010 10:08:19 AM
Application: System Center Operations Manager 2007 R2
Application Version: 6.1.7221.0
Severity: Error
Message:

: Verification failed with [1] errors:
——————————————————-
Error 1:
: Failed to verify Recovery [MomUIGenaratedRecoverybdae2c715da44a0797df0f2dbd5b41dc]
The requested ManagementPackElement [Type=ManagementPackMonitor, ID=Microsoft.SystemCenter.NTService.ServiceStateMonitor] in ManagementPack [ManagementPack:[Name=Microsoft.SystemCenter.NTService.Library, KeyToken=31bf3856ad364e35, Version=6.1.7221.0]] is not Accessible outside this ManagementPack.
——————————————————-

Failed to verify Recovery [MomUIGenaratedRecoverybdae2c715da44a0797df0f2dbd5b41dc]The requested ManagementPackElement [Type=ManagementPackMonitor, ID=Microsoft.SystemCenter.NTService.ServiceStateMonitor] in ManagementPack [ManagementPack:[Name=Microsoft.SystemCenter.NTService.Library, KeyToken=31bf3856ad364e35, Version=6.1.7221.0]] is not Accessible outside this ManagementPack.
: Failed to verify Recovery [MomUIGenaratedRecoverybdae2c715da44a0797df0f2dbd5b41dc]
The requested ManagementPackElement [Type=ManagementPackMonitor, ID=Microsoft.SystemCenter.NTService.ServiceStateMonitor] in ManagementPack [ManagementPack:[Name=Microsoft.SystemCenter.NTService.Library, KeyToken=31bf3856ad364e35, Version=6.1.7221.0]] is not Accessible outside this ManagementPack.
: The requested ManagementPackElement [Type=ManagementPackMonitor, ID=Microsoft.SystemCenter.NTService.ServiceStateMonitor] in ManagementPack [ManagementPack:[Name=Microsoft.SystemCenter.NTService.Library, KeyToken=31bf3856ad364e35, Version=6.1.7221.0]] is not Accessible outside this ManagementPack.

So… After some digging I found out this is one (or THE) way of getting this accomplished:

1. Create a new Basic Service Monitor under Authoring\Management Pack Objects\Monitors – Windows Service\Entity Health\Availability called Service Run State (the name of the monitor is arbitrary, but it is close enough to the original name, Service Running State, that it makes sense…). Make sure you don’t add it to the Default Management Pack.

2. For Service Name enter this string:

$Target/Property[Type=”MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService”]/ServiceName$

Update: This string may vary for you. The best way to find it (and you should probably do that, instead of simply copying mine) is to try and create a recovery action in the original Service Running State monitor. When you get to the point of entering a command, click the arrow next to the Parameters box. The fly-out will have a list of parameters. Pick the one on top called Service Name. The UI will place the string in the parameters box. Once you have it there, copy it and save it. Cancel the Create Recovery Task Wizard. In my latest install the string looks like this:

$Target/Property[Type=”MicrosoftSystemCenterNTServiceLibrary6172210!Microsoft.SystemCenter.NTService”]/ServiceName$

3. Accept all other defaults. Once it is created, go into the properties of it, under Diagnostics and Recovery

4. Create a Recovery Action Run A Command. The command line should be:

Full path to file: net.exe

Parameters: start “$Target/Property[Type=”MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService”]/DisplayName$”

5. Save it.

You are done.

— If you this post helped you, please, rate it/”Like” it.

Advertisements

4 Responses to “Automatic start/restart recovery action for Windows Service in SCOM 2007”

  1. Alex Hdez Says:

    Hi
    I´m trying to monitor OCS 2007 services
    but I´m new in this area, so I don´t understand what I must do with this string
    $Target/Property[Type=”MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService”]/ServiceName$

    I must exchange only /ServiceName$ by RTCACPMCU? or
    I must kust copy the string in Service Name field?

    sane question about
    Parameters: start “$Target/Property[Type=”MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService”]/DisplayName$”

    Can you explain me this?
    Best Regards
    Alex

    • The string $Target/Property[Type=”MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService”]/ServiceName$ is a variable – SCOM will replace it with the name of the service (the actual name, not display name) so you must use it exactly as I posted it.

      The answer is the same about the net start string – paste the string I posted into the parameter box in the rule and SCOM will replace the name with the Display Name of the service during execution.

      BTW, the reason I use …/ServiceName$ in one and …/DisplayName$ in the other is that the “net start” command does not recognize the service name, but instead needs the friendly Display Name (e.g. the Service Name for the Computer Browser service is “Browser“, while the Display Name is “Computer Browser“. This is also why you want to enclose the parameter string variable in quotes – most Display Names have spaces in them, while the service names “usually” don’t.

      HTH

  2. What is the procedure to restart the service irrespective of its state?

    • If you mean while it is running – you have the option to do it while in the SCOM console – under Monitoring, go to Windows Service And Process Monitoring, find the service you want and select it. In the Actions menu on the right there are options to start and stop (Start NT Service/Stop NT Service)

      If you mean for SCOM to restart it, then it is a little more complicated. You will need some sort of a trigger to tell SCOM when to do it – like time of day, or event ID in the event log of the server or breaching a performance counter. Once you decide on trigger, you will need to create a custom monitor, target it to the service object and set it up to restart the service (for time trigger you can use custom Scripting monitor, for the other two it is pretty obvious :))

      Let me know if I misunderstood.

      HTH

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: