1 # -*- coding: utf-8 -*-
2 # Description: nginx netdata python.d module
3 # Author: Pawel Krupa (paulfantom)
5 from base import UrlService
7 # default module values (can be overridden per job in `config`)
12 # default job configuration (overridden by python.d.plugin)
13 # config = {'local': {
14 # 'update_every': update_every,
16 # 'priority': priority,
17 # 'url': 'http://localhost/stub_status'
20 # charts order (can be overridden if you want less charts, or different order)
21 ORDER = ['connections', 'requests', 'connection_status', 'connect_rate']
25 'options': [None, 'nginx Active Connections', 'connections', 'active connections', 'nginx.connections', 'line'],
30 'options': [None, 'nginx Requests', 'requests/s', 'requests', 'nginx.requests', 'line'],
32 ["requests", None, 'incremental']
34 'connection_status': {
35 'options': [None, 'nginx Active Connections by Status', 'connections', 'status', 'nginx.connection_status', 'line'],
42 'options': [None, 'nginx Connections Rate', 'connections/s', 'connections rate', 'nginx.connect_rate', 'line'],
44 ["accepts", "accepted", "incremental"],
45 ["handled", None, "incremental"]
50 class Service(UrlService):
51 def __init__(self, configuration=None, name=None):
52 UrlService.__init__(self, configuration=configuration, name=name)
53 if len(self.url) == 0:
54 self.url = "http://localhost/stub_status"
56 self.definitions = CHARTS
60 Format data received from http request
64 raw = self._get_raw_data().split(" ")
65 return {'active': int(raw[2]),
66 'requests': int(raw[9]),
67 'reading': int(raw[11]),
68 'writing': int(raw[13]),
69 'waiting': int(raw[15]),
70 'accepts': int(raw[7]),
71 'handled': int(raw[8])}
72 except (ValueError, AttributeError):