Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-5186

Use multiples XPath for the resource identifier (resource key).

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.10.0
    • Fix Version/s: 1.10.1
    • Component/s: Data Collection - XML
    • Security Level: Default (Default Security Scheme)
    • Labels:
      None

      Description

      The resource identifier or resource key, is the string used to uniquely identify a resource, like the ifIndex for SNMP Interfaces.

      In certain circumstances it is required to use multiple XML tags to create a unique identifier.

      Take a look at this example:

      <data>
      <entry>
      <summary>
      <domain-name>HQ</domain-name>
      <local-id>0012</local-id>
      </summary>
      <info>
      <cpu>67%</cpu>
      <mem>82%</mem>
      <temp>41C</temp>
      </info>
      </entry>
      <entry>
      <summary>
      <domain-name>HQ</domain-name>
      <local-id>0022</local-id>
      </summary>
      <info>
      <cpu>72%</cpu>
      <mem>91%</mem>
      <temp>39C</temp>
      </info>
      </entry>
      </data>

      Certainly the local-id is unique, but imagine that the only way to differentiate both entries is by the combination of domain-name plus the local-id.

      The current tag available for xml-group (key-xpath) only let the user define one key to identify the resource. The idea is, when it is required more than one element, use a different tag which will take precedence over the default one, for example:

      <xml-source url="http://

      {ipaddr}/stats">
      <xml-group name="stats" resource-type="statsEntry" resource-xpath="/data/entry">
      <resource-key>
      <key-xpath>summary/domain-name</key-xpath>
      <key-xpath>summary/local-id</key-xpath>
      </resource-key>
      <xml-object name="cpu" type="GAUGE" xpath="info/cpu" />
      <xml-object name="mem" type="GAUGE" xpath="info/mem" />
      <xml-object name="temp" type="GAUGE" xpath="info/temp" />
      </xml-group>
      </xml-source>

      Of course, for this particular example it is possible to use the following config, but I guess it could be useful to have something like the above example:

      <xml-source url="http://{ipaddr}

      /stats">
      <xml-group name="stats" resource-type="statsEntry" resource-xpath="/data/entry" key-xpath="summary/local-id">
      <xml-object name="cpu" type="GAUGE" xpath="info/cpu" />
      <xml-object name="mem" type="GAUGE" xpath="info/mem" />
      <xml-object name="temp" type="GAUGE" xpath="info/temp" />
      </xml-group>
      </xml-source>

        Attachments

          Activity

            People

            • Assignee:
              agalue Alejandro Galue
              Reporter:
              agalue Alejandro Galue
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: