/** * <p>reinitializeThresholding</p> */ /* * TODO Re-create or merge ? * * The reason of doing a merge is to keep and update the threshold states. * * It is extremely more easy to just recreate the thresholding visitor to avoid complex * operations. But, the cost of doing this is that all the states will be lost, and * some alarms will become orphans. * * Other idea is to create two methods to get and set the states, and detect orphan * states. That way, we can decide what to do with orphans (like clear the alarm, or * send an auto-rearm), and also it can be used to persist the states across restarts. */ public void reinitializeThresholding() { if(m_thresholdVisitor!=null) { LOG.debug("reinitializeThresholding on {}", this); m_thresholdVisitor.reload(); } }
@Test public void testBug5764() throws Exception { ThresholdingVisitor visitor = createVisitor(); initFactories("/threshd-configuration.xml","/test-thresholds-bug5764.xml"); visitor.reload(); }
@Test public void testBug3146_unrelatedChange() throws Exception { ThresholdingVisitor visitor = createVisitor(); // Add Events addHighThresholdEvent(1, 10000, 5000, 12000, "node", "node", "freeMem", null, null); addHighRearmEvent(1, 10000, 5000, 1000, "node", "node", "freeMem", null, null); // Step 1: Trigger threshold runGaugeDataTest(visitor, 12000); // Step 2: Reload Configuration (changes are not related to triggered threshold) visitor.reload(); // Step 3: Send Rearmed event runGaugeDataTest(visitor, 1000); // Verify Events verifyEvents(0); }
@Test public void testReloadThresholdsConfig() throws Exception { ThresholdingVisitor visitor = createVisitor(); // Step 1: No events addHighThresholdEvent(1, 10000, 5000, 4500, "node", "node", "freeMem", null, null); runGaugeDataTest(visitor, 4500); verifyEvents(1); // Step 2: Change configuration initFactories("/threshd-configuration.xml","/test-thresholds-2.xml"); visitor.reload(); resetAnticipator(); // Step 3: Trigger threshold with new configuration values addHighThresholdEvent(1, 4000, 2000, 4500, "node", "node", "freeMem", null, null); runGaugeDataTest(visitor, 4500); verifyEvents(0); }
visitor.reload();
@Test public void testBug3146_replaceThreshold() throws Exception { ThresholdingVisitor visitor = createVisitor(); // Add Events String lowThresholdUei = EventConstants.LOW_THRESHOLD_EVENT_UEI; String highExpression = "(((hrStorageAllocUnits*hrStorageUsed)/(hrStorageAllocUnits*hrStorageSize))*100)"; String lowExpression = "(100-((hrStorageAllocUnits*hrStorageUsed)/(hrStorageAllocUnits*hrStorageSize))*100)"; addHighThresholdEvent(1, 30, 25, 50, "/opt", "1", highExpression, null, null); addHighRearmEvent(1, 30, 25, Double.NaN, "/opt", "1", highExpression, null, null); addEvent(lowThresholdUei, "127.0.0.1", "SNMP", 1, 10.0, 20.0, 5.0, "/opt", "1", lowExpression, null, null, m_anticipator, m_anticipatedEvents); // Step 1: Trigger threshold runFileSystemDataTest(visitor, 1, "/opt", 500, 1000); // Step 2: Reload Configuration (merge). Threshold definition was replaced. initFactories("/threshd-configuration.xml","/test-thresholds-4.xml"); visitor.reload(); // Step 3: Must trigger only one low threshold exceeded runFileSystemDataTest(visitor, 1, "/opt", 950, 1000); verifyEvents(0); }
/** * This test uses this files from src/test/resources: * - threshd-configuration.xml * - test-thresholds-bug5258-a.xml * - test-thresholds-bug5258-b.xml */ @Test public void testBug5258() throws Exception { initFactories("/threshd-configuration.xml","/test-thresholds-bug5258-a.xml"); ThresholdingVisitor visitor = createVisitor(); // Define Main Events addEvent(EventConstants.HIGH_THRESHOLD_EVENT_UEI, "127.0.0.1", "SNMP", 1, 50.0, 45.0, 65.0, "/opt", "1", "hrStorageUsed", null, null, m_anticipator, m_anticipatedEvents); addEvent(EventConstants.HIGH_THRESHOLD_EVENT_UEI, "127.0.0.1", "SNMP", 1, 50.0, 45.0, 70.0, "/var", "1", "hrStorageUsed", null, null, m_anticipator, m_anticipatedEvents); // Define Rearm Event - This is because the configuration of an already triggered threshold has been changed. addEvent(EventConstants.HIGH_THRESHOLD_REARM_EVENT_UEI, "127.0.0.1", "SNMP", 1, 50.0, 45.0, Double.NaN, "/opt", "1", "hrStorageUsed", null, null, m_anticipator, m_anticipatedEvents); // Trigger high Threshold for /opt runFileSystemDataTest(visitor, 1, "/opt", 65, 100); // Change the filter initFactories("/threshd-configuration.xml","/test-thresholds-bug5258-b.xml"); visitor.reload(); // Trigger high Threshold for /var runFileSystemDataTest(visitor, 1, "/var", 70, 100); // Verify Events verifyEvents(0); }
@Test public void testBug3146_reduceTrigger() throws Exception { ThresholdingVisitor visitor = createVisitor(); // Add Events addHighThresholdEvent(1, 10000, 5000, 12000, "node", "node", "freeMem", null, null); addHighRearmEvent(1, 10000, 5000, Double.NaN, "node", "node", "freeMem", null, null); addHighThresholdEvent(1, 4000, 2000, 5000, "node", "node", "freeMem", null, null); addHighRearmEvent(1, 4000, 2000, 1000, "node", "node", "freeMem", null, null); // Step 1: Trigger threshold runGaugeDataTest(visitor, 12000); // Step 2: Change Configuration (reducing value for already triggered threshold) initFactories("/threshd-configuration.xml","/test-thresholds-2.xml"); // Step 3: Execute Merge Configuration visitor.reload(); // Step 4: Trigger threshold (with new value) runGaugeDataTest(visitor, 5000); // Step 5: Send Rearmed event (with new value) runGaugeDataTest(visitor, 1000); // Verify Events verifyEvents(0); }
@Test public void testBug3146_inceaseTrigger() throws Exception { ThresholdingVisitor visitor = createVisitor(); // Add Events addHighThresholdEvent(1, 10000, 5000, 12000, "node", "node", "freeMem", null, null); addHighRearmEvent(1, 10000, 5000, Double.NaN, "node", "node", "freeMem", null, null); // Step 1: Trigger threshold runGaugeDataTest(visitor, 12000); // Step 2: Change Configuration (increasing value for already triggered threshold) initFactories("/threshd-configuration.xml","/test-thresholds-3.xml"); // Step 3: Execute Merge Configuration (Rearmed Event must be sent). visitor.reload(); verifyEvents(0); // Step 4: New collected data is not above the new threshold value. No Events generated resetAnticipator(); addHighThresholdEvent(1, 15000, 14000, 13000, "node", "node", "freeMem", null, null); runGaugeDataTest(visitor, 13000); verifyEvents(1); // Step 5: Trigger and rearm a threshold using new configuration resetAnticipator(); addHighThresholdEvent(1, 15000, 14000, 16000, "node", "node", "freeMem", null, null); addHighRearmEvent(1, 15000, 14000, 1000, "node", "node", "freeMem", null, null); runGaugeDataTest(visitor, 16000); runGaugeDataTest(visitor, 1000); verifyEvents(0); }