]> arthur.barton.de Git - netdata.git/commitdiff
first run
authorpaulfantom <paulfantom@gmail.com>
Sat, 18 Jun 2016 10:26:25 +0000 (12:26 +0200)
committerpaulfantom <paulfantom@gmail.com>
Sat, 18 Jun 2016 10:26:25 +0000 (12:26 +0200)
plugins.d/python.d.plugin
python.d/mysql.chart.py
python.d/python_modules/base.py

index ce797087f503918c1a2bd687dca42553e8b54278..af9da3bd868b90c228c7b98178271ac120de5e1d 100755 (executable)
@@ -41,10 +41,11 @@ class PythonCharts(object):
         loaded_modules = [ m for m in modules if m.__name__ not in modules_disabled ]
         
         # load configuration files
-        confiured_modules = self._load_configs(loaded_modules)
+        configured_modules = self._load_configs(loaded_modules)
 
         # good economy and prosperity:
         self.jobs = self._create_jobs(configured_modules)
+        debug(self.jobs)
 
 
     def _create_jobs(self,modules):
@@ -120,7 +121,7 @@ class PythonCharts(object):
                 try:
                     setattr(mod,
                             'config',
-                            self._parse_config(mod,read_config(config_file))
+                            self._parse_config(mod,read_config(configfile)))
                 except Exception as e:
                     debug("something went wrong while loading configuration",e)
             else:
@@ -146,16 +147,13 @@ class PythonCharts(object):
                     defaults[key] = BASE_CONFIG[key]
 
         # assign variables needed by supervisor to every job configuration
-        out = {}
         for name in config:
-            out[name] = {}
             for key in BASE_CONFIG:
                 if key not in config[name]:
-                    out[name][key] = defaults[key] 
-                except (KeyError,ValueError):
-
+                    config[name][key] = defaults[key] 
+        
         # return dictionary of jobs where every job has BASE_CONFIG variables
-        return out
+        return config
 
     def _stop(self, job, reason=None): #FIXME test if Service has __name__
     # modifies self.jobs
@@ -164,23 +162,23 @@ class PythonCharts(object):
             return
         elif reason[:3] == "no ":
             debug("chart '" +
-                  job.__name__,
+                  job.execution_name,
                   "' does not seem to have " +
                   reason[3:] +
                   "() function. Disabling it.")
         elif reason[:7] == "failed ":
             debug("chart '" +
-                  job.__name__ + "' " +
+                  job.execution_name + "' " +
                   reason[7:] +
                   "() function reports failure.")
         elif reason[:13] == "configuration":
-            debug(job.__name__,
+            debug(job.execution_name,
                   "configuration file '" +
                   self.configs +
-                  job.__name__ +
+                  job.execution_name +
                   ".conf' not found. Using defaults.")
         elif reason[:11] == "misbehaving":
-            debug(job.__name__, "is "+reason)
+            debug(job.execution_name, "is "+reason)
 
     def check(self):
     # try to execute check() on every job
index bc80e46b9edcb23aac8865549b912f506b17950a..793b6aec4535e596f9b618a399217ba028d14bb1 100644 (file)
@@ -23,16 +23,16 @@ from base import BaseService
 
 # default configuration (overriden by python.d.plugin)
 # FIXME change password
-config = [
-    {
-        'name'     : 'local',
+config = {
+    'local': {
         'user'     : 'root',
         'password' : 'a',
         'socket'   : '/var/run/mysqld/mysqld.sock',
         'update_every' : 3,
-        'retries'  : 4
+        'retries'  : 4,
+        'priority' : 100
     }
-]
+}
 
 # default module values (can be overridden per job in `config`)
 update_every = 3
@@ -335,11 +335,11 @@ CHARTS = {
 
 class Service(BaseService):
     def __init__(self,configuration=None,name=None):
-        super().__init__(configuration)
+        super().__init__(configuration=configuration)
+        self.name = name
         self.configuration = self._parse_config(configuration)
         self.connection = None
         self.defs = {}
-        self.name = name
 
     def _parse_config(self,configuration):
         # parse configuration to collect data from mysql server
@@ -405,7 +405,6 @@ class Service(BaseService):
 
     def create(self):
         for name in ORDER:
-            print(name)
             self.defs[name] = []
             for line in CHARTS[name][1]:
                 self.defs[name].append(line[0])
@@ -456,7 +455,7 @@ class Service(BaseService):
 
 #FIXME debug only:
 if __name__ == "__main__":
-    my = Service(config[0],'loc')
+    my = Service(config['local'],'loc')
     my.check()
     my.create()
     my.update(1)
index 5caf50b9667472e0b1318ce8e98820dfefc58303..05dc49c4edccc152d3b977609be1554643d1406d 100644 (file)
@@ -2,12 +2,13 @@
 # Author: Pawel Krupa (paulfantom)
 
 from time import time
+import sys
 
 
 class BaseService(object):
     def __init__(self,name=None,configuration=None):
+        print(configuration)
         if configuration is None:
-            # use defaults
             self.error("BaseService: no configuration parameters supplied. Cannot create Service.")
             raise RuntimeError
         else: