ClassCastException when using complex threshold expressions.

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.

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

Alejandro Galue October 26, 2011 at 11:36 AM

Fixed on revision for 69830c0ab67813c7601b6bc68b4fbdb96bc6e7a7 1.10

Alejandro Galue October 26, 2011 at 11:35 AM

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:

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

PagerDuty

Created October 26, 2011 at 11:00 AM
Updated January 27, 2017 at 4:20 PM
Resolved October 26, 2011 at 11:36 AM