示例#1
0
 def test_log_brok_illegal_char(self):
     data = {
         'log': '[1329144231] SERVICE ALERT: www.cibc.com;www.cibc.com;WARNING;HARD;4;WARNING - load average: 5.04, 4.67, 5.04'
     }
     brok = Brok('log', data)
     brok.prepare()
     broker = InfluxdbBroker(self.basic_modconf)
     broker.manage_log_brok(brok)
     point = broker.buffer[0]
     self.assertEqual(point['name'], 'www_cibc_com.www_cibc_com._events_.ALERT')
 def test_log_brok_illegal_char(self):
     data = {
         'log':
         '[1329144231] SERVICE ALERT: www.cibc.com;www.cibc.com;WARNING;HARD;4;WARNING - load average: 5.04, 4.67, 5.04'
     }
     brok = Brok('log', data)
     brok.prepare()
     broker = InfluxdbBroker(self.basic_modconf)
     broker.manage_log_brok(brok)
     point = broker.buffer[0]
     self.assertEqual(point['name'],
                      'www_cibc_com.www_cibc_com._events_.ALERT')
    def test_manage_log_brok(self):
        data = {
            'log':
            '[1402515279] HOST NOTIFICATION: admin;localhost;CRITICAL;notify-service-by-email;Connection refused'
        }
        brok = Brok('log', data)
        brok.prepare()

        broker = InfluxdbBroker(self.basic_modconf)
        broker.manage_log_brok(brok)

        # make sure that this has generated only 1 point
        self.assertEqual(len(broker.buffer), 1)
        point = broker.buffer[0]

        # validate the point
        expected = {
            'points': [[
                None, 'CRITICAL', 'admin', 1402515279,
                'notify-service-by-email', 'HOST'
            ]],
            'name':
            'localhost._events_.NOTIFICATION',
            'columns': [
                'acknownledgement', 'state', 'contact', 'time',
                'notification_method', 'notification_type'
            ]
        }

        self.assertEqual(expected, point)

        # And that there is as much columns as there is points
        # (manage_log_brok has a special way of creating points)
        self.assertEqual(len(point['points'][0]), len(point['columns']))

        # A service notification's name should be different (host.service._events_.[event_type])
        data[
            'log'] = '[1402515279] SERVICE NOTIFICATION: admin;localhost;check-ssh;CRITICAL;notify-service-by-email;Connection refused'
        brok = Brok('log', data)
        brok.prepare()
        broker.buffer = []
        broker.manage_log_brok(brok)
        point = broker.buffer[0]
        self.assertEqual(point['name'],
                         'localhost.check-ssh._events_.NOTIFICATION')
示例#4
0
    def test_manage_log_brok(self):
        data = {
            'log': '[1402515279] HOST NOTIFICATION: admin;localhost;CRITICAL;notify-service-by-email;Connection refused'
        }
        brok = Brok('log', data)
        brok.prepare()

        broker = InfluxdbBroker(self.basic_modconf)
        broker.manage_log_brok(brok)

        # make sure that this has generated only 1 point
        self.assertEqual(len(broker.buffer), 1)
        point = broker.buffer[0]

        # validate the point
        expected = {
            'points': [[None, 'CRITICAL', 'admin', 1402515279, 'notify-service-by-email', 'HOST']],
            'name': 'localhost._events_.NOTIFICATION',
            'columns': ['acknownledgement', 'state', 'contact', 'time', 'notification_method', 'notification_type']
        }

        self.assertEqual(expected, point)

        # And that there is as much columns as there is points
        # (manage_log_brok has a special way of creating points)
        self.assertEqual(
            len(point['points'][0]),
            len(point['columns'])
        )

        # A service notification's name should be different (host.service._events_.[event_type])
        data['log'] = '[1402515279] SERVICE NOTIFICATION: admin;localhost;check-ssh;CRITICAL;notify-service-by-email;Connection refused'
        brok = Brok('log', data)
        brok.prepare()
        broker.buffer = []
        broker.manage_log_brok(brok)
        point = broker.buffer[0]
        self.assertEqual(point['name'], 'localhost.check-ssh._events_.NOTIFICATION')