mirror of
https://github.com/netdata/netdata.git
synced 2025-04-18 03:23:51 +00:00

<!-- Describe the change in summary section, including rationale and degin decisions. Include "Fixes #nnn" if you are fixing an existing issue. In "Component Name" section write which component is changed in this PR. This will help us review your PR quicker. If you have more information you want to add, write them in "Additional Information" section. This is usually used to help others understand your motivation behind this change. A step-by-step reproduction of the problem is helpful if there is no related issue. --> ##### Summary Fix: #4756 `python.d.plugin` updates: * remove `retries` option * make `penalty` configurable (enabled by default, max is 10 minutes) > penalty indicates whether to apply penalty to update_every in case of failures. > Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes. > penalty: yes ##### Component Name `python.d.plugin` ##### Additional Information
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Description: example netdata python.d module
|
|
# Author: Put your name here (your github login)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from random import SystemRandom
|
|
|
|
from bases.FrameworkServices.SimpleService import SimpleService
|
|
|
|
# default module values
|
|
# update_every = 4
|
|
priority = 90000
|
|
|
|
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):
|
|
SimpleService.__init__(self, configuration=configuration, name=name)
|
|
self.order = ORDER
|
|
self.definitions = CHARTS
|
|
self.random = SystemRandom()
|
|
|
|
@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
|