@cryptotaxi247 / netdata-1 / commits / 8e7a2ceb6

example module update

lgz committed Nov 3, 2017 at 10:29 UTC 8e7a2ceb654f081d0d74f5ad11e8480dc1c2372a
1 file changed +10 -8
python.d/example.chart.py
+10 -8
@@ -2,7 +2,7 @@
2 # Description: example netdata python.d module
3 # Author: Pawel Krupa (paulfantom)
4
5 -import random
5 +from random import SystemRandom
6
7 from bases.FrameworkServices.SimpleService import SimpleService
8
@@ -24,22 +24,24 @@ CHARTS = {
24
25 class Service(SimpleService):
26 def __init__(self, configuration=None, name=None):
27 - super(self.__class__, self).__init__(configuration=configuration, name=name)
27 + SimpleService.__init__(self, configuration=configuration, name=name)
28 self.order = ORDER
29 self.definitions = CHARTS
30 - self.data = dict()
30 + self.random = SystemRandom()
31
32 @staticmethod
33 def check():
34 return True
35
36 def get_data(self):
37 - dimension = ''.join(['random', str(random.randint(1, 3))])
37 + data = dict()
38
39 - if dimension not in self.charts['random']:
40 - self.charts['random'].add_dimension([dimension])
39 + for i in range(1, 4):
40 + dimension_id = ''.join(['random', str(i)])
41
42 - self.data[dimension] = random.randint(0, 100)
42 + if dimension_id not in self.charts['random']:
43 + self.charts['random'].add_dimension([dimension_id])
44
44 - return self.data
45 + data[dimension_id] = self.random.randint(0, 100)
46
47 + return data