From 3660cbb50c74dc0ee1a5e48e1d2038b8cb2c85bf Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Thu, 7 Sep 2023 01:26:08 +0200 Subject: [PATCH] Implemented notification_error_mode configuration option. (0.30.1) --- bin/linspector | 2 +- etc/linspector.conf | 2 +- files/bugs/0002_sqlerror.txt | 9 +++++++++ linspector/monitor.py | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 files/bugs/0002_sqlerror.txt diff --git a/bin/linspector b/bin/linspector index d90add1..61aa6b8 100755 --- a/bin/linspector +++ b/bin/linspector @@ -23,7 +23,7 @@ from linspector.monitors import Monitors __author__ = 'Johannes Findeisen' __author_email__ = 'you@hanez.org' __description__ = 'linspector is a infrastructure and system monitoring daemon and toolchain.' -__version__ = '0.30.0' +__version__ = '0.30.1' sys.stderr = open('/dev/null', 'w') diff --git a/etc/linspector.conf b/etc/linspector.conf index aa2fc2a..7fac7c9 100644 --- a/etc/linspector.conf +++ b/etc/linspector.conf @@ -7,7 +7,7 @@ minimum_interval = 10 delta_range = 60 ; number of errors until executing notifications notification_error_threshold = 5 -; "decrease" error countor or "reset" to 0 when a service is healthy again +; "decrease" error countor or "reset" to 0 when a service is healthy again (default: decrease) notification_error_mode = decrease start_scheduler = true diff --git a/files/bugs/0002_sqlerror.txt b/files/bugs/0002_sqlerror.txt new file mode 100644 index 0000000..faf2b42 --- /dev/null +++ b/files/bugs/0002_sqlerror.txt @@ -0,0 +1,9 @@ +[2023-09-07 00:53:57.794240 +0200] [0:07:07.535255] [ERROR] [linspector]: identifier=network2.gateway_dsl host=192.168.178.1 service=vendor.avm.is_connected status=ERROR +[2023-09-07 00:53:57.794646 +0200] [0:07:07.535661] [ERROR] [linspector]: + + FRITZ!Box: access for applications disabled. + Check: Home Network -> Network -> Network Settings + for "Allow access for applications". + +[2023-09-07 00:53:57.800175 +0200] [0:07:07.541190] [ERROR] [linspector]: task mysql query failed: (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'Allow access for applications".\\n\', \'host\': \'192.168.178.1\', \'log\': \'identifi...\' at line 1') +[2023-09-07 00:53:57.800478 +0200] [0:07:07.541493] [INFO] [linspector]: identifier=network2.gateway_dsl host=192.168.178.1 service=vendor.avm.is_connected status=ERROR diff --git a/linspector/monitor.py b/linspector/monitor.py index 615829e..92db5e2 100644 --- a/linspector/monitor.py +++ b/linspector/monitor.py @@ -122,8 +122,26 @@ class Monitor: self._result = self._services[self._service].execute(self._identifier, self, self._service, **self._args) + notification_error_mode = 'decrease' if self._result['status'] == 'ERROR': self._error_count += 1 + elif self._result['status'] == 'OK': + if self._configuration.get_option('linspector', 'notification_error_mode'): + configuration_notification_error_mode = ( + self._configuration.get_option('linspector', 'notification_error_mode')) + if (configuration_notification_error_mode == 'decrease' or + configuration_notification_error_mode == 'reset'): + notification_error_mode = ( + self._configuration.get_option('linspector', + 'notification_error_mode')) + + if notification_error_mode == 'decrease': + if self._error_count > 0: + self._error_count -= 1 + elif notification_error_mode == 'reset': + self._error_count = 0 + + self._log.debug('notification error mode: ' + notification_error_mode) self._log.debug('error count: ' + str(self._error_count)) self._log.debug(self._result)