Management Pack Health Model Exercise #8 - Creating a Diagnostic
This document is part of the Operations Manager Management Pack Authoring Guide .
Overview
The following procedure shows how to create a diagnostic that runs a command using the Operations Manager 2007 Authoring console and Visual Studio Authoring Extensions.
Product Versions
This exercise applies to the following products:
- System Center Operations Manager 2007 R2
- System Center 2012 Operations Manager
- System Center 2012 Operations Manager SP1
Prerequisites
Before you perform this procedure, you must first complete the following prerequisite procedures:
- Creating a New Management Pack - Create the management pack.
- Creating a Class - Create the class that is the target of the monitor.
- Creating an Event Monitor - Create the monitor that the diagnostic will respond to.
Revisions
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
Sample Code
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.
Details
The event monitor created in this procedure has the following characteristics:
- Automatically runs when the MyMP.Monitor.MyApplicationEventError monitor goes to a critical state.
- Runs tasklist.exe to return a list of running processes on the agent computer.
Authoring Console Procedure
- In the Authoring Console, select Health Model, and then select Monitors.
- In the Monitors pane, expand MyMP.MyComputerRole1, and then expand System.Health.EntityState, and then expand System.Health.AvailabilityState.
- Right-click MyMP.Monitor.MyApplicationEventError and select Properties.
- Select the Diagnostic and Recovery tab.
- Click Add and then Diagnostic for a critical health state.
- In the Choose a unique identifier box, type MyMP.MyApplicationEventError.CommandDiagnostic and then click OK.
- On the General tab, do the following:
- In the Name box**,** type Check Running Processes.
- In the Target box, select MyMP.MyComputerRole1.
- On the Configuration tab, do the following:
- Under Actions, click Create.
- In the Choose Module Type box, select System.CommandExecutorProbe.
- In the Module ID box**,** type Command. Click OK.
- Click Edit.
- Click Configure.
- In the Full path to file box, type %windir%\system32\tasklist.exe.
- Click OK.
- Click OK.
- Click OK.
- Click OK.
Visual Studio Authoring Extensions Procedure
- Create the Diagnostic:
- In Solution Explorer, right click Right click the name of the solution, select Add and then select New Item.
- Select Monitor Diagnostic and click OK.
- Change the name of the template to Diagnostics.mpx and click Add.
- Configure the Diagnostic:
- Replace the value for the ID attribute of the Diagnotic with MyMP.MyApplicationEventError.CommandDiagnostic
- In the Target attribute for the Diagnostic, fill in MyMP.MyComputerRole1.
- In the Monitor attribute for the Diagnostic, fill in MyMP.Monitor.MyApplicationEventError.
- Configure the Diagnostic modules:
Remove the ConditionDetection section of the XML.
Replace the XML for the ProbectAction with the following XML. Note that you can use Intellisense to manually type in each entry.
<ProbeAction ID="Command" TypeID="System!System.CommandExecuterProbe"> <ApplicationName><![CDATA[%windir%\system32\tasklist.exe]]></ApplicationName> <WorkingDirectory /> <CommandLine /> <TimeoutSeconds>15</TimeoutSeconds> <RequireOutput>true</RequireOutput> </ProbeAction>
- Configure the Display String:
- Replace the value for the ElementID attribute of the DisplayString with MyMP.MyApplicationEventError.CommandDiagnostic.
- Replace the value for the Name element with Check Running Processes.
- Save and Compile the Project:
- Select File, and then click Save Diagnostics.mpx.
- Select Build and then Build Solution.
- Ensure that you don't receive any errors.