Some more error handling and logging.
This commit is contained in:
parent
fc925d1d82
commit
a2fe8e8196
2 changed files with 11 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
; requireed options
|
||||
; required options
|
||||
[monitor]
|
||||
description = Test1
|
||||
service = misc.dummy
|
||||
|
|
@ -6,7 +6,7 @@ hosts = 192.168.10.10
|
|||
|
||||
; optional options
|
||||
[args]
|
||||
interval = 60
|
||||
interval = 13
|
||||
; 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
|
||||
start_date = 2022-01-01 00:00:00
|
||||
|
|
|
|||
|
|
@ -12,8 +12,13 @@ from apscheduler.jobstores.memory import MemoryJobStore
|
|||
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
|
||||
|
||||
|
||||
def job_function(monitor):
|
||||
monitor.handle_call()
|
||||
def job_function(monitor, log):
|
||||
try:
|
||||
log('debug', 'executing job_function for monitor: ' + monitor.get_identifier())
|
||||
monitor.handle_call()
|
||||
except Exception as err:
|
||||
log('warning', 'execution failed for job_function for monitor: ' +
|
||||
monitor.get_identifier() + ' error: ' + str(err))
|
||||
|
||||
|
||||
class Linspector:
|
||||
|
|
@ -99,7 +104,7 @@ class Linspector:
|
|||
scheduler_job = scheduler['linspector'].add_job(job_function, 'interval',
|
||||
start_date=new_start_date,
|
||||
seconds=interval, timezone=timezone,
|
||||
args=[monitors.get(monitor)])
|
||||
args=[monitors.get(monitor), log])
|
||||
|
||||
monitor_job.set_job(scheduler_job)
|
||||
self.__jobs.append(monitor_job)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue