1 # -*- coding: utf-8 -*-
2 # Description: nginx log netdata python.d module
3 # Author: Pawel Krupa (paulfantom)
5 from base import LogService
15 'options': [None, 'nginx status codes', 'requests/s', 'requests', 'nginx_log.codes', 'stacked'],
17 ["2xx", None, "incremental"],
18 ["3xx", None, "incremental"],
19 ["4xx", None, "incremental"],
20 ["5xx", None, "incremental"]
25 class Service(LogService):
26 def __init__(self, configuration=None, name=None):
27 LogService.__init__(self, configuration=configuration, name=name)
28 if len(self.log_path) == 0:
29 self.log_path = "/var/log/nginx/access.log"
31 self.definitions = CHARTS
32 pattern = r'" ([0-9]{3}) ?'
33 #pattern = r'(?:" )([0-9][0-9][0-9]) ?'
34 self.regex = re.compile(pattern)
46 raw = self._get_raw_data()
51 except (ValueError, AttributeError):
56 code = regex.search(line)
58 beginning = code.group(1)[0]
59 except AttributeError:
64 elif beginning == '3':
66 elif beginning == '4':
68 elif beginning == '5':