blob: 19780aaae6055b6174c426295e531954bef73c9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
##############################################################################
# Copyright (c) 2016 ZTE Corp and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
from base import BaseCollector
from qtip.base.constant import CollectorProp as CProp
from qtip.loader.file import FileLoader
class LogfileCollector(BaseCollector):
"""collect performance metrics from log files"""
def __init__(self, config, paths=None):
super(LogfileCollector, self).__init__(config)
self.loader = FileLoader('.', paths)
def collect(self):
captured = {}
for item in self._config[CProp.LOGS]:
captured.update(self._parse_log(item))
return captured
def _parse_log(self, log_item):
captured = {}
# TODO(yujunz) select parser by name
if CProp.GREP in log_item:
for rule in log_item[CProp.GREP]:
captured.update(self._grep(log_item[CProp.FILENAME], rule))
return captured
def _grep(self, filename, rule):
return {}
|