First commit with working service execution and a defined log output (0.20).
This commit is contained in:
parent
be78e5e031
commit
c8fa991478
14 changed files with 63 additions and 177 deletions
|
|
@ -36,7 +36,7 @@ class Linspector:
|
|||
self.__scheduler = scheduler
|
||||
|
||||
# load plugins
|
||||
log.info('loading plugins...')
|
||||
log.info('message=loading plugins')
|
||||
if configuration.get_option('linspector', 'plugins'):
|
||||
plugin_list = configuration.get_option('linspector', 'plugins')
|
||||
self.__plugin_list = plugin_list.split(',')
|
||||
|
|
@ -114,8 +114,12 @@ class Linspector:
|
|||
|
||||
monitor_job.set_job(scheduler_job)
|
||||
self.__jobs.append(monitor_job)
|
||||
log.info('scheduling job ' + monitor + ' with delta ' + str(time_delta) +
|
||||
' @' + str(new_start_date) + ' running service ' + monitor_job.get_service())
|
||||
log.info('identifier=' + monitor +
|
||||
' host=' + "NOT IMPLEMENTED" +
|
||||
' service=' + monitor_job.get_service() +
|
||||
' delta=' + str(time_delta) +
|
||||
' next=' + str(new_start_date) +
|
||||
' message=scheduling job')
|
||||
|
||||
if configuration.get_option('linspector', 'start_scheduler') == 'true':
|
||||
self.__scheduler['linspector'].start()
|
||||
|
|
|
|||
|
|
@ -219,13 +219,16 @@ class Monitor:
|
|||
def handle_tasks(self, monitor_information):
|
||||
for task in self.__tasks:
|
||||
if self.status.lower() in task.get_task_type().lower():
|
||||
self.__log.debug('executing task of type: ' + self.status)
|
||||
self.__log.debug('message=executing task type=' + self.status)
|
||||
# tasks can but should not be executed here. putting them in a queue is the better
|
||||
# solution to execute them in a serial process.
|
||||
# TaskExecutor.instance().schedule_task(monitor_information, task)
|
||||
|
||||
def handle_call(self):
|
||||
self.__log.info('handle call to monitor with identifier: ' + self.__identifier)
|
||||
self.__log.debug('identifier=' + self.__identifier +
|
||||
' object=' + str(self))
|
||||
self.__log.debug('identifier=' + self.__identifier +
|
||||
' message=handle call to service')
|
||||
# logger.debug("handle call")
|
||||
# logger.debug(self.service)
|
||||
if self.enabled:
|
||||
|
|
@ -233,7 +236,7 @@ class Monitor:
|
|||
try:
|
||||
self.last_execution = MonitorExecution(self.get_host())
|
||||
# self.__services[self.__service].execute(self.last_execution)
|
||||
self.__services[self.__service].execute(**self.__args)
|
||||
self.__services[self.__service].execute(self.__identifier, self.__service, **self.__args)
|
||||
except Exception as err:
|
||||
self.__log.error(err)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ This file is part of Linspector (https://linspector.org/)
|
|||
Copyright (c) 2022 Johannes Findeisen <you@hanez.org>. All Rights Reserved.
|
||||
See LICENSE.txt (MIT license).
|
||||
"""
|
||||
from fritzconnection.lib.fritzstatus import FritzStatus
|
||||
|
||||
from linspector.core.service import Service
|
||||
|
||||
|
|
@ -18,7 +19,29 @@ class FritzboxUplinkService(Service):
|
|||
self.__environment = environment
|
||||
self.__log = log
|
||||
|
||||
def execute(self, **kwargs):
|
||||
self.__log.debug('FritzboxUplinkService object ' + str(self) + ' using kwargs: ' +
|
||||
str(kwargs))
|
||||
return
|
||||
def execute(self, identifier, service, **kwargs):
|
||||
status = "NONE"
|
||||
self.__log.debug('identifier=' + identifier +
|
||||
'service=' + service +
|
||||
' object=' + str(self) +
|
||||
' kwargs=' + str(kwargs))
|
||||
try:
|
||||
fc = FritzStatus(address=kwargs['host'],
|
||||
password=kwargs['password'])
|
||||
|
||||
if fc.is_connected:
|
||||
status = "OK"
|
||||
else:
|
||||
status = "ERROR"
|
||||
except Exception:
|
||||
self.__log.error('identifier=' + identifier +
|
||||
' host=' + str(kwargs['host']) +
|
||||
' service=' + service +
|
||||
' failed ')
|
||||
return False
|
||||
|
||||
self.__log.info('identifier=' + identifier +
|
||||
' host=' + str(kwargs['host']) +
|
||||
' service=' + service +
|
||||
' status=' + status)
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue