Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies To: System Center Operations Manager 2007
Note
This exercise has been updated to include a procedure for Visual Studio Authoring Extensions in the latest version of the Management Pack Authoring Guide on the TechNet Wiki.
The following procedure shows how to create a recovery in the Operations Manager 2007 Authoring console that runs after a diagnostic. The recovery only runs if the output from the diagnostic meets certain criteria. Before you perform these procedures, you must complete the following prerequisite procedures.
How to Create a Class Create the target class for the monitor.
How to create an event monitor Create the monitor that the diagnostic will respond to.
The diagnostic created in this procedure has the following characteristics:
Automatically runs when the MyMP.Monitor.MyApplicationEventError monitor goes to a critical state.
Runs a script that returns a single value in a property bag.
The script itself is only for testing and performs no real function. This script only simulates a script that gathers diagnostic data and returns that data in a property bag.
The recovery created in this procedure has the following characteristics:
Runs only when the value of the Result property in the property bag from the diagnostic is Positive.
Runs a script that writes an event to the OperationsManager event log on the agent and returns a message to the Operations console.
The value of the Result property in the property bag from the diagnostic is sent into the recovery script through an argument. This value is used in the event and the message created by the script.
The script itself is only for testing and performs no real function. This script only simulates a script that performs a recovery action and returns the results that are shown in an event and to the Operations console.
In the Authoring Console, select Health Model, and then select Monitors.
In the Monitors pane, expand MyMP.MyComputerRole1, expand System.Health.EntityState, and then expand System.Health.AvailabilityState.
Right-click MyMP.Monitor.MyApplicationEventError and select Properties.
Select the Diagnostic and Recovery tab.
Under Configure diagnostic tasks, click Add and then Diagnostic for a critical health state
In the Choose a unique identifier box, type MyMP.MyApplicationEventError.ScriptDiagnostic and then click OK.
On the General tab, do the following:
In the Name box, type Run diagnostic script.
In the Target box, make sure that MyMP.MyComputerRole1 is selected.
On the Configuration tab, do the following:
In the Execute on monitor box, make sure that MyMP.Monitor.MyApplicationEventError is selected.
In the Execute when monitor’s health is box, make sure that Error is selected.
On the Modules tab, do the following:
Under Actions, click Create.
In the Choose Module Type box, select Microsoft.Windows.ScriptPropertyBagProbe.
In the Module ID box, type Script. Click OK.
Under Actions, click Edit.
In the ScriptName box, type MyDiagnosticScript.vbs.
In the Arguments box, clear the existing text.
In the TimeoutSeconds box, type 300.
Click Edit. This starts the external editor.
Paste the contents of the following script between the ScriptBody tags in the XML. Replace any text that might already exist.
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)
Close the external editor to save the script back to the module.
Click OK.
Click OK.
Under Configure recovery tasks, click Add and then Recovery for a critical health state
In the Choose a unique identifier box, type MyMP.MyApplicationEventError.ScriptRecovery and then click OK.
On the General tab, do the following:
In the Name box, type Run recovery script.
In the Target box, make sure that MyMP.MyComputerRole1 is selected.
On the Configuration tab, do the following:
In the Execute on monitor box, make sure that MyMP.Monitor.MyApplicationEventError is selected.
Select Execute after diagnostic.
Select MyMP.MyApplicationEventError.ScriptDiagnostic.
On the Modules tab, do the following:
Under Condition Detection, click Create.
In the Choose Module Type box, select System.ExpressionFilter.
In the Module ID box, type FilterDiagnostic. Click OK.
Under Condition Detection, click Edit.
Click Configure.
Click Insert.
In the Parameter column, type Diagnostic/DataItem/Property[@Name='Result'].
In the Operator column, select Equals.
In the Parameter column, type Positive.
Click OK.
Click OK.
Under Actions, click Create.
In the Choose Module Type box, select Microsoft.Windows.ScriptWriteAction.
In the Module ID box, type Script, and then click OK.
Click Edit.
Click Configure.
In the File Name box, type MyRecoveryScript.vbs.
Paste the contents of the following script in the Script box.
sDiagnosticOutput = WScript.Arguments(0) sMessage = "Recovery ran after diagnostic result of " & sDiagnosticOutput & "." Set oAPI = CreateObject("MOM.ScriptAPI") oAPI.LogScriptEvent "MyRecoveryScript.vbs",100,4,sMessage
Click Parameters.
In the Parameters box, type $Data/Diagnostic/DataItem/Property[@Name='Result']$.
Click OK.
Click OK.
Click OK.
Click OK.
Click OK.