This document is part of the Operations Manager Management Pack Authoring Guide .
The following procedure shows how to create a recovery that runs after a diagnostic using the Operations Manager 2007 Authoring console and Visual Studio Authoring Extensions. The recovery only runs if the output from the diagnostic meets certain criteria.
This exercise applies to the following products:
Before you perform this procedure, you must first complete the following prerequisite procedures:
The Microsoft System Center team has validated this procedure as of the original revision. We will continue to review any changes and periodically provide validations on later revisions as they are made. Please feel free to make any corrections or additions to this procedure that you think would assist other users
A sample of the completed code for each exercise is available in the TechNet Gallery. There is a separate sample for each exercise that includes the management pack completed at the end of that exercise and each preceding exercise. This strategy allows you to work through each exercise in order and then compare your results. For VSAE, this also includes the Visual Studio solution.
The diagnostic created in this procedure has the following characteristics:
The recovery created in this procedure has the following characteristics:
bTestSuccessful = True
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
If bTestSuccessful = True Then
Call oBag.AddValue("Result","Positive")
Else
Call oBag.AddValue("Result","Negative")
End If
oAPI.Return(oBag)
sDiagnosticOutput = WScript.Arguments(0)
sMessage = "Recovery ran after diagnostic result of " & sDiagnosticOutput & "."
oAPI.LogScriptEvent "MyRecoveryScript.vbs",100,4,sMessage
sMessage =
"Recovery ran after diagnostic result of "
& sDiagnosticOutput &
"."
Set
oAPI = CreateObject(
"MOM.ScriptAPI"
)
oAPI.LogScriptEvent
"MyRecoveryScript.vbs"
,100,4,sMessage
<
Diagnostic
ID
=
"MyMP.MyApplicationEventError.ScriptDiagnostic"
Accessibility
"Internal"
Enabled
"true"
Target
"MyMP.MyComputerRole1"
Monitor
"MyMP.Monitor.MyApplicationEventError"
ExecuteOnState
"Error"
Remotable
Timeout
"300"
>
Category
>Custom</
ProbeAction
"MyDiagnosticScript.vbs"
TypeID
"Windows!Microsoft.Windows.ScriptPropertyBagProbe"
ScriptName
>MyDiagnosticScript.vbs</
Arguments
/>
ScriptBody
>$IncludeFileContent/MyDiagnosticScript.vbs$</
TimeoutSeconds
>300</
</
DisplayString
ElementID
Name
>Run diagnostic script</
Description
Recoveries
Recovery
"MyMP.MyApplicationEventError.ScriptRecovery"
ResetMonitor
"false"
ExecuteOnDiagnostic
ConditionDetection
"FilterDiagnostic"
"System!System.ExpressionFilter"
Expression
SimpleExpression
ValueExpression
XPathQuery
Type
"String"
>Diagnostic/DataItem/Property[@Name='Result']</
Operator
>Equal</
Value
>Positive</
WriteAction
"Script"
"Windows!Microsoft.Windows.ScriptWriteAction"
>MyRecoveryScript.vbs</
>$Data/Diagnostic/DataItem/Property[@Name='Result']$</
>$IncludeFileContent/MyRecoveryScript.vbs$</
>Run recovery script</
Richard Mueller edited Revision 3. Comment: Removed blank headings and fixed duplicate <a name> tags in HTML so TOC works properly, added tags
AndresNa edited Revision 1. Comment: The steps to create the recovery script and add it to the project were missing under the VSAE section. I added a new section 3 for these steps
AndresNa edited Original. Comment: Script name in Step 1 item 3 does not match the script name used in the XML MP code. Changed the name of the script to match was is in the XML
Richard Mueller edited Revision 4. Comment: Replaced RGB values with color names in HTML to restore colors, added tag