Made the monitor interval optional and set 300 seconds to default.
This commit is contained in:
parent
7e228a3196
commit
fc925d1d82
14 changed files with 24 additions and 19 deletions
|
|
@ -35,9 +35,9 @@ from linspector.core.monitors import Monitors
|
|||
|
||||
logger = logging.getLogger('linspector')
|
||||
|
||||
# i currently only increase the 3rd number because the goal is that 0.19 will become the first
|
||||
# i currently only increase the 3rd number because the goal is that 0.20.* will become the first
|
||||
# stable version.
|
||||
__version__ = '0.19.31.dev1'
|
||||
__version__ = '0.19.32.dev1'
|
||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
description = Cable Provider
|
||||
service = net.fritzboxuplink
|
||||
hosts = 192.168.0.1,192.168.23.24,@group1,@testgroup1
|
||||
; this only depends on the SLA you made with the product owner.
|
||||
interval = 60
|
||||
|
||||
; optional options when using notifications, plugins, services or tasks. btw. they still can be a required argument by
|
||||
; a corresponding notification, plugin, service or task. they will need to check required args by themself and throw an
|
||||
; exception if something fails. linspector never knows about required args:
|
||||
[args]
|
||||
; this only depends on the SLA you made with the product owner. this option is optional. the default is 300 seconds.
|
||||
interval = 60
|
||||
; notifications separated by ','. no whitespaces allowed. the case is not important.
|
||||
notifications = sms,emaiL
|
||||
; values from main configuration can be overridden for each defined monitor
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
[monitor]
|
||||
description = Cable Provider
|
||||
service = Net.FritzboxUplink
|
||||
interval = 60
|
||||
hosts = 192.168.1.1
|
||||
|
||||
[args]
|
||||
interval = 60
|
||||
notifications = email
|
||||
email_receivers = admin@example.com,fallback@example.com
|
||||
sms_receivers = +number1,+number2
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
description = Test1
|
||||
service = misc.dummy
|
||||
hosts = 192.168.10.10
|
||||
interval = 60
|
||||
|
||||
; optional options
|
||||
[args]
|
||||
interval = 60
|
||||
; the start is to schedule the execution of the monitor in at a date in the future. this is helpful to configure
|
||||
; linspector before a host is up and running.
|
||||
start_date = 2025-01-01 00:00:00
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
description = Test10
|
||||
service = misc.dummy
|
||||
interval = 120
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 120
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
[monitor]
|
||||
description = Test2
|
||||
service = misc.dummy
|
||||
interval = 10
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 10
|
||||
test_dummy_arg = nothing
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
[monitor]
|
||||
description = Test3
|
||||
service = misc.dummy
|
||||
interval = 5
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 5
|
||||
foo = bar
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
description = Test4
|
||||
service = misc.dummy
|
||||
interval = 50
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 50
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
description = Test5
|
||||
service = net.FritzboxUplink
|
||||
interval = 62
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 62
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
description = Test6
|
||||
service = misc.dummy
|
||||
interval = 30
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 30
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
description = Test7
|
||||
service = misc.dummy
|
||||
interval = 20
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 20
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
description = Test8
|
||||
service = misc.dummy
|
||||
interval = 15
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 15
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
description = Test9
|
||||
service = misc.dummy
|
||||
interval = 240
|
||||
hosts = 192.168.10.10
|
||||
|
||||
[args]
|
||||
interval = 240
|
||||
|
|
|
|||
|
|
@ -14,14 +14,19 @@ from linspector.core.task import Task, TaskExecutor
|
|||
|
||||
|
||||
class Monitor:
|
||||
|
||||
def __init__(self, configuration, environment, identifier, log, monitor_configuration,
|
||||
notifications, services, tasks, kwargs):
|
||||
self.__args = kwargs
|
||||
self.__configuration = configuration
|
||||
self.__environment = environment
|
||||
self.__identifier = identifier
|
||||
self.__interval = int(monitor_configuration.get('monitor', 'interval'))
|
||||
if int(monitor_configuration.get('args', 'interval')):
|
||||
self.__interval = int(monitor_configuration.get('args', 'interval'))
|
||||
else:
|
||||
# default interval is 5 minutes if not set in the monitor.
|
||||
log('warning', 'no interval set in identifier ' + identifier + ' set to default '
|
||||
'interval 300 seconds.')
|
||||
self.__interval = 300
|
||||
self.__log = log
|
||||
self.__monitor_configuration = monitor_configuration
|
||||
self.__notification_list = []
|
||||
|
|
@ -47,9 +52,9 @@ class Monitor:
|
|||
"""
|
||||
NONE job was not executed
|
||||
OK when everything is fine
|
||||
WARNING when a job has errors but not the threshold overridden
|
||||
WARNING when a job has errors but the threshold is not overridden
|
||||
RECOVER when a job recovers e.g. the threshold decrements (not implemented)
|
||||
ERROR when a jobs threshold is overridden
|
||||
ERROR when a jobs error threshold is overridden
|
||||
UNKNOWN when a job throws an exception which is not handled by the job itself (not
|
||||
implemented)
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue