]> arthur.barton.de Git - netdata.git/blobdiff - python.d/example.chart.py
rename chart fields to avoid conflicts with backends; fixes #1962
[netdata.git] / python.d / example.chart.py
index 1f38e28e695079cc302562944de27e1f19500c30..adf97a921eb93d129a2e1be5cd833d40c1679207 100644 (file)
@@ -1,30 +1,36 @@
-# Description: example netdata python.d plugin
+# -*- coding: utf-8 -*-
+# Description: example netdata python.d module
 # Author: Pawel Krupa (paulfantom)
 
+import os
 import random
-from base import BaseService
+from base import SimpleService
+
+NAME = os.path.basename(__file__).replace(".chart.py", "")
 
-NAME = "example.chart.py"
 # default module values
-update_every = 3
+# update_every = 4
 priority = 90000
-retries = 7
+retries = 60
 
 
-class Service(BaseService):
+class Service(SimpleService):
     def __init__(self, configuration=None, name=None):
-        super().__init__(configuration=configuration)
+        super(self.__class__,self).__init__(configuration=configuration, name=name)
 
     def check(self):
         return True
     
     def create(self):
-        print("CHART example.python_random '' 'A random number' 'random number' random random line "+str(self.priority)+" "+str(self.update_every))
-        print("DIMENSION random1 '' absolute 1 1")
+        self.chart("example.python_random", '', 'A random number', 'random number',
+                   'random', 'random', 'line', self.priority, self.update_every)
+        self.dimension('random1')
+        self.commit()
         return True
     
     def update(self, interval):
-        print("BEGIN example.python_random "+str(interval))
-        print("SET random1 = "+str(random.randint(0,100)))
-        print("END")
+        self.begin("example.python_random", interval)
+        self.set("random1", random.randint(0, 100))
+        self.end()
+        self.commit()
         return True