X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=python.d%2Fexample.chart.py;h=adf97a921eb93d129a2e1be5cd833d40c1679207;hb=c0d4db4c8e05f58c150f3f76c6b8e09a2c7f72d5;hp=6a0dfec9f3750a5b9c0de0043dac4256d8dcd01a;hpb=bd546d32209e4cc5ccc8d91a3e70a8808ffe73e0;p=netdata.git diff --git a/python.d/example.chart.py b/python.d/example.chart.py index 6a0dfec9..adf97a92 100644 --- a/python.d/example.chart.py +++ b/python.d/example.chart.py @@ -1,15 +1,36 @@ +# -*- coding: utf-8 -*- +# Description: example netdata python.d module +# Author: Pawel Krupa (paulfantom) + +import os import random +from base import SimpleService + +NAME = os.path.basename(__file__).replace(".chart.py", "") + +# default module values +# update_every = 4 +priority = 90000 +retries = 60 -def check(): - return True -def create(): - print("CHART python_example.random '' 'A random number' 'random number' random random line 90000 1") - print("DIMENSION random1 '' absolute 1 1") - return True +class Service(SimpleService): + def __init__(self, configuration=None, name=None): + super(self.__class__,self).__init__(configuration=configuration, name=name) -def update(interval): - print("BEGIN python_example.random "+str(interval)) - print("SET random1 = "+str(random.randint(0,100))) - print("END") - return True + 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() + return True