diff options
author | Andrew Maguire <andrewm4894@gmail.com> | 2022-09-22 14:50:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-22 14:50:55 +0100 |
commit | 4453613cba6d939f74e982c1d0e8d85cef8bd6be (patch) | |
tree | f133699421e276f97e1dcbb06389aba070336b1b /collectors/python.d.plugin/alarms/alarms.chart.py | |
parent | eddb7125faa609d87248036e8b8533b8bdd00621 (diff) |
alarms collector: ability to exclude certain alarms via config (#13701)
alarms collector: ability to exclude certain alarms via config
Diffstat (limited to 'collectors/python.d.plugin/alarms/alarms.chart.py')
-rw-r--r-- | collectors/python.d.plugin/alarms/alarms.chart.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/collectors/python.d.plugin/alarms/alarms.chart.py b/collectors/python.d.plugin/alarms/alarms.chart.py index 314b0e7a83..d194273581 100644 --- a/collectors/python.d.plugin/alarms/alarms.chart.py +++ b/collectors/python.d.plugin/alarms/alarms.chart.py @@ -39,6 +39,7 @@ DEFAULT_URL = 'http://127.0.0.1:19999/api/v1/alarms?all' DEFAULT_COLLECT_ALARM_VALUES = False DEFAULT_ALARM_STATUS_CHART_TYPE = 'line' DEFAULT_ALARM_CONTAINS_WORDS = '' +DEFAULT_ALARM_EXCLUDES_WORDS = '' class Service(UrlService): def __init__(self, configuration=None, name=None): @@ -51,6 +52,8 @@ class Service(UrlService): self.collected_dims = {'alarms': set(), 'values': set()} self.alarm_contains_words = self.configuration.get('alarm_contains_words', DEFAULT_ALARM_CONTAINS_WORDS) self.alarm_contains_words_list = [alarm_contains_word.lstrip(' ').rstrip(' ') for alarm_contains_word in self.alarm_contains_words.split(',')] + self.alarm_excludes_words = self.configuration.get('alarm_excludes_words', DEFAULT_ALARM_EXCLUDES_WORDS) + self.alarm_excludes_words_list = [alarm_excludes_word.lstrip(' ').rstrip(' ') for alarm_excludes_word in self.alarm_excludes_words.split(',')] def _get_data(self): raw_data = self._get_raw_data() @@ -62,6 +65,9 @@ class Service(UrlService): if self.alarm_contains_words != '': alarms = {alarm_name: alarms[alarm_name] for alarm_name in alarms for alarm_contains_word in self.alarm_contains_words_list if alarm_contains_word in alarm_name} + if self.alarm_excludes_words != '': + alarms = {alarm_name: alarms[alarm_name] for alarm_name in alarms for alarm_excludes_word in + self.alarm_excludes_words_list if alarm_excludes_word not in alarm_name} data = {a: self.sm[alarms[a]['status']] for a in alarms if alarms[a]['status'] in self.sm} self.update_charts('alarms', data) |