SCOM 2007- How to create a Diagnostic task for Unix/Linux services

I have already shown on how you can create the recovery task for Unix services in my previous blog Here. And that was meant to run when the state changes from healthy to critical. But personally, i didn't like that. So i feel its good to allow those services to be queries if its stopped or not, and only then run the recovery. Isnt that Cool!!

Here is how you can create a Diagnostic task for Unix/Linux services.

<!-- Add below lines just below the tag </Discoveries> and right above the tag <Recoveries> -->

 <Diagnostics> 
  <Diagnostic Accessibility="Public" ID="Microsoft.Unix.ACPID.Restart.Diagnostic" Remotable="true" Target="MicrosoftUnixServiceLibrary!Microsoft.SystemCenter.UnixService" Enabled="false"              Timeout="300" ExecuteOnState="Error" Monitor="MicrosoftUnixServiceLibrary!Microsoft.Unix.Generic.Service.Monitor" Comment="In response">
      <Category>Maintenance</Category>
    <ProbeAction ID="Invoke" TypeID="Unix!Microsoft.Unix.SSHCommand.ProbeAction">                          
     <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 -status</Command>
    <TimeoutSeconds>20</TimeoutSeconds>
   </ProbeAction>
  </Diagnostic>
</Diagnostics>

Once this is done, please add the Display string as well

 <DisplayString ElementID="Microsoft.Unix.ACPID.Restart.Diagnostic">
  <Name>ACPID Diagnostic</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>
 

Also please make sure to edit your Recovery task Where you have an entry "ExecuteOnState="Error"  Described in https://blogs.technet.com/b/chandanbharti/archive/2011/12/21/creating-the-recovery-task-for-linux-services-in-scom-2007.aspx

So basically you have to change it to ExecuteOnDiagnostic="Microsoft.Unix.ACPID.Restart.Diagnostic"

Remember, this is created under a custom MP. Next import the MP to the console. You should see your Diagnostic task created     

-Chandan