SNMP Profiles

SNMP Profiles are prefabricated sets of SNMP configuration that are automatically "fitted" against eligible IP addresses at provisioning time. Each profile may have a unique label and an optional filter expression. If the filter expression is present, it will be evaluated to check whether a given IP address or reverse-lookup hostname passes the filter. A profile with a filter expression will be fitted to a given IP address only if the filter expression evaluates true against that IP address.

SNMP profiles can be added to snmp-config.xml to enable automatic fitting of SNMP interfaces.

Sample snmp-config.xml with profiles
<snmp-config xmlns="http://xmlns.opennms.org/xsd/config/snmp" write-community="private" read-community="public" timeout="800" retry="3">
   <definition version="v1" ttl="6000">
      <specific>127.0.0.1</specific>
   </definition>
   <profiles>
      <profile version="v1" read-community="horizon" timeout="10000">
         <label>profile1</label>
      </profile>
      <profile version="v1" ttl="6000">
         <label>profile2</label>
         <filter>iphostname LIKE '%opennms%'</filter>
      </profile>
      <profile version="v1" read-community="meridian">
         <label>profile3</label>
         <filter>IPADDR IPLIKE 172.1.*.*</filter>
      </profile>
   </profiles>
</snmp-config>

In the above config,

  1. profile1 doesn’t have a filter expression. This profile will be tried for every interface.

  2. profile2 has a filter expression that compares iphostname (the hostname resulting from a reverse DNS lookup of the IP address being fitted) against a preconfigured value. This profile’s SNMP parameters will be fitted only against IP addresses whose hostname contains the string opennms.

  3. profile3 has an IPLIKE expression that matches all interfaces in the range specified in the filter. This profile’s SNMP parameters will be fitted only against IP addresses in the range specified by the IPLIKE expression.

Profiles will be tried in the order they are configured. The first match that produces a successful SNMP GET-REQUEST on the scalar instance of sysObjectID will be saved by Provisiond as the SNMP configuration definition to use for all future SNMP operations against the fitted IP address.

default as profile label is reserved for default SNMP config.

Manually fit an SNMP profile

The opennms:snmp-fit Karaf shell command finds a matching profile for a given IP address and prints out the resulting config. Matching or "fitting" an SNMP profile is successful if the IP passes the profile’s filter expression and gets the scalar sysObjectID instance.

$ ssh -p 8101 admin@localhost
...
admin@opennms()> opennms:snmp-fit -l MINION -s 172.1.1.105               (1)
admin@opennms()> opennms:snmp-fit 172.1.1.106 profile1                   (2)
admin@opennms()> opennms:snmp-fit -s -n -f Switches 172.1.1.107 profile2 (3)
1 Searches the profiles that fit the IP address 172.1.1.105 at location MINION and saves the resulting configuration as a definition for future use.
2 Checks whether the profile with label profile1 is a fit for IP address 172.1.1.106, but does not save the resulting configuration if it is a fit.
3 Checks whether the profile labeled profile2 is a fit for IP address 172.1.1.107. If a match, it saves the resulting configuration and also sends a newSuspect event, telling Meridian to auto-provision the node at that IP address into the Switches requisition.

Remove an IP address from definition.

The opennms:snmp-remove-from-definition Karaf shell command removes an IP address from the system-wide SNMP configuration definitions.

$ ssh -p 8101 admin@localhost
...
admin@opennms()> opennms:snmp-remove-from-definition -l MINION 172.1.0.255

This removes IP address 172.1.0.255 at location MINION from the system-wide SNMP configuration so that this IP address can be fitted to a new profile. This command is useful when an IP address formerly assigned to a device is reassigned to a device with a different SNMP configuration.

Using SNMP profiles with the SNMP detector

By default, the SnmpDetector does not use SNMP profiles. To enable SNMP profiles for the SnmpDetector, add property useSnmpProfiles to the detector and set it to true. If you use profiles and do not enable this setting, the SNMP service may not get detected on your nodes until the node is added to inventory and rescanned.