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': "'' 'PHP-FPM Active Connections' 'connections' phpfpm phpfpm.connections line",
28 "options": "'' absolute 1 1"},
30 "options": "'max active' absolute 1 1"},
32 "options": "'' absolute 1 1"}
35 'options': "'' 'PHP-FPM Requests' 'requests/s' phpfpm phpfpm.requests line",
38 "options": "'' incremental 1 1"}
42 'options': "'' 'PHP-FPM Performance' 'status' phpfpm phpfpm.performance line",
45 "options": "'max children reached' absolute 1 1"},
47 "options": "'slow requests' absolute 1 1"}
52 class Service(UrlService):
53 def __init__(self, configuration=None, name=None):
54 UrlService.__init__(self, configuration=configuration, name=name)
55 if len(self.url) == 0:
56 self.url = "http://localhost/status"
59 self.assignment = {"active processes": 'active',
60 "max active processes": 'maxActive',
61 "idle processes": 'idle',
62 "accepted conn": 'requests',
63 "max children reached": 'reached',
64 "slow requests": 'slow'}
66 def _formatted_data(self):
68 Format data received from http request
71 raw = self._get_data().split('\n')
75 if str(tmp[0]) in self.assignment:
77 data[self.assignment[tmp[0]]] = int(tmp[1])
78 except (IndexError, ValueError) as a: