SNMP Metadata

The SNMP Metadata adapter can be used to enrich a node with data gathered from SNMP. This data is stored in the node’s metadata context snmp and can be displayed in the Web UI and also queried via ReST. The use-case is to add hardware inventory data for a SNMP-enabled node. The file ${OPENNMS_HOME}/etc/snmp-metadata-adapter-configuration.xml is used to configure this adapter:

<snmp-metadata-config updateBehavior="replace">
    <config tree=".1.2.3.4" name="myHardware" sysObjectId="~^\.4\.3\.2\.1.*">
        <entry tree=".1" name="someKey"/>
        <entry tree=".2" name="otherKey"/>
        <entry tree=".3.1" name="aTable">
            <entry tree=".1" name="anEntryIndex" index="true"/>
            <entry tree=".2" name="anEntryValue"/>
            <entry tree=".3" name="anotherEntryValue"/>
            <entry tree=".4.999" name="anExactOIDValue" exact="true"/>
        </entry>
    </config>
</snmp-metadata-config>

The config’s sysObjectId attribute is compared with the System Object Id of the node. By prepending a tilde symbol (~), a regular expression can be specified to check the node’s System Object Id. The example above will query nodes with System Object Ids matching the regular expression ^4\.3\.2\.1.*. The data will be searched in the SNMP sub-tree .1.2.3.4 and be stored in the node’s metadata context snmp. The top-level element will be named myHardware.

The provisioning adapter automatically appends the .0 value to single-entry OIDs per normal SNMP specification. In some edge cases, you will need to specify the entire OID statically to retrieve a single piece of data. Specifying the attribute exact="true" allows you to specify the entire OID.

There is also an optional resultsBehavior attribute that you can use to specify how the adapter should update the node’s metadata. The table below outlines the behavior of each option:

Value Description

replace

Default behavior. The adapter will replace the node’s metadata snmp context with the data retrieved from the node.

update

The adapter will update the node’s metadata snmp context with the data retrieved from the node.

New values will be added, existing values will be updated, and values not present in the retrieved data will be left unchanged.

NOTE: This behavior can leave old values in the metadata context if the retrieved data does not contain the same keys.

Based on this example and under the assumption that a node provides corresponding data, the following metadata entries will be produced:

Context Key Value

snmp

myHardware.someKey

someValue

snmp

myHardware.otherKey

otherValue

snmp

myHardware.aTable[.1].anEntryIndex

1

snmp

myHardware.aTable[.1].anEntryValue

aValue1

snmp

myHardware.aTable[.1].anotherEntryValue

anotherValue1

snmp

myHardware.aTable[.2].anEntryIndex

2

snmp

myHardware.aTable[.2].anEntryValue

aValue2

snmp

myHardware.aTable[.2].anotherEntryValue

anotherValue2