]> arthur.barton.de Git - netdata.git/blob - python.d/phpfpm.chart.py
unset update_every
[netdata.git] / python.d / phpfpm.chart.py
1 # -*- coding: utf-8 -*-
2 # Description: PHP-FPM netdata python.d plugin
3 # Author: Pawel Krupa (paulfantom)
4
5 from base import UrlService
6
7 # default module values (can be overridden per job in `config`)
8 # update_every = 2
9 # priority = 60000
10 # retries = 5
11
12 # default job configuration (overridden by python.d.plugin)
13 # config = {'local': {
14 #     'update_every': update_every,
15 #     'retries': retries,
16 #     'priority': priority,
17 #     'url': 'http://localhost/status'
18 # }}
19
20 # charts order (can be overridden if you want less charts, or different order)
21 ORDER = ['connections', 'requests', 'performance']
22
23 CHARTS = {
24     'connections': {
25         'options': "'' 'PHP-FPM Active Connections' 'connections' phpfpm phpfpm.connections line",
26         'lines': [
27             {"name": "active",
28              "options": "'' absolute 1 1"},
29             {"name": "maxActive",
30              "options": "'max active' absolute 1 1"},
31             {"name": "idle",
32              "options": "'' absolute 1 1"}
33         ]},
34     'requests': {
35         'options': "'' 'PHP-FPM Requests' 'requests/s' phpfpm phpfpm.requests line",
36         'lines': [
37             {"name": "requests",
38              "options": "'' incremental 1 1"}
39         ]},
40     'performance': {
41
42         'options': "'' 'PHP-FPM Performance' 'status' phpfpm phpfpm.performance line",
43         'lines': [
44             {"name": "reached",
45              "options": "'max children reached' absolute 1 1"},
46             {"name": "slow",
47              "options": "'slow requests' absolute 1 1"}
48         ]}
49 }
50
51
52 class Service(UrlService):
53     url = "http://localhost/status"
54     order = ORDER
55     charts = CHARTS
56     assignment = {"active processes": 'active',
57                   "max active processes": 'maxActive',
58                   "idle processes": 'idle',
59                   "accepted conn": 'requests',
60                   "max children reached": 'reached',
61                   "slow requests": 'slow'}
62
63     def _formatted_data(self):
64         """
65         Format data received from http request
66         :return: dict
67         """
68         raw = self._get_data().split('\n')
69         data = {}
70         for row in raw:
71             tmp = row.split(":")
72             if str(tmp[0]) in self.assignment:
73                 try:
74                     data[self.assignment[tmp[0]]] = int(tmp[1])
75                 except (IndexError, ValueError) as a:
76                     pass
77         return data