]> arthur.barton.de Git - netdata.git/blob - python.d/example.chart.py
multithreading
[netdata.git] / python.d / example.chart.py
1 # -*- coding: utf-8 -*-
2 # Description: example netdata python.d plugin
3 # Author: Pawel Krupa (paulfantom)
4
5 import os
6 import random
7 from base import BaseService
8
9 NAME = os.path.basename(__file__).replace(".chart.py", "")
10
11 # default module values
12 update_every = 4
13 priority = 90000
14 retries = 7
15
16
17 class Service(BaseService):
18     def __init__(self, configuration=None, name=None):
19         super(self.__class__,self).__init__(configuration=configuration, name=name)
20
21     def check(self):
22         return True
23     
24     def create(self):
25         chart = "CHART example.python_random '' 'A random number' 'random number' random random line " + \
26                 str(self.priority) + " " + \
27                 str(self.update_every) + "\n" + \
28                 "DIMENSION random1 '' absolute 1 1"
29         print(chart)
30         return True
31     
32     def update(self, interval):
33         chart = "BEGIN example.python_random "+str(interval)+"\n"
34         chart += "SET random1 = "+str(random.randint(0,100))+"\n"
35         print(chart + "END")
36         return True