Share via


Management Pack Health Model Exercise #1 - Creating an Event Monitor

This document is part of the Operations Manager Management Pack Authoring Guide



Overview

The following procedure shows how to create an event monitor 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:

Revisions

The Microsoft System Center team has validated this procedure as of Revision #2.  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:

  • Runs on any computer that has an instance of MyComputerRole1.
  • Sets the monitor to a critical state when an event in the Application event log with an event source of MyApplication and an event number of 101 is detected.
  • Sets the monitor to a healthy state when an event in the Application event log with an event source of MyApplication and an event number of 102 is detected.

Authoring Console Procedure

  1. In the Authoring Console, select Health Model, and then select Monitors.
  2. In the Monitors pane, expand Computer Role 1, and then expand System.Health.EntityState.
  3. Right-click System.Health.AvailabilityState, select New, select Windows Events, select Simple, and then select Event Reset.
  4. On the General page, do the following:
    1. In the ElementID box, type MyMP.Monitor.MyApplicationEventError.
    2. In the Display Name box, type MyApplication Event Error.
    3. In the Target box, select MyMP.MyComputerRole1.
    4. In the Parent Monitor box, select System.Health.AvailabilityState.
    5. In the Category box, select AvailabilityHealth. Click Next.
  5. On the Event Log (Unhealthy Event) page, do the following:
    1. In the Log Name box, keep the default value of Application.
    2. Click Next.
  6. On the Event Expression (Unhealthy Event) page, do the following:
    1. For the Event ID value, type 101.
    2. For the Event Source value, type MyApplication.
    3. Click Next.
  7. On the Event Log (Healthy Event) page, do the following:
    1. In the Log Name box, keep the default value of Application.
    2. Click Next.
  8. On the Event Expression (Healthy Event) page, do the following:
    1. For the Event ID value, type 102.
    2. For the Event Source value, type MyApplication.
    3. Click Next.
  9. Expand System.Health.AvailabilityState.
  10. Right-click MyMP.Monitor.MyApplicationEventError and select Properties.
  11. On the Health tab, for FirstEventRaised, change the Health State to Critical.
  12. On the Alerting tab, check Generate alerts for this monitor.
  13. Click OK.

Visual Studio Authoring Extensions Procedure

  1. Create the Monitor:
    1. In Solution Explorer, right click Right click the name of the project, select Add and then select New Item.
    2. Select Monitor (Unit).
    3. Change the name of the template to Monitors.mptg and click Add.
  2. Configure the Monitor Properties:
    1. Right click the entry for NewUnitMonitor and select Properties Window.
    2. Change the ID to Monitor.MyApplicationEventError.
    3. Change the Display Name to MyApplication Event Error.
  3. Select the Monitor Target:
    1. Select Target and click the ellipse (...) button on the right of the field. 
    2. Select MyMP.MyComputerRole1 and click OK.
  4. Select the Monitor Type:
    1. Select Monitor Type ID and click the ellipse (...) button on the right of the field. 
    2. Select Microsoft.Windows.2SingleEventLog2StateMonitorType and click OK.
    3. Select Parent Monitor ID and click the ellipse (...) button on the right of the field.
    4. Select System.Health.AvailabilityState and click OK.
  5. Configure the Monitor:
    1. Select Monitor Configuration and click the ellipse (...) button on the right of the field. 

    2. Copy the following XML into the configuration window between the <Configuration> tags.  Note that you can use Intellisense to manually type in each entry.

      <!-- Computer name for the first event.  We will use a variable to get the target computer name. -->
      <FirstComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</FirstComputerName>
      <!-- Name of the log containing the first event. -->
      <FirstLogName>Application</FirstLogName>
       
      <!-- Expression for the first event -->
      <FirstExpression>
        <And>
          <!-- Expression for the first event number -->
          <Expression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="UnsignedInteger">EventDisplayNumber</XPathQuery>
              </ValueExpression>
              <Operator>Equal</Operator>
              <ValueExpression>
                <Value Type="UnsignedInteger">101</Value>
              </ValueExpression>
            </SimpleExpression>
          </Expression>
          <!-- Expression for the first event source -->
          <Expression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="String">PublisherName</XPathQuery>
              </ValueExpression>
              <Operator>Equal</Operator>
              <ValueExpression>
                <Value Type="String">MyApplication</Value>
              </ValueExpression>
            </SimpleExpression>
          </Expression>
        </And>
      </FirstExpression>
       
      <!-- Computer name for the second event.  We will use a variable to get the target computer name. -->
      <SecondComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</SecondComputerName>
      <!-- Name of the log containing the first event. -->
      <SecondLogName>Application</SecondLogName>
       
      <!-- Expression for the second event -->         
      <SecondExpression>
        <And>
          <!-- Expression for the second event number -->
          <Expression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="UnsignedInteger">EventDisplayNumber</XPathQuery>
              </ValueExpression>
              <Operator>Equal</Operator>
              <ValueExpression>
                <Value Type="UnsignedInteger">102</Value>
              </ValueExpression>
            </SimpleExpression>
          </Expression>
          <!-- Expression for the second event source -->
          <Expression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="String">PublisherName</XPathQuery>
              </ValueExpression>
              <Operator>Equal</Operator>
              <ValueExpression>
                <Value Type="String">MyApplication</Value>
              </ValueExpression>
            </SimpleExpression>
          </Expression>
        </And>
      </SecondExpression>
      
      
    3. Select Monitor Operational States and click the ellipse (...) button on the right of the field.

    4. Next to FirstEventRaised, select Critical.

    5. Next to SecondEventRaised, select Healthy.

    6. Click OK,

  6. Save and Compile the Project:
    1. Select File, and then click Save Monitors.mptg.
    2. Select Build and then Build Solution.
    3. Ensure that you don't receive any errors.

See Also

  • Unit Monitors
  • Events