From caf1a5281f9e974ba73ceded3a782db3d0142c5f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 26 Apr 2019 18:22:55 +0200 Subject: Merging upstream version 1.14.0. Signed-off-by: Daniel Baumann --- .../python.d.plugin/python_modules/bases/charts.py | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'collectors/python.d.plugin/python_modules/bases') diff --git a/collectors/python.d.plugin/python_modules/bases/charts.py b/collectors/python.d.plugin/python_modules/bases/charts.py index 008ebe24e..6e78ed6e7 100644 --- a/collectors/python.d.plugin/python_modules/bases/charts.py +++ b/collectors/python.d.plugin/python_modules/bases/charts.py @@ -19,7 +19,7 @@ CHART_OBSOLETE = "CHART {type}.{id} '{name}' '{title}' '{units}' '{family}' '{co "{chart_type} {priority} {update_every} '{hidden} obsolete'\n" -DIMENSION_CREATE = "DIMENSION '{id}' '{name}' {algorithm} {multiplier} {divisor} '{hidden}'\n" +DIMENSION_CREATE = "DIMENSION '{id}' '{name}' {algorithm} {multiplier} {divisor} '{hidden} {obsolete}'\n" DIMENSION_SET = "SET '{id}' = {value}\n" CHART_VARIABLE_SET = "VARIABLE CHART '{id}' = {value}\n" @@ -200,12 +200,24 @@ class Chart: self.dimensions.append(dim) return dim + def del_dimension(self, dimension_id, hide=True): + if dimension_id not in self: + return + idx = self.dimensions.index(dimension_id) + dimension = self.dimensions[idx] + if hide: + dimension.params['hidden'] = 'hidden' + dimension.params['obsolete'] = 'obsolete' + self.create() + self.dimensions.remove(dimension) + def hide_dimension(self, dimension_id, reverse=False): - if dimension_id in self: - idx = self.dimensions.index(dimension_id) - dimension = self.dimensions[idx] - dimension.params['hidden'] = 'hidden' if not reverse else str() - self.refresh() + if dimension_id not in self: + return + idx = self.dimensions.index(dimension_id) + dimension = self.dimensions[idx] + dimension.params['hidden'] = 'hidden' if not reverse else str() + self.refresh() def create(self): """ @@ -288,6 +300,7 @@ class Dimension: if not isinstance(self.params.get('divisor'), int): self.params['divisor'] = 1 self.params.setdefault('hidden', '') + self.params.setdefault('obsolete', '') def __getattr__(self, item): try: -- cgit v1.2.3