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

Varbinddecodes are being ignored on Notifications

    Details

      Description

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

      <event>
       <mask>
        <maskelement>
         <mename>id</mename>
         <mevalue>.1.3.6.1.4.1.9.9.106.2</mevalue>
        </maskelement>
        <maskelement>
         <mename>generic</mename>
         <mevalue>6</mevalue>
        </maskelement>
        <maskelement>
         <mename>specific</mename>
         <mevalue>1</mevalue>
        </maskelement>
       </mask>
       <uei>uei.opennms.org/vendor/Cisco/traps/cHsrpStateChange</uei>
       <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;
       &lt;tr&gt;&lt;td&gt;&lt;b&gt;
       cHsrpGrpStandbyState&lt;/b&gt;&lt;/td&gt;&lt;td&gt;%parm[#1]%
       &lt;/td&gt;&lt;td&gt;&lt;p;&gt;
       initial(1) learn(2) listen(3) speak(4) standby(5) active(6)&lt;/p&gt;
       &lt;/td;&gt;&lt;/tr&gt;&lt;/table&gt;
       </descr>
       <logmsg dest='logndisplay'>&lt;p&gt;Cisco Event: HSRP State Change to %parm[#1]%.&lt;/p&gt;</logmsg>
       <severity>Minor</severity>
       <varbindsdecode>
       <parmid>parm[#1]</parmid>
       <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"/>
       </varbindsdecode>
       <alarm-data reduction-key="%uei%:%dpname%:%nodeid%" alarm-type="3" auto-clean="false"/>
      </event>
      

      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">
          <uei>uei.opennms.org/vendor/Cisco/traps/cHsrpStateChange</uei>
          <rule>IPADDR != '0.0.0.0'</rule>
          <destinationPath>Network-Admin</destinationPath>
          <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>
           <numeric-message>111-%noticeid%</numeric-message>
      </notification>
      

      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.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: