1 # -*- coding: utf-8 -*-
2 # Description: apache 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://www.apache.org/server-status?auto'
20 # charts order (can be overridden if you want less charts, or different order)
21 ORDER = ['requests', 'connections', 'conns_async', 'net', 'workers', 'reqpersec', 'bytespersec', 'bytesperreq']
25 'options': "'' 'apache Lifetime Avg. Response Size' 'bytes/request' statistics apache.bytesperreq area",
28 "options": "'' absolute 1 1000000"}
31 'options': "'' 'apache Workers' 'workers' workers apache.workers stacked",
34 "options": "'' absolute 1 1"},
36 "options": "'' absolute 1 1"}
39 'options': "'' 'apache Lifetime Avg. Requests/s' 'requests/s' statistics apache.reqpersec area",
41 {"name": "requests_sec",
42 "options": "'' absolute 1 1000000"}
45 'options': "'' 'apache Lifetime Avg. Bandwidth/s' 'kilbits/s' statistics apache.bytesperreq area",
48 "options": "'' absolute 8 1000000000"}
51 'options': "'' 'apache Requests' 'requests/s' requests apache.requests line",
54 "options": "'' incremental 1 1"}
57 'options': "'' 'apache Bandwidth' 'kilobits/s' bandwidth apache.net area",
60 "options": "'' incremental 8 1"}
63 'options': "'' 'apache Connections' 'connections' connections apache.connections line",
65 {"name": "connections",
66 "options": "'' absolute 1 1"}
69 'options': "'' 'apache Async Connections' 'connections' connections apache.conns_async stacked",
72 "options": "'' absolute 1 1"},
74 "options": "'' absolute 1 1"},
76 "options": "'' absolute 1 1"}
81 class Service(UrlService):
82 def __init__(self, configuration=None, name=None):
83 UrlService.__init__(self, configuration=configuration, name=name)
84 if len(self.url) == 0:
85 self.url = "http://localhost/server-status?auto"
88 self.assignment = {"BytesPerReq": 'size_req',
89 "IdleWorkers": 'idle',
90 "BusyWorkers": 'busy',
91 "ReqPerSec": 'requests_sec',
92 "BytesPerSec": 'size_sec',
93 "Total Accesses": 'requests',
94 "Total kBytes": 'sent',
95 "ConnsTotal": 'connections',
96 "ConnsAsyncKeepAlive": 'keepalive',
97 "ConnsAsyncClosing": 'closing',
98 "ConnsAsyncWriting": 'writing'}
100 def _formatted_data(self):
102 Format data received from http request
105 raw = self._get_data().split("\n")
109 if str(tmp[0]) in self.assignment:
112 if tmp[0] in ("BytesPerReq", "ReqPerSec", "BytesPerSec"):
114 data[self.assignment[tmp[0]]] = int(float(tmp[1])*multiplier)
115 except (IndexError, ValueError) as a: