configurable "chart_cleanup" option added (default is 10)
lgz committed
Nov 3, 2017 at 11:50 UTC
ae2a314f3c7bc8f9e8ee12a233d6de27cf81c3e7
3 files changed
+9
-8
python.d/python_modules/bases/FrameworkServices/SimpleService.py
+2
-3
@@ -14,8 +14,6 @@ from bases.charts import Charts, ChartError, create_runtime_chart
14
from bases.collection import OldVersionCompatibility, safe_print
15
from bases.loggers import PythonDLimitedLogger
16
17
-CHART_OBSOLETE_PENALTY = 10
18
-
17
RUNTIME_CHART_UPDATE = 'BEGIN netdata.runtime_{job_name} {since_last}\n' \
18
'SET run_time = {elapsed}\n' \
19
'END\n'
@@ -66,6 +64,7 @@ class SimpleService(Thread, PythonDLimitedLogger, OldVersionCompatibility, objec
64
self._runtime_counters = RuntimeCounters(configuration=configuration)
65
self.charts = Charts(job_name=self.actual_name,
66
priority=configuration.pop('priority'),
67
+ cleanup=configuration.pop('chart_cleanup'),
68
get_update_every=self.get_update_every)
69
70
def __repr__(self):
@@ -211,7 +210,7 @@ class SimpleService(Thread, PythonDLimitedLogger, OldVersionCompatibility, objec
210
211
if chart.flags.obsolete:
212
continue
214
- elif chart.penalty > CHART_OBSOLETE_PENALTY:
213
+ elif chart.cleanup and chart.penalty > chart.cleanup:
214
chart.push_obsolete()
215
self.error("chart '{0}' was removed due to non updating".format(chart.name))
216
continue
python.d/python_modules/bases/charts.py
+5
-1
@@ -71,7 +71,7 @@ class Charts:
71
All charts stored in a dict.
72
Chart is a instance of Chart class.
73
Charts adding must be done using Charts.add_chart() method only"""
74
- def __init__(self, job_name, priority, get_update_every):
74
+ def __init__(self, job_name, priority, cleanup, get_update_every):
75
"""
76
:param job_name: <bound method>
77
:param priority: <int>
@@ -79,6 +79,7 @@ class Charts:
79
"""
80
self.job_name = job_name
81
self.priority = priority
82
+ self.cleanup = cleanup
83
self.get_update_every = get_update_every
84
self.charts = dict()
85
@@ -119,8 +120,11 @@ class Charts:
120
"""
121
params = [self.job_name()] + params
122
new_chart = Chart(params)
123
+
124
new_chart.params['update_every'] = self.get_update_every()
125
new_chart.params['priority'] = self.priority
126
+ new_chart.params['cleanup'] = self.cleanup
127
+
128
self.priority += 1
129
self.charts[new_chart.id] = new_chart
130
python.d/varnish.chart.py
+2
-4
@@ -105,6 +105,8 @@ class Service(SimpleService):
105
def __init__(self, configuration=None, name=None):
106
SimpleService.__init__(self, configuration=configuration, name=name)
107
self.varnish = find_binary('varnishstat')
108
+ self.order = ORDER[:]
109
+ self.definitions = dict(CHARTS)
110
self.regex_all = re.compile(r'([A-Z]+\.)?([\d\w_.]+)\s+(\d+)')
111
self.regex_backend = None
112
self.cache_prev = list()
@@ -218,10 +220,6 @@ class Service(SimpleService):
220
return to_netdata
221
222
def create_charts(self):
221
- self.order = ORDER[:]
222
- self.definitions = CHARTS
223
-
224
- # Create dynamic backend charts
223
if self.backend_list:
224
for backend in self.backend_list:
225
self.order.insert(0, ''.join([backend[0], '_resp_stats']))