E Create Event Template Example

This appendix contains an example that shows how to create a createEvent request template for an event connector.

Listed below are the steps that would be taken to create the template:

  1. Study Data in External Application

  2. Study Data in Enterprise Manager

  3. Determine the Mapping for the Template

  4. Create the Template

  5. Create Mappings

See Completed Template Examples for examples of a completed template.

E.1 Study Data in External Application

The first step is to study the web service for the external application and determine what fields are available and what the data looks like in those fields.

Study of the web service WSDL shows that the root element for create requests is createRequest, and the namespace is http://samplecompany.com. The WSDL also shows that there are four required fields on a create. These fields are summary, description, severity, and priority. The severity field must be a numeric value from 1 to 5. Where 1 is the highest and 5 is the lowest. The priority field must be set to High, Medium, or Low. We have decided to populate just the required fields on the create request.

E.2 Study Data in Enterprise Manager

Now that we understand the data required to create events, we need to understand what data is available in Enterprise Manager and where it is located. Study of the data showed that all of the data that we need is located in the SystemAttributes element. There is a Summary element that has summary information and there is a SeverityCode field that can be used as well. Also included in the SystemAttributes element is target information that we would like to see in the event description.

E.3 Determine the Mapping for the Template

Listed below are the mappings that have been identified for the createEvent template:

  • Summary will be set to the contents of the SystemAttributes/Summary field.

  • Description will be set to the contents of the SystemAttributes/Summary field followed by the target information. The target information is located in the SystemAttributes/SourceInfo/TargetInfo element. The target fields that will be included are TargetName, TargetType, and TargetURL.

  • Severity will be set based on the contents of the SystemAttributes/SeverityCode field. If the field is set to FATAL, the severity will be set to 1. If the field is set to CRITICAL, the severity will be set to 2. If the field is set to WARNING, the severity will be set to 3. For all other values the severity will be set to 5.

  • Priority will be set based on the contents of the SystemAttributes/SeverityCode field. If the field is set to FATAL or CRITICAL, then the priority will be set to High. If the field is set to WARNING, then the priority will be set to Medium. All other values it will be set to Low.

E.4 Create the Template

We start the process by copying the contents of the template skeleton from Example 2-4 into our editor. Then we develop the mapping for the create request as shown in Create Mappings. After the mapping has been done, save the file as createEvent_request.xsl and test the template using the sample transactions in Appendix G, "Sample Event Data," to verify that it works.

Completed Template Examples shows what the template looks like after the mappings have been added to the skeleton template. Also included in the section are the results of our testing using the sample event transactions.

E.5 Create Mappings

Listed below are the mapping for create requests. We will identify the translation logic required for one field at a time.

E.5.1 Mapping the Summary Field

The first field is the Summary field. Listed below is the translation logic required to map this field to the Summary field in the event.

<Summary><xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/></Summary>

E.5.2 Mapping the Description Field

The next field to map is the Description field. It will be comprised of the Summary followed by the target information. Listed below is the mapping for the Description field.

<Description>Event created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Message"/>
Target information:
      Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType"/>
      Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName"/>
      Target URL: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/>
</Description>

E.5.3 Mapping the Severity Field

The next field to map is the Severity field. Listed below is the mapping for the Severity field.

<xsl:choose>
  <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'"><Severity>1</Severity></xsl:when>
  <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'"><Severity>2</Severity></xsl:when>
  <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'"><Severity>3</Severity></xsl:when>
  <xsl:otherwise><Severity>5</Severity></xsl:otherwise>
</xsl:choose>

E.5.4 Mapping the Priority Field

The last field to map is the Priority field.

<xsl:choose>
  <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'"><Priority>High</Priority></xsl:when>
  <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'"><Priority>High</Priority></xsl:when>
  <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'"><Priority>Medium</Priority></xsl:when>
  <xsl:otherwise><Priority>Low</Priority></xsl:otherwise>
</xsl:choose>

E.6 Completed Template Examples

Example E-1 shows the completed template using the mappings shown earlier in this section. The filename for the template is createEvent_request.xsl

Example E-1 Completed Event Template Sample

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" 
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:emcf="http://xmlns.oracle.com/sysman/connector">
 
  <xsl:template match="emcf:EMEvent">
    <createRequest xmlns="http://samplecompany.com">
      <!-- Set the summary to the EM event message -->
      <Summary><xsl:value-of select="emcf:SystemAttributes/emcf:Message"/></Summary>
 
      <!-- Set the description to the EM event message followed by the target information -->
      <Description>Event created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/>
Target information:
      Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType"/>
      Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName"/>
      Target URL: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/></Description>
 
      <!-- Set the severity based on the EM event severity code -->
      <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'"><Severity>1</Severity></xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'"><Severity>2</Severity></xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'"><Severity>3</Severity></xsl:when>
        <xsl:otherwise><Severity>5</Severity></xsl:otherwise>
      </xsl:choose>
 
      <!-- Set the priority based on the EM event severity code -->
      <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'"><Priority>High</Priority></xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'"><Priority>High</Priority></xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'"><Priority>Medium</Priority></xsl:when>
        <xsl:otherwise><Priority>Low</Priority></xsl:otherwise>
      </xsl:choose>
    </createRequest>
  </xsl:template>
</xsl:stylesheet>

Example E-2 shows the output from the template using the "Sample Create Transaction" data from Appendix G, "Sample Event Data," as input.

Example E-2 Event Template Output Sample

<?xml version="1.0" encoding="UTF-8"?>
<createRequest xmlns="http://samplecompany.com" xmlns:emcf="http://xmlns.oracle.com/sysman/connector">
   <Summary>Memory Utilization is 69.913%, crossed warning (40) or critical (99) threshold.</Summary>
   <Description>Event created in Enterprise Manager: Memory Utilization is 69.913%, crossed warning (40) or critical (99) threshold.
Target information:
      Target Type: host
      Target Name: target.mycompany.com
      Target URL: https://target.mycompany.com:5416/em/redirect?pageType=TARGET_HOMEPAGE&amp;targetName=target.mycompany.com&amp;targetType=host</Description>
   <Severity>3</Severity>
   <Priority>Medium</Priority>
</createRequest>