From: paulfantom Date: Wed, 22 Jun 2016 14:15:37 +0000 (+0200) Subject: fixing bugs in UrlService. X-Git-Tag: v1.3.0~106^2~7 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a37612cf2d6a2c68a2892504a8ad7d2ecb7ffd7;p=netdata.git fixing bugs in UrlService. --- diff --git a/plugins.d/python.d.plugin b/plugins.d/python.d.plugin index 2fde6d29..0407a480 100755 --- a/plugins.d/python.d.plugin +++ b/plugins.d/python.d.plugin @@ -220,6 +220,8 @@ class PythonCharts(object): if os.path.isfile(configfile): debug(mod.__name__ + ": loading module configuration: '" + configfile + "'") try: + if not hasattr(mod, 'config'): + mod.config = {} setattr(mod, 'config', self._parse_config(mod, read_config(configfile))) @@ -263,7 +265,7 @@ class PythonCharts(object): try: # get defaults from module source code defaults[key] = getattr(module, key) - except (KeyError, ValueError): + except (KeyError, ValueError, AttributeError): # if above failed, get defaults from global dict defaults[key] = BASE_CONFIG[key] @@ -576,7 +578,6 @@ def run(): ", ONLY_MODULES=" + str(modules)) # run plugins - modules = ['apache', 'nginx'] charts = PythonCharts(modules, MODULES_DIR, CONFIG_DIR + "python.d/", disabled) charts.check() charts.create() diff --git a/python.d/apache.chart.py b/python.d/apache.chart.py index 140f80ae..0892cce8 100644 --- a/python.d/apache.chart.py +++ b/python.d/apache.chart.py @@ -48,7 +48,7 @@ CHARTS = { "options": "'' absolute 8 1000000000"} ]}, 'requests': { - 'options': "''' 'apache Requests' 'requests/s' requests apache.requests line", + 'options': "'' 'apache Requests' 'requests/s' requests apache.requests line", 'lines': [ {"name": "requests", "options": "'' incremental 1 1"} @@ -79,21 +79,24 @@ CHARTS = { class Service(UrlService): - # url = "http://localhost/server-status?auto" - url = "http://www.apache.org/server-status?auto" - order = ORDER - charts = CHARTS - assignment = {"BytesPerReq": 'size_req', - "IdleWorkers": 'idle', - "BusyWorkers": 'busy', - "ReqPerSec": 'requests_sec', - "BytesPerSec": 'size_sec', - "Total Accesses": 'requests', - "Total kBytes": 'sent', - "ConnsTotal": 'connections', - "ConnsAsyncKeepAlive": 'keepalive', - "ConnsAsyncClosing": 'closing', - "ConnsAsyncWriting": 'writing'} + def __init__(self, configuration=None, name=None): + UrlService.__init__(self, configuration=configuration, name=name) + if len(self.url) == 0: + # url = "http://localhost/server-status?auto" # FIXME + self.url = "http://www.apache.org/server-status?auto" + self.order = ORDER + self.charts = CHARTS + self.assignment = {"BytesPerReq": 'size_req', + "IdleWorkers": 'idle', + "BusyWorkers": 'busy', + "ReqPerSec": 'requests_sec', + "BytesPerSec": 'size_sec', + "Total Accesses": 'requests', + "Total kBytes": 'sent', + "ConnsTotal": 'connections', + "ConnsAsyncKeepAlive": 'keepalive', + "ConnsAsyncClosing": 'closing', + "ConnsAsyncWriting": 'writing'} def _formatted_data(self): """ diff --git a/python.d/nginx.chart.py b/python.d/nginx.chart.py index 6675a69d..0e7fccc8 100644 --- a/python.d/nginx.chart.py +++ b/python.d/nginx.chart.py @@ -25,7 +25,7 @@ CHARTS = { 'options': "'' 'nginx Active Connections' 'connections' nginx nginx.connections line", 'lines': [ {"name": "active", - "options": "'' absolute 1 1"}, + "options": "'' absolute 1 1"} ]}, 'requests': { 'options': "'' 'nginx Requests' 'requests/s' nginx nginx.requests line", @@ -55,10 +55,13 @@ CHARTS = { class Service(UrlService): - # url = "http://localhost/stub_status" - url = "http://toothless.dragon/stub_status" - order = ORDER - charts = CHARTS + def __init__(self, configuration=None, name=None): + UrlService.__init__(self, configuration=configuration, name=name) + if len(self.url) == 0: + self.url = "http://toothless.dragon/stub_status" + # self.url = "http://localhost/stub_status" # FIXME + self.order = ORDER + self.charts = CHARTS def _formatted_data(self): """ diff --git a/python.d/phpfpm.chart.py b/python.d/phpfpm.chart.py index da8eea39..2e7ef6b7 100755 --- a/python.d/phpfpm.chart.py +++ b/python.d/phpfpm.chart.py @@ -50,15 +50,18 @@ CHARTS = { class Service(UrlService): - url = "http://localhost/status" - order = ORDER - charts = CHARTS - assignment = {"active processes": 'active', - "max active processes": 'maxActive', - "idle processes": 'idle', - "accepted conn": 'requests', - "max children reached": 'reached', - "slow requests": 'slow'} + def __init__(self, configuration=None, name=None): + UrlService.__init__(self, configuration=configuration, name=name) + if len(self.url) == 0: + self.url = "http://localhost/status" + self.order = ORDER + self.charts = CHARTS + self.assignment = {"active processes": 'active', + "max active processes": 'maxActive', + "idle processes": 'idle', + "accepted conn": 'requests', + "max children reached": 'reached', + "slow requests": 'slow'} def _formatted_data(self): """ diff --git a/python.d/python_modules/base.py b/python.d/python_modules/base.py index 1b958dec..69898944 100644 --- a/python.d/python_modules/base.py +++ b/python.d/python_modules/base.py @@ -97,24 +97,27 @@ class BaseService(object): class UrlService(BaseService): - charts = {} - # charts definitions in format: - # charts = { - # 'chart_name_in_netdata': { - # 'options': "parameters defining chart (passed to CHART statement)", - # 'lines': [ - # { 'name': 'dimension_name', - # 'options': 'dimension parameters (passed to DIMENSION statement)" - # } - # ]} - # } - order = [] - definitions = {} - # definitions are created dynamically in create() method based on 'charts' dictionary. format: - # definitions = { - # 'chart_name_in_netdata' : [ charts['chart_name_in_netdata']['lines']['name'] ] - # } - url = "" + def __init__(self, configuration=None, name=None): + self.charts = {} + # charts definitions in format: + # charts = { + # 'chart_name_in_netdata': { + # 'options': "parameters defining chart (passed to CHART statement)", + # 'lines': [ + # { 'name': 'dimension_name', + # 'options': 'dimension parameters (passed to DIMENSION statement)" + # } + # ]} + # } + self.order = [] + self.definitions = {} + # definitions are created dynamically in create() method based on 'charts' dictionary. format: + # definitions = { + # 'chart_name_in_netdata' : [ charts['chart_name_in_netdata']['lines']['name'] ] + # } + self.url = "" + BaseService.__init__(self, configuration=configuration, name=name) + def _get_data(self): """ diff --git a/web/index.html b/web/index.html index e7638317..3a84bba4 100644 --- a/web/index.html +++ b/web/index.html @@ -1366,6 +1366,16 @@ var menuData = { info: undefined, }, + 'nginx': { + title: 'nginx', + info: undefined, + }, + + 'apache': { + title: 'Apache', + info: undefined, + }, + 'named': { title: 'named', info: undefined @@ -1806,6 +1816,8 @@ function enrichChartData(chart) { case 'mysql': case 'phpfpm': + case 'nginx': + case 'apache': case 'named': case 'cgroup': chart.menu = chart.type;