]> arthur.barton.de Git - netdata.git/commitdiff
fixing bugs in UrlService.
authorpaulfantom <paulfantom@gmail.com>
Wed, 22 Jun 2016 14:15:37 +0000 (16:15 +0200)
committerpaulfantom <paulfantom@gmail.com>
Wed, 22 Jun 2016 14:15:37 +0000 (16:15 +0200)
plugins.d/python.d.plugin
python.d/apache.chart.py
python.d/nginx.chart.py
python.d/phpfpm.chart.py
python.d/python_modules/base.py
web/index.html

index 2fde6d2941fb3816df5e77f79444c8400aa03083..0407a480893bfae04a67a3148b6193afeaf7ea54 100755 (executable)
@@ -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()
index 140f80ae86f20d3e3c59bc1e3be84d1516ab74e3..0892cce83f3bb7c1403c5282a670b135684ba045 100644 (file)
@@ -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):
         """
index 6675a69d407bddf0d97204a037b776418289704e..0e7fccc8a806fb299af17503efc6290cc8de65df 100644 (file)
@@ -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):
         """
index da8eea3932c6ad7ff7c0423c83fa43b50ca39310..2e7ef6b7dc5b06c7beb5c9db2b48a3ebef34c488 100755 (executable)
@@ -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):
         """
index 1b958dec124ee8f2765f99a819158b3dc02497bd..69898944f12541d7667a3f870fab0e6858245b02 100644 (file)
@@ -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):
         """
index e7638317fb40c8544d2973a9b4c2dd4d1c90559e..3a84bba4bd6d6d121e7c822f014a6e94f3a0abc2 100644 (file)
@@ -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;