Exemple #1
0
    def test_alerting_receive_high(self):
        analyzer = LogAnalyzer("1")
        analyzer.analyze_alert(["log1", "log2"])
        # now becomes alerting and average 2 with 1 count
        msg = analyzer.analyze_alert(["log1", "log2"])

        self.assertEqual(msg, "")
        self.assertTrue(analyzer.alerting)
Exemple #2
0
    def test_alerting_receive_high(self):
        analyzer = LogAnalyzer("1")
        analyzer.analyze_alert(["log1", "log2"])
        # now becomes alerting and average 2 with 1 count
        msg = analyzer.analyze_alert(["log1", "log2"])

        self.assertEqual(msg, "")
        self.assertTrue(analyzer.alerting)
Exemple #3
0
    def test_alerting_receive_low(self):
        analyzer = LogAnalyzer("1")
        analyzer.analyze_alert(["log1", "log2"])
        # now becomes alerting and average 2 with 1 count
        analyzer.analyze_alert([])
        msg = analyzer.analyze_alert([])
        # (2 / 3) < 1
        recover_msg_prefix = "Traffic recovered"

        self.assertEqual(msg[:len(recover_msg_prefix)], recover_msg_prefix)
        self.assertFalse(analyzer.alerting)
Exemple #4
0
    def test_alerting_receive_low(self):
        analyzer = LogAnalyzer("1")
        analyzer.analyze_alert(["log1", "log2"])
        # now becomes alerting and average 2 with 1 count
        analyzer.analyze_alert([])
        msg = analyzer.analyze_alert([])
        # (2 / 3) < 1
        recover_msg_prefix = "Traffic recovered"

        self.assertEqual(msg[:len(recover_msg_prefix)], recover_msg_prefix )
        self.assertFalse(analyzer.alerting)
Exemple #5
0
def logmonitor(stdscr, *args, **kwargs):
    # init
    reader = LogReader(sys.argv[1])
    publisher = LogPublisher(reader)
    analyzer = LogAnalyzer(sys.argv[2])
    display = LogDisplay(stdscr, analyzer)

    publisher.add_subscriber(LogSubscriber(10, display.refresh_most_hits))
    publisher.add_subscriber(LogSubscriber(1, display.refresh_alert))

    # publish event every one second
    while True:
        time.sleep(1)
        publisher.publish()

    # deinit
    reader.close()
Exemple #6
0
    def test_notalerting_receive_low(self):
        analyzer = LogAnalyzer("1")
        msg = analyzer.analyze_alert([])

        self.assertEqual(msg, "")
        self.assertFalse(analyzer.alerting)
Exemple #7
0
    def test_notalerting_receive_high(self):
        analyzer = LogAnalyzer("1")
        msg = analyzer.analyze_alert(["log1", "log2"])

        self.assertEqual(msg[:4], "High")
        self.assertTrue(analyzer.alerting)
Exemple #8
0
    def test_notalerting_receive_high(self):
        analyzer = LogAnalyzer("1")
        msg = analyzer.analyze_alert(["log1", "log2"])

        self.assertEqual(msg[:4], "High")
        self.assertTrue(analyzer.alerting)
Exemple #9
0
    def test_notalerting_receive_low(self):
        analyzer = LogAnalyzer("1")
        msg = analyzer.analyze_alert([])

        self.assertEqual(msg, "")
        self.assertFalse(analyzer.alerting)