Ejemplo n.º 1
0
    def __init__(self, *a):
        Source.__init__(self, *a)

        self.parser = parsers.ApacheLogParser(
            self.config.get('log_format', 'combined'))

        self.log = follower.LogFollower(self.config['file'],
                                        parser=self._parser_proxy,
                                        history=False)

        self.max_lines = int(self.config.get('max_lines', 2000))
Ejemplo n.º 2
0
    def __init__(self, *a):
        Source.__init__(self, *a)

        parser = parsers.ApacheLogParser(
            self.config.get('log_format', 'combined'))

        history = self.config.get('history', False)

        self.log = follower.LogFollower(self.config['file'],
                                        parser=parser.parse,
                                        history=history)

        self.max_lines = int(self.config.get('max_lines', 2000))
        self.bucket_res = int(self.config.get('resolution', 10))

        self.bucket = 0
Ejemplo n.º 3
0
    def test_apache_parser(self):
        log = parsers.ApacheLogParser('combined')

        line = '192.168.0.102 - - [16/Jan/2015:11:11:45 +0200] "GET / HTTP/1.1" 200 709 "-" "My browser"'

        want = {
            'status': 200,
            'request': 'GET / HTTP/1.1',
            'bytes': 709,
            'user-agent': 'My browser',
            'client': '192.168.0.102',
            'time': datetime.datetime(2015, 1, 16, 11, 11, 45),
            'referer': None,
            'logname': None,
            'user': None,
        }

        p = log.parse(line)

        for k, v in want.items():
            self.assertEquals(p[k], v)