1 # -*- coding: utf-8 -*-
2 # Description: PHP-FPM 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/status'
20 # charts order (can be overridden if you want less charts, or different order)
21 ORDER = ['connections', 'requests', 'performance']
25 'options': [None, 'PHP-FPM Active Connections', 'connections', 'phpfpm', 'phpfpm.connections', 'line'],
28 ["maxActive", 'max active'],
32 'options': [None, 'PHP-FPM Requests', 'requests/s', 'phpfpm', 'phpfpm.requests', 'line'],
34 ["requests", None, "incremental"]
37 'options': [None, 'PHP-FPM Performance', 'status', 'phpfpm', 'phpfpm.performance', 'line'],
39 ["reached", 'max children reached'],
40 ["slow", 'slow requests']
45 class Service(UrlService):
46 def __init__(self, configuration=None, name=None):
47 UrlService.__init__(self, configuration=configuration, name=name)
48 if len(self.url) == 0:
49 self.url = "http://localhost/status"
51 self.definitions = CHARTS
52 self.assignment = {"active processes": 'active',
53 "max active processes": 'maxActive',
54 "idle processes": 'idle',
55 "accepted conn": 'requests',
56 "max children reached": 'reached',
57 "slow requests": 'slow'}
59 def _format_data(self):
61 Format data received from http request
65 raw = self._get_data().split('\n')
66 except AttributeError:
71 if str(tmp[0]) in self.assignment:
73 data[self.assignment[tmp[0]]] = int(tmp[1])
74 except (IndexError, ValueError):