Once you create a monitor for Linux services and wonder how to create a recovery task for service restart. Here is how you can do that.


The following would go in a custom MP that has the Unix Library MP defined in the References sections with the Alias "Unix".

 Insert this in the  section, right after the closing </Discoveries> tag :

 

<Recoveries>
  <Recovery ID="Custom.SCX.Restart.Recovery" Accessibility="Public" Enabled="false" Target="MicrosoftUnixServiceLibrary!Microsoft.SystemCenter.UnixService" Monitor="MicrosoftUnixServiceLibrary!Microsoft.Unix.Generic.Service.Monitor" ExecuteOnState="Error" ResetMonitor="false" Remotable="true" Timeout="300">
  <Category>Maintenance</Category> 
 <WriteAction ID="SSHCommand" TypeID="Unix!Microsoft.Unix.SSHCommand.WriteAction">
  <Host>$Target/Property[Type="MicrosoftUnixServiceLibrary!Microsoft.SystemCenter.UnixService"]/ComputerName$</Host> 
  <Port>22</Port> 
  <UserName>$RunAs[Name="Unix!Microsoft.Unix.PrivilegedAccount"]/UserName$</UserName> 
  <Password>$RunAs[Name="Unix!Microsoft.Unix.PrivilegedAccount"]/Password$</Password> 
  <Command>/etc/init.d/acpid restart</Command> 
  <TimeoutSeconds>120</TimeoutSeconds> 
  </WriteAction>
  </Recovery>
  </Recoveries>

Make sure to define the Display Strings as well:

 

        <DisplayString ElementID=" Custom.SCX.Restart.Recovery">

          <Name>SSH Daemon Recovery</Name>

          <Description>WARNING: Running this diagnostic is unsecure, do not run this against machines you do not trust as it may expose credentials to an unknown system.</Description>

        </DisplayString>

MP attached in this blog. Hope this Helps!!

Note: This MP attached is just an example for HTTPD service, you can change the service name in the override page.

-Chandan Bharti