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

Varbinddecodes are being ignored on Notifications




      Let's suppose we have the following event definition for a particular SNMP Trap:

       <event-label>CISCO-HSRP-MIB defined trap event: cHsrpStateChange</event-label>
       <descr>&lt;p&gt;A cHsrpStateChange notification is sent when a
       cHsrpGrpStandbyState transitions to either active or
       standby state, or leaves active or standby state. There
       will be only one notification issued when the state change
       is from standby to active and vice versa.&lt;/p&gt;&lt;table&gt;
       initial(1) learn(2) listen(3) speak(4) standby(5) active(6)&lt;/p&gt;
       <logmsg dest='logndisplay'>&lt;p&gt;Cisco Event: HSRP State Change to %parm[#1]%.&lt;/p&gt;</logmsg>
       <decode varbindvalue="1" varbinddecodedstring="initial"/>
       <decode varbindvalue="2" varbinddecodedstring="learn"/>
       <decode varbindvalue="3" varbinddecodedstring="listen"/>
       <decode varbindvalue="4" varbinddecodedstring="speak"/>
       <decode varbindvalue="5" varbinddecodedstring="standby"/>
       <decode varbindvalue="6" varbinddecodedstring="active"/>
       <alarm-data reduction-key="%uei%:%dpname%:%nodeid%" alarm-type="3" auto-clean="false"/>

      The numeric value of the parameter number 1 is going to be translated to its human readable representation, according with the varbindsdecode.

      If this trap comes in, the log message is translated to something like the following:

      <p>Cisco Event: HSRP State Change to active(6).</p>

      As you can see %parm[#1]% appears as active(6) instead of just the numeric value (i.e. 6)

      Let's say you need a notification for this event, and you define something like the following:

      <notification name="Cisco HSRP State Change" status="on" writeable="yes">
          <rule>IPADDR != ''</rule>
          <text-message>The HSRP State was changed to %parm[#1]%  on node %nodelabel% (IP address %interface%)</text-message>
          <subject>Notice #%noticeid%: The HSRP State was changed to %parm[#1]% on node %nodelabel%.</subject>

      The reason for this is having a Non-HTML content for the subject and the message on the Notification's Email, and that's why we cannot use the logmsg or the description from the event directly.

      The expected result for the subject is something like this:

      Notice #314: The HSRP State was changed to active(6) on node router.local.

      Unfortunately, the received email shows:

      Notice #314: The HSRP State was changed to 6 on node router.local.

      In other words, the varbindsdecode works if you use them inside the event's logmsg or the event's description, but they won't work if you use them on notifications.




            agalue Alejandro Galue
            agalue Alejandro Galue
            0 Vote for this issue
            2 Start watching this issue