Search in sources :

Example 1 with AlarmChecker

use of com.navercorp.pinpoint.web.alarm.checker.AlarmChecker in project pinpoint by naver.

the class AlarmReader method addChecker.

private void addChecker(Application application) {
    List<Rule> rules = alarmService.selectRuleByApplicationId(application.getName());
    long timeSlotEndTime = System.currentTimeMillis();
    Map<DataCollectorCategory, DataCollector> collectorMap = new HashMap<>();
    for (Rule rule : rules) {
        CheckerCategory checkerCategory = CheckerCategory.getValue(rule.getCheckerName());
        DataCollector collector = collectorMap.get(checkerCategory.getDataCollectorCategory());
        if (collector == null) {
            collector = dataCollectorFactory.createDataCollector(checkerCategory, application, timeSlotEndTime);
            collectorMap.put(collector.getDataCollectorCategory(), collector);
        }
        AlarmChecker checker = checkerCategory.createChecker(collector, rule);
        checkers.add(checker);
    }
}
Also used : HashMap(java.util.HashMap) DataCollectorCategory(com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) DataCollector(com.navercorp.pinpoint.web.alarm.collector.DataCollector) AlarmChecker(com.navercorp.pinpoint.web.alarm.checker.AlarmChecker)

Example 2 with AlarmChecker

use of com.navercorp.pinpoint.web.alarm.checker.AlarmChecker in project pinpoint by naver.

the class WriterTest method emailSendTest.

@Ignore
@Test
public void emailSendTest() throws Exception {
    Rule rule = new Rule("testService", "tomcat", CheckerCategory.SLOW_COUNT.getName(), 100, "testGroup", false, true, "");
    SlowCountChecker checker = new SlowCountChecker(null, rule) {

        @Override
        public boolean isDetected() {
            return true;
        }

        @Override
        protected long getDetectedValue() {
            return 10000;
        }
    };
    List<AlarmChecker> checkers = new LinkedList<AlarmChecker>();
    checkers.add(checker);
    writer.write(checkers);
}
Also used : SlowCountChecker(com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) LinkedList(java.util.LinkedList) AlarmChecker(com.navercorp.pinpoint.web.alarm.checker.AlarmChecker) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with AlarmChecker

use of com.navercorp.pinpoint.web.alarm.checker.AlarmChecker in project pinpoint by naver.

the class WriterTest method smsSendTest.

@Ignore
@Test
public void smsSendTest() throws Exception {
    Rule rule = new Rule("testService", "tomcat", CheckerCategory.SLOW_COUNT.getName(), 100, "testGroup", true, false, "");
    SlowCountChecker checker = new SlowCountChecker(null, rule) {

        @Override
        public boolean isDetected() {
            return true;
        }

        @Override
        protected long getDetectedValue() {
            return 10000;
        }
    };
    List<AlarmChecker> checkers = new LinkedList<AlarmChecker>();
    checkers.add(checker);
    writer.write(checkers);
}
Also used : SlowCountChecker(com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker) Rule(com.navercorp.pinpoint.web.alarm.vo.Rule) LinkedList(java.util.LinkedList) AlarmChecker(com.navercorp.pinpoint.web.alarm.checker.AlarmChecker) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with AlarmChecker

use of com.navercorp.pinpoint.web.alarm.checker.AlarmChecker in project pinpoint by naver.

the class AlarmWriter method write.

@Override
public void write(List<? extends AlarmChecker> checkers) throws Exception {
    Map<String, CheckerResult> beforeCheckerResults = alarmService.selectBeforeCheckerResults(checkers.get(0).getRule().getApplicationId());
    for (AlarmChecker checker : checkers) {
        CheckerResult beforeCheckerResult = beforeCheckerResults.get(checker.getRule().getCheckerName());
        if (beforeCheckerResult == null) {
            beforeCheckerResult = new CheckerResult(checker.getRule().getApplicationId(), checker.getRule().getCheckerName(), false, 0, 1);
        }
        if (checker.isDetected()) {
            sendAlarmMessage(beforeCheckerResult, checker);
        }
        alarmService.updateBeforeCheckerResult(beforeCheckerResult, checker);
    }
}
Also used : CheckerResult(com.navercorp.pinpoint.web.alarm.vo.CheckerResult) AlarmChecker(com.navercorp.pinpoint.web.alarm.checker.AlarmChecker)

Aggregations

AlarmChecker (com.navercorp.pinpoint.web.alarm.checker.AlarmChecker)4 Rule (com.navercorp.pinpoint.web.alarm.vo.Rule)3 SlowCountChecker (com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker)2 LinkedList (java.util.LinkedList)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 DataCollectorCategory (com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory)1 DataCollector (com.navercorp.pinpoint.web.alarm.collector.DataCollector)1 CheckerResult (com.navercorp.pinpoint.web.alarm.vo.CheckerResult)1 HashMap (java.util.HashMap)1