summaryrefslogtreecommitdiffstats
path: root/python.d/example.chart.py
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:21 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:21 +0000
commit61aedf201c2c4bf0e5aa4db32e74f4d860b88593 (patch)
treebcf4f9a0cd8bc2daf38b2ff9f29bfcc1e5ed8968 /python.d/example.chart.py
parentNew upstream version 1.8.0+dfsg (diff)
downloadnetdata-61aedf201c2c4bf0e5aa4db32e74f4d860b88593.tar.xz
netdata-61aedf201c2c4bf0e5aa4db32e74f4d860b88593.zip
New upstream version 1.9.0+dfsgupstream/1.9.0+dfsg
Diffstat (limited to 'python.d/example.chart.py')
-rw-r--r--python.d/example.chart.py51
1 files changed, 31 insertions, 20 deletions
diff --git a/python.d/example.chart.py b/python.d/example.chart.py
index adf97a921..ee7ff62fc 100644
--- a/python.d/example.chart.py
+++ b/python.d/example.chart.py
@@ -2,35 +2,46 @@
# Description: example netdata python.d module
# Author: Pawel Krupa (paulfantom)
-import os
-import random
-from base import SimpleService
+from random import SystemRandom
-NAME = os.path.basename(__file__).replace(".chart.py", "")
+from bases.FrameworkServices.SimpleService import SimpleService
# default module values
# update_every = 4
priority = 90000
retries = 60
+ORDER = ['random']
+CHARTS = {
+ 'random': {
+ 'options': [None, 'A random number', 'random number', 'random', 'random', 'line'],
+ 'lines': [
+ ['random1']
+ ]
+ }
+}
+
class Service(SimpleService):
def __init__(self, configuration=None, name=None):
- super(self.__class__,self).__init__(configuration=configuration, name=name)
+ SimpleService.__init__(self, configuration=configuration, name=name)
+ self.order = ORDER
+ self.definitions = CHARTS
+ self.random = SystemRandom()
- def check(self):
- return True
-
- def create(self):
- 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):
- self.begin("example.python_random", interval)
- self.set("random1", random.randint(0, 100))
- self.end()
- self.commit()
+ @staticmethod
+ def check():
return True
+
+ def get_data(self):
+ data = dict()
+
+ for i in range(1, 4):
+ dimension_id = ''.join(['random', str(i)])
+
+ if dimension_id not in self.charts['random']:
+ self.charts['random'].add_dimension([dimension_id])
+
+ data[dimension_id] = self.random.randint(0, 100)
+
+ return data