From 1797c37a1d6d78b7e064e2434bce01e4d80993e5 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Fri, 23 Sep 2022 23:51:08 +0200 Subject: [PATCH] Base skeleton commit to get started with my idea of monipy. --- .gitignore | 2 + AUTHORS | 7 + CHANGELOG | 0 LICENSE | 2 +- Makefile | 0 README.md | 3 +- TODO | 0 bin/__init__.py | 0 bin/monipy | 65 ++++++++ bin/monipyd | 65 ++++++++ etc/monipy/monipy.json | 0 etc/monipy/monitors/.gitkeep | 0 etc/monipy/monitors/network1/.gitkeep | 0 .../monitors/network1/cable_uplink.json | 9 + etc/monipy/monitors/network2/.gitkeep | 0 etc/monipy/monitors/network2/dsl_uplink.json | 9 + etc/monipy/notifications/.gitkeep | 0 etc/monipy/plugins/.gitkeep | 0 log/.gitkeep | 0 monipy/__init__.py | 0 monipy/configuration.py | 29 ++++ monipy/daemon.py | 156 ++++++++++++++++++ monipy/environment.py | 29 ++++ monipy/monipy.py | 30 ++++ monipy/monipyd.py | 31 ++++ monipy/notications/__init__.py | 0 monipy/notications/network/__init__.py | 0 monipy/notications/network/email.py | 30 ++++ monipy/notications/notification.py | 29 ++++ monipy/notications/phone/__init__.py | 0 monipy/notications/phone/sms.py | 30 ++++ monipy/plugins/__init__.py | 0 monipy/plugins/network/__init__.py | 0 monipy/plugins/network/httpserver.py | 30 ++++ monipy/plugins/plugin.py | 29 ++++ monipy/plugins/storage/__init__.py | 0 monipy/plugins/storage/mariadb.py | 30 ++++ monipy/plugins/storage/redis.py | 30 ++++ monipy/plugins/storage/sqlite.py | 30 ++++ monipy/types/__init__.py | 0 monipy/types/network/__init__.py | 0 monipy/types/network/ping.py | 30 ++++ monipy/types/network/port.py | 30 ++++ monipy/types/network/speedtest.py | 30 ++++ monipy/types/network/uplink.py | 30 ++++ monipy/types/type.py | 29 ++++ requirements.txt | 0 setup.py | 0 48 files changed, 821 insertions(+), 3 deletions(-) create mode 100644 AUTHORS create mode 100644 CHANGELOG create mode 100644 Makefile create mode 100644 TODO create mode 100644 bin/__init__.py create mode 100755 bin/monipy create mode 100755 bin/monipyd create mode 100644 etc/monipy/monipy.json create mode 100644 etc/monipy/monitors/.gitkeep create mode 100644 etc/monipy/monitors/network1/.gitkeep create mode 100644 etc/monipy/monitors/network1/cable_uplink.json create mode 100644 etc/monipy/monitors/network2/.gitkeep create mode 100644 etc/monipy/monitors/network2/dsl_uplink.json create mode 100644 etc/monipy/notifications/.gitkeep create mode 100644 etc/monipy/plugins/.gitkeep create mode 100644 log/.gitkeep create mode 100644 monipy/__init__.py create mode 100644 monipy/configuration.py create mode 100644 monipy/daemon.py create mode 100644 monipy/environment.py create mode 100644 monipy/monipy.py create mode 100644 monipy/monipyd.py create mode 100644 monipy/notications/__init__.py create mode 100644 monipy/notications/network/__init__.py create mode 100644 monipy/notications/network/email.py create mode 100644 monipy/notications/notification.py create mode 100644 monipy/notications/phone/__init__.py create mode 100644 monipy/notications/phone/sms.py create mode 100644 monipy/plugins/__init__.py create mode 100644 monipy/plugins/network/__init__.py create mode 100644 monipy/plugins/network/httpserver.py create mode 100644 monipy/plugins/plugin.py create mode 100644 monipy/plugins/storage/__init__.py create mode 100644 monipy/plugins/storage/mariadb.py create mode 100644 monipy/plugins/storage/redis.py create mode 100644 monipy/plugins/storage/sqlite.py create mode 100644 monipy/types/__init__.py create mode 100644 monipy/types/network/__init__.py create mode 100644 monipy/types/network/ping.py create mode 100644 monipy/types/network/port.py create mode 100644 monipy/types/network/speedtest.py create mode 100644 monipy/types/network/uplink.py create mode 100644 monipy/types/type.py create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 6a7d809..a8b1a3d 100644 --- a/.gitignore +++ b/.gitignore @@ -240,3 +240,5 @@ luac.out *.hex +/monipy.iml +/.idea/ diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..d20c371 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,7 @@ +PRIMARY AUTHORS (alphabetic order): + +* Findeisen, Johannes + Main Developer and maintainer. + github.com: + git.unixpeople.org: + Homepage: \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE index d449d3e..bf877cd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) +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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 9c46cc3..1c9399a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# monipy - +# monipy - A infrastructure monitoring toolchain diff --git a/TODO b/TODO new file mode 100644 index 0000000..e69de29 diff --git a/bin/__init__.py b/bin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/monipy b/bin/monipy new file mode 100755 index 0000000..8411a71 --- /dev/null +++ b/bin/monipy @@ -0,0 +1,65 @@ +#!/usr/bin/python3 -d + +# 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. + +import argparse + +from logging import getLogger +#from monipy.configuration import Configuration +#from monipy.environment import Environment +#from monipy.monipy import Monipy + +""" +According to: https://wiki.unixpeople.org/linux_kernel_version_numbering +MAJOR.FEATURE.MINOR.FIXES +MAJOR changes can change the API. The lesser, the better. +FEATURE changes can, but should not break the API. New features are placed here. It expects a +complete documentation. +MINOR changes are "just-in-time" changes or small enhancements which should not affect the +documentation. +FIXES should never affect anything else then stability or security. +""" +__version__ = '0.1' +__author__ = 'Johannes Findeisen ' + +logger = getLogger('monipy') + + +def parse_args(): + parser = argparse.ArgumentParser( + description='monipy is a client for the monipyd infrastructure monitoring daemon.', + epilog='author: ' + __author__, + prog='monipy') + + parser.add_argument('configuration_path', metavar='CONFIGURATION_PATH', + help='the configuration path to use') + + parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + str(__version__)) + + return parser.parse_args() + + +def main(): + args = parse_args() + + +if __name__ == '__main__': + main() diff --git a/bin/monipyd b/bin/monipyd new file mode 100755 index 0000000..95c93a0 --- /dev/null +++ b/bin/monipyd @@ -0,0 +1,65 @@ +#!/usr/bin/python3 -d + +# 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. + +import argparse + +from logging import getLogger +from monipy.configuration import Configuration +from monipy.environment import Environment +from monipy.monipyd import Monipyd + +""" +According to: https://wiki.unixpeople.org/linux_kernel_version_numbering +MAJOR.FEATURE.MINOR.FIXES +MAJOR changes can change the API. The lesser, the better. +FEATURE changes can, but should not break the API. New features are placed here. It expects a +complete documentation. +MINOR changes are "just-in-time" changes or small enhancements which should not affect the +documentation. +FIXES should never affect anything else then stability or security. +""" +__version__ = '0.1' +__author__ = 'Johannes Findeisen ' + +logger = getLogger('monipy') + + +def parse_args(): + parser = argparse.ArgumentParser( + description='monipyd is a infrastructure monitoring daemon.', + epilog='author: ' + __author__, + prog='monipyd') + + parser.add_argument('configuration_path', metavar='CONFIGURATION_PATH', + help='the configuration path to use') + + parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + str(__version__)) + + return parser.parse_args() + + +def main(): + args = parse_args() + + +if __name__ == '__main__': + main() diff --git a/etc/monipy/monipy.json b/etc/monipy/monipy.json new file mode 100644 index 0000000..e69de29 diff --git a/etc/monipy/monitors/.gitkeep b/etc/monipy/monitors/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/etc/monipy/monitors/network1/.gitkeep b/etc/monipy/monitors/network1/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/etc/monipy/monitors/network1/cable_uplink.json b/etc/monipy/monitors/network1/cable_uplink.json new file mode 100644 index 0000000..c2e8a24 --- /dev/null +++ b/etc/monipy/monitors/network1/cable_uplink.json @@ -0,0 +1,9 @@ +{ + "type": "uplink", + "interval": 60, + "notification": "sms", + "host": "192.168.0.1", + "user": "USERNAME", + "password": "PASSWORD", + "info": "Cable Provider" +} \ No newline at end of file diff --git a/etc/monipy/monitors/network2/.gitkeep b/etc/monipy/monitors/network2/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/etc/monipy/monitors/network2/dsl_uplink.json b/etc/monipy/monitors/network2/dsl_uplink.json new file mode 100644 index 0000000..a7286ce --- /dev/null +++ b/etc/monipy/monitors/network2/dsl_uplink.json @@ -0,0 +1,9 @@ +{ + "type": "uplink", + "interval": 60, + "notification": "sms", + "host": "192.168.1.1", + "user": "USERNAME", + "password": "PASSWORD", + "info": "DSL Provider" +} \ No newline at end of file diff --git a/etc/monipy/notifications/.gitkeep b/etc/monipy/notifications/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/etc/monipy/plugins/.gitkeep b/etc/monipy/plugins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/log/.gitkeep b/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/monipy/__init__.py b/monipy/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/configuration.py b/monipy/configuration.py new file mode 100644 index 0000000..a1f0a0b --- /dev/null +++ b/monipy/configuration.py @@ -0,0 +1,29 @@ +# 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('monipy') + + +class Configuration: + + def __init__(self, configuration_file): + self.__configuration_file = configuration_file diff --git a/monipy/daemon.py b/monipy/daemon.py new file mode 100644 index 0000000..dc96747 --- /dev/null +++ b/monipy/daemon.py @@ -0,0 +1,156 @@ +# 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. + +import atexit +import os +import signal +import sys +import time + +from logging import getLogger + +logger = getLogger('monipy') + + +class Daemon: + """ + Usage: subclass the daemon class and override the run() method. + """ + + def __init__(self, pid_file): + self.pid_file = pid_file + + def daemonize(self): + """ + Daemonize the class using the UNIX double fork mechanism. + """ + + # Do first fork + try: + pid = os.fork() + if pid > 0: + # Exit first parent + sys.exit(0) + except OSError as err: + logger.error(str('fork #1 failed: {0}'.format(err))) + sys.exit(1) + + # Decouple from parent environment + os.chdir('/') + os.setsid() + os.umask(0) + + # Do second fork + try: + pid = os.fork() + if pid > 0: + # Exit from second parent + sys.exit(0) + except OSError as err: + logger.error(str('fork #2 failed: {0}'.format(err))) + sys.exit(1) + + # Redirect standard file descriptors + sys.stdout.flush() + sys.stderr.flush() + si = open(os.devnull, 'r') + so = open(os.devnull, 'a+') + se = open(os.devnull, 'a+') + + os.dup2(si.fileno(), sys.stdin.fileno()) + os.dup2(so.fileno(), sys.stdout.fileno()) + os.dup2(se.fileno(), sys.stderr.fileno()) + + # Write pidfile + atexit.register(self.del_pid) + + pid = str(os.getpid()) + with open(self.pid_file, 'w+') as f: + f.write(pid + '\n') + + def del_pid(self): + os.remove(self.pid_file) + + def start(self): + """ + Start the daemon. + """ + + # Check for a pidfile to see if the daemon already runs + try: + with open(self.pid_file, 'r') as pf: + pid = int(pf.read().strip()) + except IOError: + pid = None + + if pid: + message = 'pid_file {0} already exist. daemon already running?' + logger.error(str(message.format(self.pid_file))) + sys.exit(1) + + # Start the daemon + self.daemonize() + self.run() + + def stop(self): + """ + Stop the daemon. + """ + + # Get the pid from the pid_file + try: + with open(self.pid_file, 'r') as pf: + pid = int(pf.read().strip()) + except IOError: + pid = None + + if not pid: + message = 'pid_file {0} does not exist. daemon not running?' + logger.error(str(message.format(self.pid_file))) + return # not an error in a restart + + # Try killing the daemon process + try: + while 1: + os.kill(pid, signal.SIGTERM) + time.sleep(0.1) + except OSError as err: + e = str(err.args) + if e.find('no such process') > 0: + if os.path.exists(self.pid_file): + os.remove(self.pid_file) + else: + logger.error(str(err.args)) + sys.exit(1) + + def restart(self): + """ + Restart the daemon. + """ + self.stop() + self.start() + + def run(self): + """ + You should override this method when you subclass Daemon. + + It will be called after the process has been daemonized by + start() or restart(). + """ diff --git a/monipy/environment.py b/monipy/environment.py new file mode 100644 index 0000000..2e7bf9f --- /dev/null +++ b/monipy/environment.py @@ -0,0 +1,29 @@ +# 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('monipy') + + +class Environment: + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/monipy.py b/monipy/monipy.py new file mode 100644 index 0000000..a18537e --- /dev/null +++ b/monipy/monipy.py @@ -0,0 +1,30 @@ +# 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('monipy') + + +class Monipy: + + def __init__(self, configuration, environment): + self.__configuration = configuration + self.__environment = environment diff --git a/monipy/monipyd.py b/monipy/monipyd.py new file mode 100644 index 0000000..646f405 --- /dev/null +++ b/monipy/monipyd.py @@ -0,0 +1,31 @@ +# 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 +from monipy.daemon import Daemon + +logger = getLogger('monipy') + + +class Monipyd(Daemon): + + def __init__(self, configuration, environment): + self.__configuration = configuration + self.__environment = environment diff --git a/monipy/notications/__init__.py b/monipy/notications/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/notications/network/__init__.py b/monipy/notications/network/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/notications/network/email.py b/monipy/notications/network/email.py new file mode 100644 index 0000000..8b0d7f9 --- /dev/null +++ b/monipy/notications/network/email.py @@ -0,0 +1,30 @@ +# 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 +from monipy.notications.notification import Notification + +logger = getLogger('monipy') + + +class EmailNotification(Notification): + + def __init__(self, configuration): + self._configuration = configuration diff --git a/monipy/notications/notification.py b/monipy/notications/notification.py new file mode 100644 index 0000000..e6d8127 --- /dev/null +++ b/monipy/notications/notification.py @@ -0,0 +1,29 @@ +# 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('monipy') + + +class Notification: + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/notications/phone/__init__.py b/monipy/notications/phone/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/notications/phone/sms.py b/monipy/notications/phone/sms.py new file mode 100644 index 0000000..593ddcd --- /dev/null +++ b/monipy/notications/phone/sms.py @@ -0,0 +1,30 @@ +# 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 +from monipy.notications.notification import Notification + +logger = getLogger('monipy') + + +class SmsNotification(Notification): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/plugins/__init__.py b/monipy/plugins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/plugins/network/__init__.py b/monipy/plugins/network/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/plugins/network/httpserver.py b/monipy/plugins/network/httpserver.py new file mode 100644 index 0000000..599021b --- /dev/null +++ b/monipy/plugins/network/httpserver.py @@ -0,0 +1,30 @@ +# 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 +from monipy.plugins.plugin import Plugin + +logger = getLogger('monipy') + + +class HttpserverPlugin(Plugin): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/plugins/plugin.py b/monipy/plugins/plugin.py new file mode 100644 index 0000000..c7354cd --- /dev/null +++ b/monipy/plugins/plugin.py @@ -0,0 +1,29 @@ +# 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('monipy') + + +class Plugin: + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/plugins/storage/__init__.py b/monipy/plugins/storage/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/plugins/storage/mariadb.py b/monipy/plugins/storage/mariadb.py new file mode 100644 index 0000000..8623caa --- /dev/null +++ b/monipy/plugins/storage/mariadb.py @@ -0,0 +1,30 @@ +# 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 +from monipy.plugins.plugin import Plugin + +logger = getLogger('monipy') + + +class MariadbPlugin(Plugin): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/plugins/storage/redis.py b/monipy/plugins/storage/redis.py new file mode 100644 index 0000000..6fcd4d4 --- /dev/null +++ b/monipy/plugins/storage/redis.py @@ -0,0 +1,30 @@ +# 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 +from monipy.plugins.plugin import Plugin + +logger = getLogger('monipy') + + +class RedisPlugin(Plugin): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/plugins/storage/sqlite.py b/monipy/plugins/storage/sqlite.py new file mode 100644 index 0000000..9ca17ba --- /dev/null +++ b/monipy/plugins/storage/sqlite.py @@ -0,0 +1,30 @@ +# 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 +from monipy.plugins.plugin import Plugin + +logger = getLogger('monipy') + + +class SqlitePlugin(Plugin): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/types/__init__.py b/monipy/types/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/types/network/__init__.py b/monipy/types/network/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/monipy/types/network/ping.py b/monipy/types/network/ping.py new file mode 100644 index 0000000..aad6623 --- /dev/null +++ b/monipy/types/network/ping.py @@ -0,0 +1,30 @@ +# 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 +from monipy.types.type import Type + +logger = getLogger('monipy') + + +class PingType(Type): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/types/network/port.py b/monipy/types/network/port.py new file mode 100644 index 0000000..c755d28 --- /dev/null +++ b/monipy/types/network/port.py @@ -0,0 +1,30 @@ +# 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 +from monipy.types.type import Type + +logger = getLogger('monipy') + + +class PortType(Type): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/types/network/speedtest.py b/monipy/types/network/speedtest.py new file mode 100644 index 0000000..8721c89 --- /dev/null +++ b/monipy/types/network/speedtest.py @@ -0,0 +1,30 @@ +# 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 +from monipy.types.type import Type + +logger = getLogger('monipy') + + +class SpeedtestType(Type): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/types/network/uplink.py b/monipy/types/network/uplink.py new file mode 100644 index 0000000..3972fe6 --- /dev/null +++ b/monipy/types/network/uplink.py @@ -0,0 +1,30 @@ +# 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 +from monipy.types.type import Type + +logger = getLogger('monipy') + + +class UplinkType(Type): + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/monipy/types/type.py b/monipy/types/type.py new file mode 100644 index 0000000..8594bcb --- /dev/null +++ b/monipy/types/type.py @@ -0,0 +1,29 @@ +# 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('monipy') + + +class Type: + + def __init__(self, configuration): + self.__configuration = configuration diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e69de29