Some small improvements and refactoring.
This commit is contained in:
parent
a4053a0db3
commit
7360ab1936
5 changed files with 11 additions and 36 deletions
|
|
@ -16,7 +16,7 @@ from linspector.core.linspector import Linspector
|
|||
from linspector.core.logger import Log
|
||||
from linspector.core.monitors import Monitors
|
||||
|
||||
__version__ = '0.20.1'
|
||||
__version__ = '0.20.2'
|
||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
title = Uplink Status
|
||||
description = Cable Provider Uplink Status
|
||||
service = net.fritzboxuplink
|
||||
service = vendor.avm.is_connected
|
||||
; this is obsolete because the host will become part of the args but removing it now will break the code. linspector
|
||||
; should be for checking local or remote stuff so a host is optional.
|
||||
hosts = 192.168.1.1
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[monitor]
|
||||
title = Uplink Status
|
||||
description = DSL Provider Uplink Status
|
||||
service = net.fritzboxuplink
|
||||
service = vendor.avm.is_connected
|
||||
hosts = 192.168.2.1
|
||||
|
||||
[args]
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
"""
|
||||
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 linspector.core.service import Service
|
||||
|
||||
|
||||
def create(configuration, environment, log):
|
||||
return FritzboxPhoneStatusService(configuration, environment, log)
|
||||
|
||||
|
||||
class FritzboxPhoneStatusService(Service):
|
||||
def __init__(self, configuration, environment, log):
|
||||
super().__init__(configuration, environment, log)
|
||||
self.__configuration = configuration
|
||||
self.__environment = environment
|
||||
self.__log = log
|
||||
|
||||
def execute(self, **kwargs):
|
||||
self.__log.debug('FritzboxPhoneStatusService object ' + str(self))
|
||||
return
|
||||
|
|
@ -9,10 +9,10 @@ from linspector.core.service import Service
|
|||
|
||||
|
||||
def create(configuration, environment, log):
|
||||
return FritzboxUplinkService(configuration, environment, log)
|
||||
return IsConnectedService(configuration, environment, log)
|
||||
|
||||
|
||||
class FritzboxUplinkService(Service):
|
||||
class IsConnectedService(Service):
|
||||
def __init__(self, configuration, environment, log):
|
||||
super().__init__(configuration, environment, log)
|
||||
self.__configuration = configuration
|
||||
|
|
@ -20,7 +20,6 @@ class FritzboxUplinkService(Service):
|
|||
self.__log = log
|
||||
|
||||
def execute(self, identifier, service, **kwargs):
|
||||
status = "NONE"
|
||||
self.__log.debug('identifier=' + identifier +
|
||||
'service=' + service +
|
||||
' object=' + str(self) +
|
||||
|
|
@ -28,11 +27,6 @@ class FritzboxUplinkService(Service):
|
|||
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']) +
|
||||
|
|
@ -43,5 +37,9 @@ class FritzboxUplinkService(Service):
|
|||
self.__log.info('identifier=' + identifier +
|
||||
' host=' + str(kwargs['host']) +
|
||||
' service=' + service +
|
||||
' status=' + status)
|
||||
return True
|
||||
' status=' + ('OK' if fc.is_connected else 'ERROR'))
|
||||
|
||||
if fc.is_connected:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
Loading…
Add table
Add a link
Reference in a new issue