]> arthur.barton.de Git - netdata.git/blobdiff - python.d/example.chart.py
Merge pull request #1815 from lfdominguez/master
[netdata.git] / python.d / example.chart.py
index 18c72032eb5a4930983a9ecce225daebae3308d6..adf97a921eb93d129a2e1be5cd833d40c1679207 100644 (file)
@@ -1,20 +1,20 @@
 # -*- coding: utf-8 -*-
-# Description: example netdata python.d plugin
+# 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", "")
 
 # default module values
-update_every = 4
+update_every = 4
 priority = 90000
-retries = 7
+retries = 60
 
 
-class Service(BaseService):
+class Service(SimpleService):
     def __init__(self, configuration=None, name=None):
         super(self.__class__,self).__init__(configuration=configuration, name=name)
 
@@ -22,15 +22,15 @@ class Service(BaseService):
         return True
     
     def create(self):
-        chart = "CHART example.python_random '' 'A random number' 'random number' random random line " + \
-                str(self.priority) + " " + \
-                str(self.update_every) + "\n" + \
-                "DIMENSION random1 '' absolute 1 1"
-        print(chart)
+        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):
-        chart = "BEGIN example.python_random "+str(interval)+"\n"
-        chart += "SET random1 = "+str(random.randint(0,100))+"\n"
-        print(chart + "END")
+        self.begin("example.python_random", interval)
+        self.set("random1", random.randint(0, 100))
+        self.end()
+        self.commit()
         return True