OpenNMS
  1. OpenNMS
  2. NMS-5014

ClassCastException when using complex threshold expressions.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.92
    • Fix Version/s: 1.9.93
    • Component/s: Thresholding
    • Security Level: Default (Default Security Scheme)
    • Labels:

      Description

      I have a situation that needs trigger a threshold when the value is equal to certain numbers. This is not the standard use case of thresholds but in this particular situation will be very useful.

      I need to track JUNIPER-MIB::jnxOperatingState. Operating state is defined as on of the following by the MIB:

      1 - unknown
      2 - running
      3 - ready
      4 - reset
      5 - runningAtFullSpeed
      6 - down
      7 - standby

      The threshold should be triggered when the value is running(2), ready(3) ot standby (7), so here is the threshold definition:

      <group name="juniper-status" rrdRepository = "/opt/opennms/share/rrd/snmp/">
      <expression type="high" expression="jnxOperatingState == 2.0 || jnxOperatingState == 3.0 || jnxOperatingState == 7.0 ? 1.0 : 0.0"
      ds-type="jnxContentsContainerIndex" ds-label="jnxContentsType" value="1" rearm="0" trigger="1"
      triggeredUEI="org.opennms/thresholds/juniper/powerStatusFailure"
      rearmedUEI="org.opennms/thresholds/juniper/powerStatusNormal">
      <resource-filter field="jnxContentsType">^jnxPower$</resource-filter>
      </expression>
      </group>

      We use Apache JEXL to parse and evaluate the expressions, the above expression is correct according with:
      http://commons.apache.org/jexl/reference/syntax.html#Operators

      The problem is that ExpressionConfigWrapper will throw a ClassCastException because JEXL return a Long and that class will try to convert the value returned into Double.

        Activity

        Alejandro Galue created issue -
        Hide
        Alejandro Galue added a comment -

        1.8 uses JEP instead of Apache JEXL, so the solution is a little bit different but it works without code changes. The threshold definition should looks like this:

        <group name="juniper-status" rrdRepository = "/opt/opennms/share/rrd/snmp/">
           <expression type="high" expression="jnxOperatingState == 2.0 || jnxOperatingState == 3.0 || jnxOperatingState == 7.0" 
              ds-type="jnxContentsContainerIndex" ds-label="jnxContentsType" value="1" rearm="0" trigger="1"
              triggeredUEI="org.opennms/thresholds/juniper/powerStatusFailure"
              rearmedUEI="org.opennms/thresholds/juniper/powerStatusNormal">
              <resource-filter field="jnxContentsType">^jnxPower$</resource-filter>
           </expression>
        </group>
        
        Show
        Alejandro Galue added a comment - 1.8 uses JEP instead of Apache JEXL, so the solution is a little bit different but it works without code changes. The threshold definition should looks like this: <group name= "juniper-status" rrdRepository = "/opt/opennms/share/rrd/snmp/" > <expression type= "high" expression= "jnxOperatingState == 2.0 || jnxOperatingState == 3.0 || jnxOperatingState == 7.0" ds-type= "jnxContentsContainerIndex" ds-label= "jnxContentsType" value= "1" rearm= "0" trigger= "1" triggeredUEI= "org.opennms/thresholds/juniper/powerStatusFailure" rearmedUEI= "org.opennms/thresholds/juniper/powerStatusNormal" > <resource-filter field= "jnxContentsType" > ^jnxPower$ </resource-filter> </expression> </group>
        Alejandro Galue made changes -
        Field Original Value New Value
        Affects Version/s 1.8.15 [ 10620 ]
        Fix Version/s 1.8.16 [ 10820 ]
        Hide
        Alejandro Galue added a comment -

        Fixed on revision for 69830c0ab67813c7601b6bc68b4fbdb96bc6e7a7 1.10

        Show
        Alejandro Galue added a comment - Fixed on revision for 69830c0ab67813c7601b6bc68b4fbdb96bc6e7a7 1.10
        Alejandro Galue made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development