Implemented notification_error_mode configuration option. (0.30.1)

This commit is contained in:
Johannes Findeisen 2023-09-07 01:26:08 +02:00
commit 3660cbb50c
4 changed files with 29 additions and 2 deletions

View file

@ -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')

View file

@ -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

View file

@ -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

View file

@ -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)