Search in sources :

Example 31 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.

the class ThresholdEvaluatorAbsoluteChangeTest method testEvaluateTwiceTriggerLowBelow.

@Test
public void testEvaluateTwiceTriggerLowBelow() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.ABSOLUTE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(-1.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateAbsoluteChange evaluator = new ThresholdEvaluatorStateAbsoluteChange(wrapper);
    assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.0));
    assertEquals("should trigger", Status.TRIGGERED, evaluator.evaluate(8.0));
}
Also used : ThresholdEvaluatorStateAbsoluteChange(org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 32 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.

the class ThresholdEvaluatorAbsoluteChangeTest method testEvaluateTwiceNoTriggerHighBelow.

@Test
public void testEvaluateTwiceNoTriggerHighBelow() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.ABSOLUTE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(1.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(3);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateAbsoluteChange evaluator = new ThresholdEvaluatorStateAbsoluteChange(wrapper);
    assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.0));
    assertEquals("should not trigger", Status.NO_CHANGE, evaluator.evaluate(10.5));
}
Also used : ThresholdEvaluatorStateAbsoluteChange(org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 33 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testIsTriggerCountExceededNotAfterReArm.

@Test
public void testIsTriggerCountExceededNotAfterReArm() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.HIGH);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(99.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(1);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateHighLow item = new ThresholdEvaluatorStateHighLow(wrapper);
    assertFalse("trigger count should not be exeeded before exceeding value", item.isTriggerCountExceeded());
    Status status = item.evaluate(100.0);
    assertEquals("first threshold evaluation status", Status.TRIGGERED, status);
    assertTrue("trigger count should  be exeeded after exceeding value", item.isTriggerCountExceeded());
    status = item.evaluate(0.0);
    assertEquals("first threshold evaluation status", Status.RE_ARMED, status);
    assertFalse("trigger count should be reset after being rearmed", item.isTriggerCountExceeded());
}
Also used : Status(org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status) ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 34 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testEvaluateHighNoTriggerTwice.

@Test
public void testEvaluateHighNoTriggerTwice() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.HIGH);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(99.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(2);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorState item = new ThresholdEvaluatorStateHighLow(wrapper);
    Status status = item.evaluate(100.0);
    assertEquals("threshold evaluation status", Status.NO_CHANGE, status);
}
Also used : Status(org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status) ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 35 with Threshold

use of org.opennms.netmgt.config.threshd.Threshold in project opennms by OpenNMS.

the class ThresholdEvaluatorHighLowTest method testEvaluateHighTriggerRearm.

@Test
public void testEvaluateHighTriggerRearm() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.HIGH);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(99.0);
    threshold.setRearm(0.5);
    threshold.setTrigger(1);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorState item = new ThresholdEvaluatorStateHighLow(wrapper);
    Status status = item.evaluate(100.0);
    assertEquals("first threshold evaluation status", Status.TRIGGERED, status);
    status = item.evaluate(0.0);
    assertEquals("second threshold evaluation status", Status.RE_ARMED, status);
}
Also used : Status(org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status) ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Aggregations

Threshold (org.opennms.netmgt.config.threshd.Threshold)68 Test (org.junit.Test)64 ThresholdEvaluatorStateHighLow (org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow)33 ThresholdEvaluatorStateRelativeChange (org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange)18 ThresholdEvaluatorStateAbsoluteChange (org.opennms.netmgt.threshd.ThresholdEvaluatorAbsoluteChange.ThresholdEvaluatorStateAbsoluteChange)13 Status (org.opennms.netmgt.threshd.ThresholdEvaluatorState.Status)11 Date (java.util.Date)10 Event (org.opennms.netmgt.xml.event.Event)8 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)8 ModelAndView (org.springframework.web.servlet.ModelAndView)4 ThresholdingConfigFactory (org.opennms.netmgt.config.ThresholdingConfigFactory)3 ServletException (javax.servlet.ServletException)2 Group (org.opennms.netmgt.config.threshd.Group)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Expression (org.opennms.netmgt.config.threshd.Expression)1 ResourceFilter (org.opennms.netmgt.config.threshd.ResourceFilter)1