+
+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 cherrypy
+import json
+
+from logging import getLogger
+from monipy.plugins.plugin import Plugin
+
+logger = getLogger('monipyd')
+
+
+class HTTPServerPlugin(Plugin):
+
+ def __init__(self, configuration, environment):
+ super().__init__(configuration, environment)
+ self.__configuration = configuration
+ self.__environment = environment
+
+ @cherrypy.expose
+ def index(self):
+ return 'Hello world!'
+
+ @cherrypy.expose
+ def configuration(self):
+ return '[monipy-' + \
+ self.__environment.get_env_var("__version__") + '@' + \
+ self.__environment.get_env_var("_hostname") + '] configuration' + \
+ json.dumps(vars(self.__configuration), sort_keys=True, indent=4) + \
+ '
'
+
+ @cherrypy.expose
+ def environment(self):
+ return '[monipy-' + \
+ self.__environment.get_env_var("__version__") + '@' + \
+ self.__environment.get_env_var("_hostname") + '] environment' + \
+ json.dumps(vars(self.__environment), sort_keys=True, indent=4) + \
+ '
'
+
+ @cherrypy.expose
+ def playground(self):
+ return 'My Playground!'
+
+ def run_server(self):
+ conf = {
+ '/': {
+ # 'tools.sessions.on': True,
+ # 'tools.staticdir.root': os.path.abspath(os.getcwd())
+ 'tools.response_headers.on': True,
+ 'tools.response_headers.headers': [('Content-Type', 'text/plain')],
+ },
+ '/configuration': {
+ # 'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
+ 'tools.response_headers.on': True,
+ 'tools.response_headers.headers': [('Content-Type', 'text/html')],
+ },
+ '/environment': {
+ # 'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
+ 'tools.response_headers.on': True,
+ 'tools.response_headers.headers': [('Content-Type', 'text/html')],
+ },
+ '/playground': {
+ # 'tools.staticdir.on': True,
+ # 'tools.staticdir.dir': './public'
+ }
+ }
+ #cherrypy.config.update({
+ # 'global': {
+ # 'engine.autoreload.on': False
+ # }
+ #})
+ cherrypy.config.update({
+ 'global': {
+ 'server.socket_host': self.__configuration.get_httpserver_host(),
+ 'server.socket_port': self.__configuration.get_httpserver_port(),
+ 'environment': 'production'
+ }
+ })
+ cherrypy.tree.mount(root=None, config=conf)
+ cherrypy.quickstart(self, '/', conf)
+ #cherrypy.server.bus.exit(self)
diff --git a/monipy/plugins/mariadb.py b/monipy/plugins/mariadb.py
new file mode 100644
index 0000000..51f4bed
--- /dev/null
+++ b/monipy/plugins/mariadb.py
@@ -0,0 +1,35 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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('monipyd')
+
+
+class MariadbPlugin(Plugin):
+
+ def __init__(self, configuration, environment):
+ super().__init__(configuration, environment)
+ self.__configuration = configuration
+ self.__environment = environment
diff --git a/monipy/plugins/network/__init__.py b/monipy/plugins/network/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/monipy/plugins/network/httpserver.py b/monipy/plugins/network/httpserver.py
deleted file mode 100644
index 599021b..0000000
--- a/monipy/plugins/network/httpserver.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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
deleted file mode 100644
index c7354cd..0000000
--- a/monipy/plugins/plugin.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# 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/redis.py b/monipy/plugins/redis.py
new file mode 100644
index 0000000..903f5f2
--- /dev/null
+++ b/monipy/plugins/redis.py
@@ -0,0 +1,35 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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('monipyd')
+
+
+class RedisPlugin(Plugin):
+
+ def __init__(self, configuration, environment):
+ super().__init__(configuration, environment)
+ self.__configuration = configuration
+ self.__environment = environment
diff --git a/monipy/plugins/sqlite.py b/monipy/plugins/sqlite.py
new file mode 100644
index 0000000..d450eae
--- /dev/null
+++ b/monipy/plugins/sqlite.py
@@ -0,0 +1,35 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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('monipyd')
+
+
+class SqlitePlugin(Plugin):
+
+ def __init__(self, configuration, environment):
+ super().__init__(configuration, environment)
+ self.__configuration = configuration
+ self.__environment = environment
diff --git a/monipy/plugins/storage/__init__.py b/monipy/plugins/storage/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/monipy/plugins/storage/mariadb.py b/monipy/plugins/storage/mariadb.py
deleted file mode 100644
index 8623caa..0000000
--- a/monipy/plugins/storage/mariadb.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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
deleted file mode 100644
index 6fcd4d4..0000000
--- a/monipy/plugins/storage/redis.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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
deleted file mode 100644
index 9ca17ba..0000000
--- a/monipy/plugins/storage/sqlite.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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/type.py b/monipy/type.py
new file mode 100644
index 0000000..d69dad4
--- /dev/null
+++ b/monipy/type.py
@@ -0,0 +1,33 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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('monipyd')
+
+
+class Type:
+
+ def __init__(self, configuration, environment):
+ self.__configuration = configuration
+ self.__environment = environment
diff --git a/monipy/types.py b/monipy/types.py
new file mode 100644
index 0000000..61c143d
--- /dev/null
+++ b/monipy/types.py
@@ -0,0 +1,34 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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('monipyd')
+
+
+class Types:
+
+ def __init__(self, configuration, environment):
+ super().__init__()
+ self.__configuration = configuration
+ self.__environment = environment
diff --git a/monipy/types/fritzbox.py b/monipy/types/fritzbox.py
new file mode 100644
index 0000000..17f85eb
--- /dev/null
+++ b/monipy/types/fritzbox.py
@@ -0,0 +1,35 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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('monipyd')
+
+
+class FritzboxType(Type):
+
+ def __init__(self, configuration, environment):
+ super().__init__(configuration, environment)
+ self.__configuration = configuration
+ self.__environment = environment
diff --git a/monipy/types/network/__init__.py b/monipy/types/network/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/monipy/types/network/ping.py b/monipy/types/network/ping.py
deleted file mode 100644
index aad6623..0000000
--- a/monipy/types/network/ping.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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
deleted file mode 100644
index c755d28..0000000
--- a/monipy/types/network/port.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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
deleted file mode 100644
index 8721c89..0000000
--- a/monipy/types/network/speedtest.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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
deleted file mode 100644
index 3972fe6..0000000
--- a/monipy/types/network/uplink.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# 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/ping.py b/monipy/types/ping.py
new file mode 100644
index 0000000..213ff8c
--- /dev/null
+++ b/monipy/types/ping.py
@@ -0,0 +1,35 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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('monipyd')
+
+
+class PingType(Type):
+
+ def __init__(self, configuration, environment):
+ super().__init__(configuration, environment)
+ self.__configuration = configuration
+ self.__environment = environment
diff --git a/monipy/types/port.py b/monipy/types/port.py
new file mode 100644
index 0000000..71817cd
--- /dev/null
+++ b/monipy/types/port.py
@@ -0,0 +1,35 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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('monipyd')
+
+
+class PortType(Type):
+
+ def __init__(self, configuration, environment):
+ super().__init__(configuration, environment)
+ self.__configuration = configuration
+ self.__environment = environment
diff --git a/monipy/types/speedtest.py b/monipy/types/speedtest.py
new file mode 100644
index 0000000..063e94e
--- /dev/null
+++ b/monipy/types/speedtest.py
@@ -0,0 +1,94 @@
+"""
+This file is part of monipy (https://hanez.org/monipy/)
+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 calendar
+import requests
+import time
+
+from logging import getLogger
+
+
+from monipy.types.type import Type
+
+logger = getLogger('monipyd')
+
+
+class SpeedtestType(Type):
+
+ def __init__(self, configuration, environment):
+ super().__init__(configuration, environment)
+ self.__configuration = configuration
+ self.__environment = environment
+
+ self.__speedtest_maximum_speed = None
+ self.__speedtest_average_speed = None
+ self.__speedtest_time_elapsed = None
+
+ def execute(self):
+ while True:
+ tmp_time = time.localtime(calendar.timegm(time.gmtime()))
+ self.__environment.set_env_var('_speedtest_last_run_date',
+ time.strftime('%Y-%m-%d %H:%M:%S',
+ tmp_time))
+
+ self.__environment.set_env_var('_speedtest_last_run_timestamp',
+ calendar.timegm(time.gmtime()))
+
+ start = time.perf_counter()
+ request = requests.get(self.__configuration.get_speedtest_url(), stream=True)
+ size = int(request.headers.get('Content-Length'))
+ downloaded = 0.0
+ total_mbps = 0.0
+ maximum_speed = 0.0
+ total_chunks = 0.0
+
+ if size is not None:
+ for chunk in request.iter_content(1024 * 1024):
+ downloaded += len(chunk)
+ # megabytes per second
+ mbps = downloaded / (time.perf_counter() - start) / (1024 * 1024)
+ if mbps > maximum_speed:
+ maximum_speed = mbps
+ total_chunks += 1
+ total_mbps += mbps
+
+ self.__speedtest_average_speed = total_mbps / total_chunks
+ self.__environment.set_env_var('_speedtest_average_speed_megabyte_per_second',
+ str(round(self.__speedtest_average_speed)))
+
+ self.__speedtest_maximum_speed = maximum_speed
+ self.__environment.set_env_var('_speedtest_maximum_speed_megabyte_per_second',
+ str(round(self.__speedtest_maximum_speed)))
+
+ self.__speedtest_time_elapsed = time.perf_counter() - start
+ self.__environment.set_env_var('_speedtest_time_elapsed',
+ str(self.__speedtest_time_elapsed))
+ logger.info('speedtest average: ' + str(self.__speedtest_average_speed) +
+ ', max: ' + str(self.__speedtest_maximum_speed) +
+ ', time: ' + str(self.__speedtest_time_elapsed))
+ else:
+ logger.warning('could not calculate download speed!')
+
+ time.sleep(self.__configuration.get_speedtest_interval())
+
+ def write_to_db(self):
+ return
diff --git a/monipy/types/type.py b/monipy/types/type.py
deleted file mode 100644
index 8594bcb..0000000
--- a/monipy/types/type.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# 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
index e69de29..48b8acd 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+requests~=2.28.1 # used by speedtest type
+CherryPy~=18.8.0 # used by httpserver plugin
\ No newline at end of file