diff --git a/bin/linspector b/bin/linspector index 0b3c857..2fe7735 100755 --- a/bin/linspector +++ b/bin/linspector @@ -2,7 +2,7 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,10 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +# TODO: implement error handling at all needed places! currently nearly no error handling is done! +# TODO: make use of the logger wherever it us useful! and be verbose when information really helps +# debugging the application! + import argparse import sys @@ -58,22 +62,26 @@ def main(): args = parse_args() environment = Environment() + monitors = None notifications = {} services = {} try: configuration = Configuration(args.configuration_path, environment) - # configuration.dump_to_ini() + #configuration.dump_to_ini() except Exception as err: - logger.error(str('[uplink] configuration error: {0}'.format(err))) + logger.error(str('[linspector] configuration error: {0}'.format(err))) sys.exit(1) - monitors = Monitors(configuration, environment, notifications, services) + try: + monitors = Monitors(configuration, environment, notifications, services) + except Exception as err: + logger.warning('[linspector] monitor initialization error: {0}'.format(err)) linspector = Linspector(configuration, environment, monitors) - #linspector.print_monitors_monitor_identifiers() + #linspector.print_debug() - # so, if Linspector should start in Daemon mode, do thi here... + # so, if Linspector should start in Daemon mode, do it here... #Linspectord(configuration, environment, linspector).execute() diff --git a/etc.example/linspector.ini b/etc.example/linspector.ini deleted file mode 100644 index 54eb817..0000000 --- a/etc.example/linspector.ini +++ /dev/null @@ -1,43 +0,0 @@ -; all you need to know: https://docs.python.org/3/library/configparser.html ... ;) -[linspector] -; report core errors to the following users -error_receivers = admin@example.com -log_file = ~/code/linspector/log/linspector.log -log_level= verbose -log_count = 5 -log_size = 10485760 -pid_file = /var/run/user/1000/linspector.pid -; default delimiters '=' and ':' should be changed to ',' to be more native -plugins = HTTPServer -tasks = MariaDB:Logger -; maybe the run_mode is obsolete because this will be a daemon but maybe it is useful for one time execution? -; in uplink the available run_modes were cron, daemon and foreground -run_mode = cron - -; every notification can be configured in it's own ini file in etc/notifications; there no notification name as prefix -; is needed. see email example. -[notifications] -; values can be overridden in each defined monitor -sms_receivers = +number1:+number2 -sms_configuration_file = ~/linspector/etc/gammurc -; retry to send interval and number of retries if something failed -sms_resend = 10 -sms_resend_count = 5 -email_resend = 10 - -; every plugin can be configured in it's own ini file in etc/plugins; there no plugin name as prefix is needed. see -; httpserver example. -[plugins] - -; if types can or must be configured before use; for now no use case seen. -; every type can be configured in it's own ini file in etc/types; there no type name as prefix is not needed. -[services] -speedtest_interval = 3600 -speedtest_url = https://go.microsoft.com/fwlink/?Linkid=850641 - -[tasks] -mariadb_database = linspector -mariadb_host = 10.0.0.254 -mariadb_password = PASSWORD -mariadb_port": 3306 -mariadb_user = USER \ No newline at end of file diff --git a/etc.example/monitors/.gitkeep b/etc.example/monitors/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/etc.example/monitors/network1/.gitkeep b/etc.example/monitors/network1/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/etc.example/monitors/network1/gateway.ini b/etc.example/monitors/network1/gateway.ini deleted file mode 100644 index d375bfb..0000000 --- a/etc.example/monitors/network1/gateway.ini +++ /dev/null @@ -1,17 +0,0 @@ -[main] -; identifiers must be unique in the whole configuration so maybe it is better to create a random string for this -; dynamically. identifiers should maybe a checksum of some options so they will not change when small changes to -; the configurations changes and will remain even when doing a fresh install. -identifier = cable -service = Fritzbox -interval = 60 -# default delimiters '=' and ':' should be changed to ',' to be more native -notifications = SMS:Email -; values from main configuration can be overridden for each defined monitor -email_receivers = admin@example.com:fallback@example.com -sms_receivers = +329084320984:+39804932409 -tasks = None -host = 192.168.0.1 -user = USERNAME -password = PASSWORD -info = Cable Provider \ No newline at end of file diff --git a/etc.example/monitors/network2/.gitkeep b/etc.example/monitors/network2/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/etc.example/monitors/network2/gateway.ini b/etc.example/monitors/network2/gateway.ini deleted file mode 100644 index b3d2aa6..0000000 --- a/etc.example/monitors/network2/gateway.ini +++ /dev/null @@ -1,13 +0,0 @@ -[main] -identifier = dsl -service = Fritzbox -interval = 60 -# default delimiters '=' and ':' should be changed to ',' to be more native -notifications = SMS:Email -email_receivers = admin@example.com:fallback@example.com -sms_receivers = +329084320984:+39804932409 -tasks = MariaDB:Logger:Redis -host = 192.168.1.1 -user = USERNAME -password = PASSWORD -info = Cable Provider \ No newline at end of file diff --git a/etc.example/notifications/.gitkeep b/etc.example/notifications/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/etc.example/notifications/email.ini b/etc.example/notifications/email.ini deleted file mode 100644 index 9d0bf9e..0000000 --- a/etc.example/notifications/email.ini +++ /dev/null @@ -1,7 +0,0 @@ -[email] -resend = 20 -smtp_host = mail.example.com -smtp_port = 25 -smtp_password = PASSWORD -smtp_user = alerts@example.com -receivers = admin@example.com \ No newline at end of file diff --git a/etc.example/plugins/.gitkeep b/etc.example/plugins/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/etc.example/plugins/httpserver.ini b/etc.example/plugins/httpserver.ini deleted file mode 100644 index b832680..0000000 --- a/etc.example/plugins/httpserver.ini +++ /dev/null @@ -1,3 +0,0 @@ -[httpserver] -ip = 127.0.0.1 -port = 4242 \ No newline at end of file diff --git a/etc.example/services/.gitkeep b/etc.example/services/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/etc.example/tasks/.gitkeep b/etc.example/tasks/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/etc/linspector.ini b/etc/linspector.ini index 54eb817..e3ae2a8 100644 --- a/etc/linspector.ini +++ b/etc/linspector.ini @@ -9,7 +9,7 @@ log_size = 10485760 pid_file = /var/run/user/1000/linspector.pid ; default delimiters '=' and ':' should be changed to ',' to be more native plugins = HTTPServer -tasks = MariaDB:Logger +tasks = MariaDB,Logger ; maybe the run_mode is obsolete because this will be a daemon but maybe it is useful for one time execution? ; in uplink the available run_modes were cron, daemon and foreground run_mode = cron diff --git a/etc/monitors/network1/gateway.ini b/etc/monitors/network1/gateway.ini index b7f786a..7e04ad7 100644 --- a/etc/monitors/network1/gateway.ini +++ b/etc/monitors/network1/gateway.ini @@ -1,8 +1,7 @@ -[main] -service = Fritzbox +[monitor] +service = FritzboxUplink interval = 60 -# default delimiters '=' and ':' should be changed to ',' to be more native -notifications = SMS:Email +notifications = SMS,Email ; values from main configuration can be overridden for each defined monitor email_receivers = admin@example.com:fallback@example.com sms_receivers = +329084320984:+39804932409 diff --git a/etc/monitors/network2/gateway.ini b/etc/monitors/network2/gateway.ini index b3d2aa6..0cfc0f3 100644 --- a/etc/monitors/network2/gateway.ini +++ b/etc/monitors/network2/gateway.ini @@ -1,9 +1,9 @@ -[main] +[monitor] identifier = dsl -service = Fritzbox +service = FritzboxUplink interval = 60 # default delimiters '=' and ':' should be changed to ',' to be more native -notifications = SMS:Email +notifications = SMS,Email email_receivers = admin@example.com:fallback@example.com sms_receivers = +329084320984:+39804932409 tasks = MariaDB:Logger:Redis diff --git a/linspector/core/configuration.py b/linspector/core/configuration.py index 606deb0..ec007d9 100644 --- a/linspector/core/configuration.py +++ b/linspector/core/configuration.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. do this only for -# options in the "monipy" section of monipy.ini. +# options in the "linspector" section of linspector.ini. class Configuration: def __init__(self, configuration_path, environment): @@ -57,7 +57,7 @@ class Configuration: section_list = glob.glob(configuration_path + '/' + target_section + '/*.ini') for section_file in section_list: - #print("-->"+section_file) + #print(__file__ + ' (60): ' + section_file) configuration = configparser.ConfigParser() configuration.read(section_file, 'utf-8') for source_section in configuration.sections(): diff --git a/linspector/core/daemon.py b/linspector/core/daemon.py index ba9a7d2..4b9853e 100644 --- a/linspector/core/daemon.py +++ b/linspector/core/daemon.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/environment.py b/linspector/core/environment.py index 39abbde..eb4bb88 100644 --- a/linspector/core/environment.py +++ b/linspector/core/environment.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/linspector.py b/linspector/core/linspector.py index e10494a..44b07a6 100644 --- a/linspector/core/linspector.py +++ b/linspector/core/linspector.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -34,9 +34,10 @@ class Linspector: self.__monitors = monitors # this function is just for testing purposes and can be removed some day - def print_monitors_monitor_identifiers(self): + def print_debug(self): # example on how to access the monitor objects in monitors monitors = self.__monitors.get_monitors() - #print(monitors) + print(__file__ + ' (40): ' + str(monitors)) for monitor in monitors: - print(monitors.get(monitor).get_identifier()) + print(__file__ + ' (42): ' + monitors.get(monitor).get_identifier()) + print(__file__ + ' (43): ' + monitors.get(monitor).get_service()) diff --git a/linspector/core/linspectord.py b/linspector/core/linspectord.py index cbfe595..82af911 100644 --- a/linspector/core/linspectord.py +++ b/linspector/core/linspectord.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/logger.py b/linspector/core/logger.py index 60706dc..10b188d 100644 --- a/linspector/core/logger.py +++ b/linspector/core/logger.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/model.py b/linspector/core/model.py index 619f442..cb421fc 100644 --- a/linspector/core/model.py +++ b/linspector/core/model.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/monitor.py b/linspector/core/monitor.py index 10d5902..c7e538c 100644 --- a/linspector/core/monitor.py +++ b/linspector/core/monitor.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,9 +21,8 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from linspector.core.notifications import Notifications -from linspector.core.service import Service -from linspector.core.services import Services +import importlib + from logging import getLogger logger = getLogger('linspector') @@ -40,5 +39,52 @@ class Monitor: self.__notifications = notifications self.__services = services + #print(__file__ + ' (42): ' + str(monitor_configuration)) + if self.__monitor_configuration.get('monitor', 'service'): + + # TODO: the exception handling later!!! + #try: + service_package = 'linspector.services.' + \ + self.__monitor_configuration.get('monitor', 'service').lower() + service_module = importlib.import_module(service_package) + + service = getattr(service_module, self.__monitor_configuration.get('monitor', 'service') + + 'Service') + service.__init__(self, configuration, environment) + + if self.__monitor_configuration.get('monitor', 'service') not in services: + services[self.__monitor_configuration.get('monitor', 'service')] = service + #print(__file__ + ' (57): ' + str(services)) + #else: + # do some logging + + #except ModuleNotFoundError as err: + # raise Exception('something went wrong when initializing a service. you are ' + # 'using an unknown service in your monitor configuration ' + # 'identified by: ' + identifier + '({0})'.format(err)) + + #service.execute(self) + + if self.__monitor_configuration.get('monitor', 'notifications'): + for notification_option in self.__monitor_configuration.get('monitor', + 'notifications').split(','): + + #print(__file__ + ' (72): ' + str(notification_option)) + notification_package = 'linspector.notifications.' + notification_option.lower() + notification_module = importlib.import_module(notification_package) + + notification = getattr(notification_module, notification_option + 'Notification') + notification.__init__(self, configuration, environment) + + if notification_option not in notifications: + notifications[notification_option] = notification + #print(__file__ + ' (81): ' + str(notifications)) + def get_identifier(self): return self.__identifier + + # currently only used for testing but maybe i will add get functions for all known variables. + # but not all variables can be known because all monitors are different. only the service + # implementation can know all variables which are being used inside the service. + def get_service(self): + return self.__monitor_configuration.get('monitor', 'service') diff --git a/linspector/core/monitors.py b/linspector/core/monitors.py index 2ccdef0..4a65a1a 100644 --- a/linspector/core/monitors.py +++ b/linspector/core/monitors.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ import configparser +import copy import glob import os @@ -43,21 +44,23 @@ class Monitors: self.__monitors = {} monitor_groups = os.listdir(self.__configuration.get_configuration_path() + '/monitors/') - print(monitor_groups) + #print(__file__ + ' (47): ' + str(monitor_groups)) + monitor_configuration = configparser.ConfigParser() for monitor_group in monitor_groups: monitors_file_list = glob.glob(self.__configuration.get_configuration_path() + '/monitors/' + monitor_group + '/*.ini') for monitor_file in monitors_file_list: - monitor_configuration = configparser.ConfigParser() monitor_configuration.read(monitor_file, 'utf-8') identifier = monitor_group + '_' + os.path.splitext(os.path.basename( monitor_file))[0] + # create Monitor() object and copy monitor_configuration for each instance because + # they else refer to the same object. self.__monitors[identifier] = Monitor(configuration, environment, identifier, - monitor_configuration, notifications, - services) + copy.deepcopy(monitor_configuration), + notifications, services) def get_monitors(self): return self.__monitors diff --git a/linspector/core/notification.py b/linspector/core/notification.py index f1e480b..7eb32eb 100644 --- a/linspector/core/notification.py +++ b/linspector/core/notification.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/notifications.py b/linspector/core/notifications.py index 0b9eb5a..ba1ecb1 100644 --- a/linspector/core/notifications.py +++ b/linspector/core/notifications.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/plugin.py b/linspector/core/plugin.py index 342f03b..d06989d 100644 --- a/linspector/core/plugin.py +++ b/linspector/core/plugin.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/plugins.py b/linspector/core/plugins.py index 609abbd..df65525 100644 --- a/linspector/core/plugins.py +++ b/linspector/core/plugins.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/service.py b/linspector/core/service.py deleted file mode 100644 index ed10011..0000000 --- a/linspector/core/service.py +++ /dev/null @@ -1,33 +0,0 @@ -""" -This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -""" - -from logging import getLogger - -logger = getLogger('linspector') - - -class Service: - - def __init__(self, configuration, environment): - self.__configuration = configuration - self.__environment = environment diff --git a/linspector/core/services.py b/linspector/core/services.py deleted file mode 100644 index cfdc3e7..0000000 --- a/linspector/core/services.py +++ /dev/null @@ -1,34 +0,0 @@ -""" -This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF -OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -""" - -from logging import getLogger - -logger = getLogger('linspector') - - -class Services: - - def __init__(self, configuration, environment): - super().__init__() - self.__configuration = configuration - self.__environment = environment diff --git a/linspector/core/task.py b/linspector/core/task.py index e2b4eff..dcc2aae 100644 --- a/linspector/core/task.py +++ b/linspector/core/task.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/core/tasks.py b/linspector/core/tasks.py index 3090a64..198cc00 100644 --- a/linspector/core/tasks.py +++ b/linspector/core/tasks.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/monitors/__init__.py b/linspector/monitors/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/linspector/notifications/call.py b/linspector/notifications/call.py index 68545b8..e1dbe14 100644 --- a/linspector/notifications/call.py +++ b/linspector/notifications/call.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,14 +22,12 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.notifications.notification import Notification logger = getLogger('linspector') -class CallNotification(Notification): +class CallNotification: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/notifications/email.py b/linspector/notifications/email.py index 40bdd56..8674698 100644 --- a/linspector/notifications/email.py +++ b/linspector/notifications/email.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,14 +22,12 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.notifications.notification import Notification logger = getLogger('linspector') -class EmailNotification(Notification): +class EmailNotification: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/notifications/sms.py b/linspector/notifications/sms.py index 3266967..0c14fc4 100644 --- a/linspector/notifications/sms.py +++ b/linspector/notifications/sms.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,14 +22,12 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.notifications.notification import Notification logger = getLogger('linspector') -class SMSNotification(Notification): +class SMSNotification: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/notifications/twitter.py b/linspector/notifications/twitter.py index a625fab..5f627bb 100644 --- a/linspector/notifications/twitter.py +++ b/linspector/notifications/twitter.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,14 +22,12 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.notifications.notification import Notification logger = getLogger('linspector') -class TwitterNotification(Notification): +class TwitterNotification: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/notifications/xmpp.py b/linspector/notifications/xmpp.py index b93c4d4..84247c9 100644 --- a/linspector/notifications/xmpp.py +++ b/linspector/notifications/xmpp.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,14 +22,12 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.notifications.notification import Notification logger = getLogger('linspector') -class XMPPNotification(Notification): +class XMPPNotification: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/plugins/httpserver.py b/linspector/plugins/httpserver.py index 1bec6c6..436f383 100644 --- a/linspector/plugins/httpserver.py +++ b/linspector/plugins/httpserver.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/plugins/lish.py b/linspector/plugins/lish.py index a4ec8cd..e235089 100644 --- a/linspector/plugins/lish.py +++ b/linspector/plugins/lish.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/linspector/services/dummy.py b/linspector/services/dummy.py index ea7b038..ef4b25e 100644 --- a/linspector/services/dummy.py +++ b/linspector/services/dummy.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class DummyService(Service): +class DummyService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/fritzbox.py b/linspector/services/fritzboxuplink.py similarity index 88% rename from linspector/services/fritzbox.py rename to linspector/services/fritzboxuplink.py index 257617c..d9a589e 100644 --- a/linspector/services/fritzbox.py +++ b/linspector/services/fritzboxuplink.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,16 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class FritzboxService(Service): +class FritzboxUplinkService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment + + def execute(self): + print(__file__ + ' (37): ' + 'test...') diff --git a/linspector/services/httpkeyword.py b/linspector/services/httpkeyword.py index aa337f0..f440290 100644 --- a/linspector/services/httpkeyword.py +++ b/linspector/services/httpkeyword.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class HTTPKeywordService(Service): +class HTTPKeywordService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/ping.py b/linspector/services/ping.py index 4cf47f5..30f4668 100644 --- a/linspector/services/ping.py +++ b/linspector/services/ping.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class PingService(Service): +class PingService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/port.py b/linspector/services/port.py index adc34b2..99daa45 100644 --- a/linspector/services/port.py +++ b/linspector/services/port.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class PortService(Service): +class PortService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/random.py b/linspector/services/random.py index a8005d3..1d4e324 100644 --- a/linspector/services/random.py +++ b/linspector/services/random.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class RandomService(Service): +class RandomService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/shell.py b/linspector/services/shell.py index 04dec6d..d81cc6a 100644 --- a/linspector/services/shell.py +++ b/linspector/services/shell.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class ShellService(Service): +class ShellService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/snmpget.py b/linspector/services/snmpget.py index 64581ca..9b7b33b 100644 --- a/linspector/services/snmpget.py +++ b/linspector/services/snmpget.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class SNMPGetService(Service): +class SNMPGetService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/speedtest.py b/linspector/services/speedtest.py index c47cb9d..3997b4b 100644 --- a/linspector/services/speedtest.py +++ b/linspector/services/speedtest.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -27,17 +27,13 @@ import time from logging import getLogger - -from linspector.services.service import Service - logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class SpeedtestService(Service): +class SpeedtestService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/ssh.py b/linspector/services/ssh.py index cfa542c..08935a3 100644 --- a/linspector/services/ssh.py +++ b/linspector/services/ssh.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class SSHService(Service): +class SSHService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/tcpconnect.py b/linspector/services/tcpconnect.py index f0478b8..66ca5b4 100644 --- a/linspector/services/tcpconnect.py +++ b/linspector/services/tcpconnect.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class TCPConnectService(Service): +class TCPConnectService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/services/uptime.py b/linspector/services/uptime.py index 0ec53b4..507a63f 100644 --- a/linspector/services/uptime.py +++ b/linspector/services/uptime.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,15 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.services.service import Service logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class UptimeService(Service): +class UptimeService: def __init__(self, configuration, environment): - super().__init__(configuration, environment) self.__configuration = configuration self.__environment = environment diff --git a/linspector/tasks/logger.py b/linspector/tasks/filelogger.py similarity index 91% rename from linspector/tasks/logger.py rename to linspector/tasks/filelogger.py index b7663ec..acc5471 100644 --- a/linspector/tasks/logger.py +++ b/linspector/tasks/filelogger.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,13 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.tasks.task import Task +from linspector.core.task import Task logger = getLogger('linspector') # TODO: check for all required configuration options and set defaults if needed. -class LoggerTask(Task): +class FileLoggerTask(Task): def __init__(self, configuration, environment): super().__init__(configuration, environment) diff --git a/linspector/tasks/mariadb.py b/linspector/tasks/mariadb.py index 117dec1..83850e1 100644 --- a/linspector/tasks/mariadb.py +++ b/linspector/tasks/mariadb.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.tasks.task import Task +from linspector.core.task import Task logger = getLogger('linspector') diff --git a/linspector/tasks/redis.py b/linspector/tasks/redis.py index 97a11a5..b8e0d70 100644 --- a/linspector/tasks/redis.py +++ b/linspector/tasks/redis.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.tasks.task import Task +from linspector.core.task import Task logger = getLogger('linspector') diff --git a/linspector/tasks/sqlite.py b/linspector/tasks/sqlite.py index b017757..bdde4c6 100644 --- a/linspector/tasks/sqlite.py +++ b/linspector/tasks/sqlite.py @@ -1,6 +1,6 @@ """ This file is part of Linspector (https://linspector.org/) -Copyright (c) 2022 Johannes Findeisen +Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from logging import getLogger -from linspector.tasks.task import Task +from linspector.core.task import Task logger = getLogger('linspector')