fixing bugs in UrlService.
paulfantom committed
Jun 22, 2016 at 16:15 UTC
2a37612cf2d6a2c68a2892504a8ad7d2ecb7ffd7
6 files changed
+75
-50
plugins.d/python.d.plugin
+3
-2
@@ -220,6 +220,8 @@ class PythonCharts(object):
220
if os.path.isfile(configfile):
221
debug(mod.__name__ + ": loading module configuration: '" + configfile + "'")
222
try:
223
+ if not hasattr(mod, 'config'):
224
+ mod.config = {}
225
setattr(mod,
226
'config',
227
self._parse_config(mod, read_config(configfile)))
@@ -263,7 +265,7 @@ class PythonCharts(object):
265
try:
266
# get defaults from module source code
267
defaults[key] = getattr(module, key)
266
- except (KeyError, ValueError):
268
+ except (KeyError, ValueError, AttributeError):
269
# if above failed, get defaults from global dict
270
defaults[key] = BASE_CONFIG[key]
271
@@ -576,7 +578,6 @@ def run():
578
", ONLY_MODULES=" + str(modules))
579
580
# run plugins
579
- modules = ['apache', 'nginx']
581
charts = PythonCharts(modules, MODULES_DIR, CONFIG_DIR + "python.d/", disabled)
582
charts.check()
583
charts.create()
python.d/apache.chart.py
+19
-16
@@ -48,7 +48,7 @@ CHARTS = {
48
"options": "'' absolute 8 1000000000"}
49
]},
50
'requests': {
51
- 'options': "''' 'apache Requests' 'requests/s' requests apache.requests line",
51
+ 'options': "'' 'apache Requests' 'requests/s' requests apache.requests line",
52
'lines': [
53
{"name": "requests",
54
"options": "'' incremental 1 1"}
@@ -79,21 +79,24 @@ CHARTS = {
79
80
81
class Service(UrlService):
82
- # url = "http://localhost/server-status?auto"
83
- url = "http://www.apache.org/server-status?auto"
84
- order = ORDER
85
- charts = CHARTS
86
- assignment = {"BytesPerReq": 'size_req',
87
- "IdleWorkers": 'idle',
88
- "BusyWorkers": 'busy',
89
- "ReqPerSec": 'requests_sec',
90
- "BytesPerSec": 'size_sec',
91
- "Total Accesses": 'requests',
92
- "Total kBytes": 'sent',
93
- "ConnsTotal": 'connections',
94
- "ConnsAsyncKeepAlive": 'keepalive',
95
- "ConnsAsyncClosing": 'closing',
96
- "ConnsAsyncWriting": 'writing'}
82
+ def __init__(self, configuration=None, name=None):
83
+ UrlService.__init__(self, configuration=configuration, name=name)
84
+ if len(self.url) == 0:
85
+ # url = "http://localhost/server-status?auto" # FIXME
86
+ self.url = "http://www.apache.org/server-status?auto"
87
+ self.order = ORDER
88
+ self.charts = CHARTS
89
+ self.assignment = {"BytesPerReq": 'size_req',
90
+ "IdleWorkers": 'idle',
91
+ "BusyWorkers": 'busy',
92
+ "ReqPerSec": 'requests_sec',
93
+ "BytesPerSec": 'size_sec',
94
+ "Total Accesses": 'requests',
95
+ "Total kBytes": 'sent',
96
+ "ConnsTotal": 'connections',
97
+ "ConnsAsyncKeepAlive": 'keepalive',
98
+ "ConnsAsyncClosing": 'closing',
99
+ "ConnsAsyncWriting": 'writing'}
100
101
def _formatted_data(self):
102
"""
python.d/nginx.chart.py
+8
-5
@@ -25,7 +25,7 @@ CHARTS = {
25
'options': "'' 'nginx Active Connections' 'connections' nginx nginx.connections line",
26
'lines': [
27
{"name": "active",
28
- "options": "'' absolute 1 1"},
28
+ "options": "'' absolute 1 1"}
29
]},
30
'requests': {
31
'options': "'' 'nginx Requests' 'requests/s' nginx nginx.requests line",
@@ -55,10 +55,13 @@ CHARTS = {
55
56
57
class Service(UrlService):
58
- # url = "http://localhost/stub_status"
59
- url = "http://toothless.dragon/stub_status"
60
- order = ORDER
61
- charts = CHARTS
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://toothless.dragon/stub_status"
62
+ # self.url = "http://localhost/stub_status" # FIXME
63
+ self.order = ORDER
64
+ self.charts = CHARTS
65
66
def _formatted_data(self):
67
"""
python.d/phpfpm.chart.py
+12
-9
@@ -50,15 +50,18 @@ CHARTS = {
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'}
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"
57
+ self.order = ORDER
58
+ self.charts = CHARTS
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'}
65
66
def _formatted_data(self):
67
"""
python.d/python_modules/base.py
+21
-18
@@ -97,24 +97,27 @@ class BaseService(object):
97
98
99
class UrlService(BaseService):
100
- charts = {}
101
- # charts definitions in format:
102
- # charts = {
103
- # 'chart_name_in_netdata': {
104
- # 'options': "parameters defining chart (passed to CHART statement)",
105
- # 'lines': [
106
- # { 'name': 'dimension_name',
107
- # 'options': 'dimension parameters (passed to DIMENSION statement)"
108
- # }
109
- # ]}
110
- # }
111
- order = []
112
- definitions = {}
113
- # definitions are created dynamically in create() method based on 'charts' dictionary. format:
114
- # definitions = {
115
- # 'chart_name_in_netdata' : [ charts['chart_name_in_netdata']['lines']['name'] ]
116
- # }
117
- url = ""
100
+ def __init__(self, configuration=None, name=None):
101
+ self.charts = {}
102
+ # charts definitions in format:
103
+ # charts = {
104
+ # 'chart_name_in_netdata': {
105
+ # 'options': "parameters defining chart (passed to CHART statement)",
106
+ # 'lines': [
107
+ # { 'name': 'dimension_name',
108
+ # 'options': 'dimension parameters (passed to DIMENSION statement)"
109
+ # }
110
+ # ]}
111
+ # }
112
+ self.order = []
113
+ self.definitions = {}
114
+ # definitions are created dynamically in create() method based on 'charts' dictionary. format:
115
+ # definitions = {
116
+ # 'chart_name_in_netdata' : [ charts['chart_name_in_netdata']['lines']['name'] ]
117
+ # }
118
+ self.url = ""
119
+ BaseService.__init__(self, configuration=configuration, name=name)
120
+
121
122
def _get_data(self):
123
"""
web/index.html
+12
@@ -1366,6 +1366,16 @@ var menuData = {
1366
info: undefined,
1367
},
1368
1369
+ 'nginx': {
1370
+ title: 'nginx',
1371
+ info: undefined,
1372
+ },
1373
+
1374
+ 'apache': {
1375
+ title: 'Apache',
1376
+ info: undefined,
1377
+ },
1378
+
1379
'named': {
1380
title: 'named',
1381
info: undefined
@@ -1806,6 +1816,8 @@ function enrichChartData(chart) {
1816
1817
case 'mysql':
1818
case 'phpfpm':
1819
+ case 'nginx':
1820
+ case 'apache':
1821
case 'named':
1822
case 'cgroup':
1823
chart.menu = chart.type;