1 # -*- coding: utf-8 -*-
2 # Description: nginx netdata python.d plugin
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': "'' 'nginx Active Connections' 'connections' nginx nginx.connections line",
28 "options": "'' absolute 1 1"}
31 'options': "'' 'nginx Requests' 'requests/s' nginx nginx.requests line",
34 "options": "'' incremental 1 1"}
36 'connection_status': {
37 'options': "'' 'nginx Active Connections by Status' 'connections' nginx nginx.connection.status line",
40 "options": "'' absolute 1 1"},
42 "options": "'' absolute 1 1"},
44 "options": "idle absolute 1 1"}
47 'options': "'' 'nginx Connections Rate' 'connections/s' nginx nginx.performance line",
50 "options": "accepted incremental 1 1"},
52 "options": "'' incremental 1 1"}
57 class Service(UrlService):
58 def __init__(self, configuration=None, name=None):
59 UrlService.__init__(self, configuration=configuration, name=name)
60 if len(self.url) == 0:
61 self.url = "http://localhost/stub_status"
65 def _formatted_data(self):
67 Format data received from http request
70 raw = self._get_data().split(" ")
72 return {'active': int(raw[2]),
73 'requests': int(raw[7]),
74 'reading': int(raw[11]),
75 'writing': int(raw[13]),
76 'waiting': int(raw[15]),
77 'accepts': int(raw[8]),
78 'handled': int(raw[9])}