Search in sources :

Example 51 with Threshold

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

the class ThresholdEvaluatorRelativeChangeTest method testGetEventForStateDefaultUEIS.

@Test
public void testGetEventForStateDefaultUEIS() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.RELATIVE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(99.0);
    threshold.setRearm(95.0);
    threshold.setTrigger(1);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateRelativeChange item = new ThresholdEvaluatorStateRelativeChange(wrapper);
    Event event = item.getEventForState(Status.TRIGGERED, new Date(), 100.0, null);
    assertEquals("UEI should be the relativeChangeThresholdTriggerd", EventConstants.RELATIVE_CHANGE_THRESHOLD_EVENT_UEI, event.getUei());
}
Also used : Event(org.opennms.netmgt.xml.event.Event) ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Date(java.util.Date) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 52 with Threshold

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

the class ThresholdEvaluatorRelativeChangeTest method testGetEventForStateCustomUEIS.

@Test
public void testGetEventForStateCustomUEIS() {
    String triggeredUEI = "uei.opennms.org/custom/relativeChangeThresholdTriggered";
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.RELATIVE_CHANGE);
    threshold.setDsName("ds-name");
    threshold.setDsType("node");
    threshold.setValue(99.0);
    threshold.setRearm(95.0);
    threshold.setTrigger(1);
    threshold.setTriggeredUEI(triggeredUEI);
    ThresholdConfigWrapper wrapper = new ThresholdConfigWrapper(threshold);
    ThresholdEvaluatorStateRelativeChange item = new ThresholdEvaluatorStateRelativeChange(wrapper);
    Event event = item.getEventForState(Status.TRIGGERED, new Date(), 100.0, null);
    assertEquals("UEI should be the uei.opennms.org/custom/relativeChangeThresholdTriggered", triggeredUEI, event.getUei());
}
Also used : Event(org.opennms.netmgt.xml.event.Event) ThresholdEvaluatorStateRelativeChange(org.opennms.netmgt.threshd.ThresholdEvaluatorRelativeChange.ThresholdEvaluatorStateRelativeChange) Date(java.util.Date) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 53 with Threshold

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

the class ThresholdEvaluatorHighLowTest method testIsRearmExceededHighTriggeredBelow.

@Test
public void testIsRearmExceededHighTriggeredBelow() {
    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);
    assertTrue("rearm should be exceeded", item.isRearmExceeded(0.0));
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 54 with Threshold

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

the class ThresholdEvaluatorHighLowTest method testIsThresholdExceededLowTriggeredBelow.

@Test
public void testIsThresholdExceededLowTriggeredBelow() {
    Threshold threshold = new Threshold();
    threshold.setType(ThresholdType.LOW);
    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);
    assertTrue("threshold should be exceeded", item.isThresholdExceeded(98.0));
}
Also used : ThresholdEvaluatorStateHighLow(org.opennms.netmgt.threshd.ThresholdEvaluatorHighLow.ThresholdEvaluatorStateHighLow) Threshold(org.opennms.netmgt.config.threshd.Threshold) Test(org.junit.Test)

Example 55 with Threshold

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

the class ThresholdEvaluatorHighLowTest method testEvaluateHighTriggerRearmTriggerAgain.

@Test
public void testEvaluateHighTriggerRearmTriggerAgain() {
    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);
    status = item.evaluate(100.0);
    assertEquals("third threshold evaluation status", Status.TRIGGERED, 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