1 # -*- coding: utf-8 -*-
2 # Description: nginx log netdata python.d module
3 # Author: Pawel Krupa (paulfantom)
4 # Modified for Gunicorn by: Jeff Willette (deltaskelta)
6 from base import LogService
16 'options': [None, 'gunicorn status codes', 'requests/s', 'requests', 'gunicorn_log.codes', 'stacked'],
18 ["2xx", None, "incremental"],
19 ["3xx", None, "incremental"],
20 ["4xx", None, "incremental"],
21 ["5xx", None, "incremental"]
26 class Service(LogService):
27 def __init__(self, configuration=None, name=None):
28 LogService.__init__(self, configuration=configuration, name=name)
29 if len(self.log_path) == 0:
30 self.log_path = "/var/log/gunicorn/access.log"
32 self.definitions = CHARTS
33 pattern = r'" ([0-9]{3}) '
34 #pattern = r'(?:" )([0-9][0-9][0-9]) ?'
35 self.regex = re.compile(pattern)
47 raw = self._get_raw_data()
52 except (ValueError, AttributeError):
57 code = regex.search(line)
59 beginning = code.group(1)[0]
60 except AttributeError:
65 elif beginning == '3':
67 elif beginning == '4':
69 elif beginning == '5':