diff --git a/README.md b/README.md index 0ec709a..b550fed 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ ## About -The idea is based on a software I developed around 2010 or so. The name of the software was +The idea is based on a software I developed around 2010 or so. The name of the software was [Linspector](https://linspector.org/) but the implementation was just too -complicated. The idea still remains so here is the rebirth of Linspector. First commits -of this rewrite where done as a new project named -[monipy](https://git.unixpeople.org/linspector/monipy), but I moved to the name -Linspector because I believe it is the better and cooler name... Old Linspector code is -not available in this repository anymore, you can find it under +complicated. The idea still remains so here is the rebirth of Linspector. First commits +of this rewrite where done as a new project named +[monipy](https://git.unixpeople.org/linspector/monipy), but I moved to the name +Linspector because I believe it is the better and cooler name... Old Linspector code is +not available in this repository anymore, you can find it under [https://git.unixpeople.org/linspector/linspector-old](https://git.unixpeople.org/linspector/linspector-old). Hope this project will become useful for someone at some day and not only for @@ -28,80 +28,80 @@ I design the software actually and try to convert my ideas to software. ### Environment My development environment is running using a virtual Python environment. I am using -all packages defined in requirements.txt. +all packages defined in requirements.txt. -Linspector includes a Makefile for executing bin/linspector without writing the full +Linspector includes a Makefile for executing bin/linspector without writing the full command with pretended PYTHONPATH. This makes my work a little easier. -The IDE I am using is [IntelliJ IDEA Community Edition](https://www.jetbrains.com/idea/) -with Python plugin and / or [PyCharm Community](https://www.jetbrains.com/pycharm/) from -[JetBrains](https://www.jetbrains.com/). I mention the IDE here because I am very thankful -to JetBrains for providing such a nice piece of software. I have never seen such a perfect +The IDE I am using is [IntelliJ IDEA Community Edition](https://www.jetbrains.com/idea/) +with Python plugin and / or [PyCharm Community](https://www.jetbrains.com/pycharm/) from +[JetBrains](https://www.jetbrains.com/). I mention the IDE here because I am very thankful +to JetBrains for providing such a nice piece of software. I have never seen such a perfect development environment. ### To do -- **Everything!** But the progress is fast and after some few days I am not far -away to get a first working codebase. If the core is running I believe adding features -will happen from day to day... ;) +- **Everything!** But the progress is fast and after some few days I am not far + away to get a first working codebase. If the core is running I believe adding features + will happen from day to day... ;) See TODO for internal tasks. ### Ideas - **Thousands!** For now the goal is to implement most features from the old version -of Linspector. :) + of Linspector. :) ### Manifest - All of this project **must be MIT licensed**. When using 3rd party libraries make -sure the license is compatible but MIT should always be preferred if an -alternative is available. + sure the license is compatible but MIT should always be preferred if an + alternative is available. - The core of Linspector should not use 3rd party libraries. Only plugins, -notifications and types may use other libraries. But copying code into the -source tree is ok when respecting the license. Not using 3rd party libraries -should always be preferred though. + notifications and types may use other libraries. But copying code into the + source tree is ok when respecting the license. Not using 3rd party libraries + should always be preferred though. - Inline comments should be all lowercase. Descriptions and documentation comments -must be natural language. + must be natural language. - Arguments to functions must always be in alphabetical order. -- Class member variables must always be in alphabetical order in __init__() or any -function / method. +- Class member variables must always be in alphabetical order in __init__() or any + function / method. - Every commit must run without errors even if not being a working version of Linspector. ### Required libraries Currently, the Linspector core requires the following 3rd party libraries: -- [APScheduler](https://github.com/agronholm/apscheduler) - This is the scheduler in -Linspector for execution of monitors. I started -to use this library in very early versions of Linspector in 2011. Since the main task -in Linspector is the execution of jobs in regularly intervals I believe it is the right -decision to make use of APScheduler directly in the core of the Linspector project. +- [APScheduler](https://github.com/agronholm/apscheduler) - This is the scheduler in + Linspector for execution of monitors. I started + to use this library in very early versions of Linspector in 2011. Since the main task + in Linspector is the execution of jobs in regularly intervals I believe it is the right + decision to make use of APScheduler directly in the core of the Linspector project. ### Other used libraries -monitors, notifications, services or plugins sometimes need to make the use of -3rd party libraries, but they are not required to run Linspector properly. Not installing +monitors, notifications, services or plugins sometimes need to make the use of +3rd party libraries, but they are not required to run Linspector properly. Not installing them may only affect parts of Linspector. Currently used libraries are: -- [CherryPy](https://cherrypy.dev/) - CherryPy is a pythonic, object-oriented HTTP framework. -Used by the HTTPServer plugin. -- [fritzconnection](https://github.com/kbr/fritzconnection) - A Python-Tool to communicate with -the AVM Fritz!Box. Uses the TR-064 protocol over UPnP. Used by the FritzboxPhoneStatus and -FritzBoxUplink service. -- [Paramiko](https://www.paramiko.org/) - Paramiko is a pure-Python (2.7, 3.4+) implementation -of the SSHv2 protocol, providing both client and server functionality. Used by the SSH service. -- [python-gammu](https://wammu.eu/python-gammu/) - Python bindings for the Gammu library. Used by the -SMS notification. -- [PySNMP](https://pysnmp.readthedocs.io/en/latest/) - PySNMP is a cross-platform, pure-Python -SNMP engine implementation. It features fully-functional SNMP engine capable to act in -Agent/Manager/Proxy roles, talking SNMP v1/v2c/v3 protocol versions over IPv4/IPv6 and other -network transports. Used by the SNMP services (get). -- [requests](https://requests.readthedocs.io/en/latest/) - Requests is an elegant and simple -HTTP library for Python, built for human beings. Used by the Speedtest service. +- [CherryPy](https://cherrypy.dev/) - CherryPy is a pythonic, object-oriented HTTP framework. + Used by the HTTPServer plugin. +- [fritzconnection](https://github.com/kbr/fritzconnection) - A Python-Tool to communicate with + the AVM Fritz!Box. Uses the TR-064 protocol over UPnP. Used by the FritzboxPhoneStatus and + FritzBoxUplink service. +- [Paramiko](https://www.paramiko.org/) - Paramiko is a pure-Python (2.7, 3.4+) implementation + of the SSHv2 protocol, providing both client and server functionality. Used by the SSH service. +- [python-gammu](https://wammu.eu/python-gammu/) - Python bindings for the Gammu library. Used by the + SMS notification. +- [PySNMP](https://pysnmp.readthedocs.io/en/latest/) - PySNMP is a cross-platform, pure-Python + SNMP engine implementation. It features fully-functional SNMP engine capable to act in + Agent/Manager/Proxy roles, talking SNMP v1/v2c/v3 protocol versions over IPv4/IPv6 and other + network transports. Used by the SNMP services (get). +- [requests](https://requests.readthedocs.io/en/latest/) - Requests is an elegant and simple + HTTP library for Python, built for human beings. Used by the Speedtest service. - [xmpp2](https://pypi.org/project/xmpp2/) - A XMPP client for Python. Used by the XMPP notification. -These libraries are not being delivered with the Linspector source code and maybe have +These libraries are not being delivered with the Linspector source code and maybe have different and incompatible licenses. You need to install them using pip, your OS package manager or any other possible way. @@ -112,9 +112,9 @@ scheme (See: [https://semver.org/](https://semver.org/)): #### MAJOR.MINOR.MAINTENANCE -- **MAJOR** changes _can_ change the API. The lesser, the better. It _expects_ a -complete documentation. -- **MINOR** changes _must_ not break the API. New features are placed here. +- **MAJOR** changes _can_ change the API. The lesser, the better. It _expects_ a + complete documentation. +- **MINOR** changes _must_ not break the API. New features are placed here. - **MAINTENANCE** changes are "just-in-time" changes or small enhancements which _should_ not affect the documentation and _must_ not break the API. @@ -129,15 +129,16 @@ complete documentation. - 15.10 - Date based release - 23 - Serial release -(More information: [https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#choosing-a-versioning-scheme](https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#choosing-a-versioning-scheme) & +(More +information: [https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#choosing-a-versioning-scheme](https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#choosing-a-versioning-scheme) & [https://peps.python.org/pep-0440/#public-version-identifiers](https://peps.python.org/pep-0440/#public-version-identifiers)) ### Configuration file rules - - No inline comments so every available character can be used in values - - Values can be overridden in each monitor - - File names in etc/* are not important but section names and key names. - - Comments can be inserted using ';' or '#' +- No inline comments so every available character can be used in values +- Values can be overridden in each monitor +- File names in etc/* are not important but section names and key names. +- Comments can be inserted using ';' or '#' ## FAQ @@ -149,27 +150,27 @@ monitoring a small amount of services for some years. ### Should I try the old version of Linspector? -I recommend not to use the old version of Linspector because the new version will +I recommend not to use the old version of Linspector because the new version will in no way become backward compatible. Features of the old version will nearly all be -implemented in the new version so if you can wait a little then I recommend to wait +implemented in the new version so if you can wait a little then I recommend to wait until I release the new version of Linspector. ### Can I use an old configuration of Linspector in the new version? -No! The new configuration does not use JSON files anymore but an INI file syntax based on +No! The new configuration does not use JSON files anymore but an INI file syntax based on a directory tree. ### Why should I use Linspecter even there are other mature and stable tools available already? -Linpector aims to be very small and simple and even should work in home or small +Linpector aims to be very small and simple and even should work in home or small environments. But Linspector also is useful in very large infrastructures for monitoring thousands of devices and services. ### Can I run multiple instances of the Linspector daemon? -Yes, of course. Since you add a configuration path when running Linspector you can +Yes, of course. Since you add a configuration path when running Linspector you can just pass a different path to a configuration tree to each instance. And since you -can configure the PID file in each configuration you can even can start, stop or +can configure the PID file in each configuration you can even can start, stop or restart each instance in a native way. ## License diff --git a/bin/linspector b/bin/linspector index 3f5b7fe..c421e56 100755 --- a/bin/linspector +++ b/bin/linspector @@ -12,11 +12,10 @@ import sys from linspector.core.configuration import Configuration from linspector.core.environment import Environment -from linspector.core.logger import Log from linspector.core.linspector import Linspector +from linspector.core.logger import Log from linspector.core.monitors import Monitors - # i currently only increase the 3rd number because the goal is that 0.19.* will become the first # stable version. __version__ = '0.19.62.dev1' @@ -79,7 +78,7 @@ def main(): try: linspector = Linspector(configuration, environment, log, monitors, plugins, scheduler) - #linspector.print_debug() + # linspector.print_debug() except Exception as err: log.critical('[linspector] core initialization error: {0}'.format(err)) sys.exit(1) diff --git a/bin/lish b/bin/lish index fccacfe..1bd50fa 100755 --- a/bin/lish +++ b/bin/lish @@ -14,9 +14,10 @@ import logging.handlers import os import sys +from linspector.core.helpers import log + from linspector.core.configuration import Configuration from linspector.core.environment import Environment -from linspector.core.helpers import log from linspector.core.linspector import Linspector from linspector.core.monitors import Monitors @@ -127,7 +128,7 @@ def main(): logger.setLevel(logging.INFO) elif log_level == "debug": logger.setLevel(logging.DEBUG) - #elif configuration.get_option('linspector', 'log_level') != 'error' != 'warning' \ + # elif configuration.get_option('linspector', 'log_level') != 'error' != 'warning' \ # != 'info' != 'debug': # logger.warning('[linspector] log level: "' + log_level + '" not found!') @@ -138,7 +139,7 @@ def main(): try: linspector = Linspector(configuration, environment, log, monitors, plugins, scheduler) - #linspector.print_debug() + # linspector.print_debug() except Exception as err: log('critical', '[linspector] core initialization error: {0}'.format(err)) sys.exit(1) diff --git a/etc/linspector.conf b/etc/linspector.conf index 5809e17..7323983 100644 --- a/etc/linspector.conf +++ b/etc/linspector.conf @@ -3,7 +3,7 @@ ; report core errors to the following users error_receivers = admin@example.com ; available log levels are: "error", "warning", "info" and "debug". if no log_level is set, it will be critical only. -log_level= debug +log_level = debug ;log_file = ~/code/linspector/linspector/log/linspector.log ; number of log files to be kept. i recommend to use the lowest sensible value for keeping performance high. so set ; the size of the log file higher to increase the log history. diff --git a/etc/plugins/httpserver.conf b/etc/plugins/httpserver.conf index ea8f0b9..e3beeae 100644 --- a/etc/plugins/httpserver.conf +++ b/etc/plugins/httpserver.conf @@ -1,4 +1,4 @@ [httpserver] ip = 127.0.0.1 port = 4242 -type=thread \ No newline at end of file +type = thread \ No newline at end of file diff --git a/etc/plugins/lish.conf b/etc/plugins/lish.conf index a40fd32..4a8778c 100644 --- a/etc/plugins/lish.conf +++ b/etc/plugins/lish.conf @@ -1,2 +1,2 @@ [lish] -type=none \ No newline at end of file +type = none \ No newline at end of file diff --git a/files/images/inspector-hat.svg b/files/images/inspector-hat.svg index c5117fe..9b4ef25 100644 --- a/files/images/inspector-hat.svg +++ b/files/images/inspector-hat.svg @@ -1,115 +1,158 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - inspector hat - Sept 2009 - - - Franziska Sponsel - - - - - Franziska Sponsel - - - - - RRZE - - - - - inspector - hat - - - - - Beate Kaspar, Hendrik Eggers, Florian Löffler - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + inspector hat + Sept 2009 + + + Franziska Sponsel + + + + + Franziska Sponsel + + + + + RRZE + + + + + inspector + hat + + + + + Beate Kaspar, Hendrik Eggers, Florian Löffler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/files/images/linspector-logo.svg b/files/images/linspector-logo.svg index 9f5edea..72b329e 100644 --- a/files/images/linspector-logo.svg +++ b/files/images/linspector-logo.svg @@ -2,4676 +2,4675 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + inkscape:export-filename="/home/hanez/www/linspector.org/htdocs/logo.png" + inkscape:export-xdpi="48.80434" + inkscape:export-ydpi="48.80434" + sodipodi:docname="New document 1"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + - - - - + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> - - + id="g8646" + transform="translate(266.12905,262.18779)"> + id="path6876" + transform="matrix(0.567073,0,0,1,136.434,-7.56328)" + d="m 348.91882,352.44836 a 165.38348,46.892272 0 1 1 -330.766965,0 165.38348,46.892272 0 1 1 330.766965,0 z" + style="color:#000000;fill:url(#radialGradient9536);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + inkscape:connector-curvature="0"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="path6878" + transform="matrix(0.582317,0,0,1,-8.55325,-8.06749)" + d="m 348.91882,352.44836 a 165.38348,46.892272 0 1 1 -330.766965,0 165.38348,46.892272 0 1 1 330.766965,0 z" + style="color:#000000;fill:url(#r1);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible" + inkscape:connector-curvature="0"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + inkscape:label="Layer 1" + id="layer1-2" + transform="matrix(0.24590166,0,0,0.24590166,354.26256,144.05795)"> + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/files/images/tux.svg b/files/images/tux.svg index 5794d0d..5f3fe51 100644 --- a/files/images/tux.svg +++ b/files/images/tux.svg @@ -1,1015 +1,1768 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file diff --git a/linspector/core/configuration.py b/linspector/core/configuration.py index 17656f2..e6cb83d 100644 --- a/linspector/core/configuration.py +++ b/linspector/core/configuration.py @@ -15,7 +15,7 @@ class Configuration: self.__configuration = configparser.ConfigParser() self.__configuration_path = configuration_path - #print('[linspector] reading configuration file: ' + configuration_path + + # print('[linspector] reading configuration file: ' + configuration_path + # '/linspector.conf') if os.path.isfile(configuration_path + '/linspector.conf'): try: @@ -35,7 +35,7 @@ class Configuration: section_list = glob.glob(configuration_path + '/' + target_section + '/*.conf') for section_file in section_list: - #print('reading section file: ' + section_file) + # print('reading section file: ' + section_file) configuration = configparser.ConfigParser() configuration.read(section_file, 'utf-8') for source_section in configuration.sections(): @@ -46,7 +46,7 @@ class Configuration: configuration.get(source_section, source_section_option)) - #print('configuration dump: ' + self.dump_to_ini()) + # print('configuration dump: ' + self.dump_to_ini()) def dump_to_ini(self): dump = '' diff --git a/linspector/core/linspector.py b/linspector/core/linspector.py index 34ee785..a1cf3c2 100644 --- a/linspector/core/linspector.py +++ b/linspector/core/linspector.py @@ -7,9 +7,9 @@ import datetime import importlib import random -from apscheduler.schedulers.background import BackgroundScheduler -from apscheduler.jobstores.memory import MemoryJobStore from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor +from apscheduler.jobstores.memory import MemoryJobStore +from apscheduler.schedulers.background import BackgroundScheduler def job_function(log, monitor): diff --git a/linspector/core/logger.py b/linspector/core/logger.py index 63e9126..656922f 100644 --- a/linspector/core/logger.py +++ b/linspector/core/logger.py @@ -102,7 +102,7 @@ class Log: self.set_level(logging.INFO) elif log_level == "debug": self.set_level(logging.DEBUG) - #elif configuration.get_option('linspector', 'log_level') != 'error' != 'warning' \ + # elif configuration.get_option('linspector', 'log_level') != 'error' != 'warning' \ # != 'info' != 'debug': # logger.warning('[linspector] log level: "' + log_level + '" not found!') diff --git a/linspector/core/monitor.py b/linspector/core/monitor.py index e51db73..e38c15f 100644 --- a/linspector/core/monitor.py +++ b/linspector/core/monitor.py @@ -6,11 +6,8 @@ See LICENSE.txt (MIT license). import configparser import hashlib import importlib - -from datetime import datetime from binascii import crc32 - -from linspector.core.task import Task, TaskExecutor +from datetime import datetime class Monitor: @@ -33,7 +30,8 @@ class Monitor: 'identifier: ' + identifier + ' to: ' + str(self.__interval)) except Exception as err: log.warning('no default_interval found in core configuration for identifier ' + - identifier + ', set to default interval 300 seconds. error: ' + str(err)) + identifier + ', set to default interval 300 seconds. error: ' + str( + err)) # default interval is 300 seconds (5 minutes) if not set in the monitor # configuration args or a default_interval in the core configuration. self.__interval = 300 @@ -48,10 +46,10 @@ class Monitor: # if no service is set in the monitor configuration, the service is set to misc.dummy # instead. just to make Linspector run but with no real result. log.debug('no service set for identifier: ' + identifier + ' setting to ' - 'misc.dummy as ' - 'default to ensure ' - 'Linspector will run. ' - 'error: ' + str(err)) + 'misc.dummy as ' + 'default to ensure ' + 'Linspector will run. ' + 'error: ' + str(err)) self.__service = 'misc.dummy' @@ -83,7 +81,7 @@ class Monitor: """ self.status = "NONE" self.last_execution = None - #self.monitor_information = MonitorInformation(self.monitor_id, self.hostgroup, self.host, + # self.monitor_information = MonitorInformation(self.monitor_id, self.hostgroup, self.host, # self.service) self.monitor_information = MonitorInformation(self.monitor_id, self.service) @@ -175,7 +173,7 @@ class Monitor: def hex_string(self): ret = hex(crc32(bytes(self.host + self.hostgroups + self.service, 'utf-8'))) - #ret = self.__hex__() + # ret = self.__hex__() if ret[0] == "-": ret = ret[3:] else: @@ -198,10 +196,10 @@ class Monitor: if execution_successful: if self.job_threshold > 0: if "threshold_reset" in self.core and self.core["threshold_reset"]: - #logger.info("Job " + self.get_monitor_id() + ", Threshold Reset") + # logger.info("Job " + self.get_monitor_id() + ", Threshold Reset") self.job_threshold = 0 else: - #logger.info("Job " + self.get_monitor_id() + ", Threshold Decrement") + # logger.info("Job " + self.get_monitor_id() + ", Threshold Decrement") self.job_threshold -= 1 self.status = "OK" @@ -214,7 +212,7 @@ class Monitor: self.job_threshold += 1 if self.job_threshold >= service_threshold: - #logger.info("Job " + self.get_monitor_id() + ", Threshold reached!") + # logger.info("Job " + self.get_monitor_id() + ", Threshold reached!") self.status = "ERROR" self.monitor_information.set_status(self.status) @@ -224,34 +222,34 @@ class Monitor: self.__log.debug('executing task of type: ' + self.status) # tasks can but should not be executed here. putting them in a queue is the better # solution to execute them in a serial process. - #TaskExecutor.instance().schedule_task(monitor_information, task) + # TaskExecutor.instance().schedule_task(monitor_information, task) def handle_call(self): self.__log.info('handle call to monitor with identifier: ' + self.__identifier) - #logger.debug("handle call") - #logger.debug(self.service) + # logger.debug("handle call") + # logger.debug(self.service) if self.enabled: self.last_execution = None try: self.last_execution = MonitorExecution(self.get_host()) - #self.__services[self.__service].execute(self.last_execution) + # self.__services[self.__service].execute(self.last_execution) self.__services[self.__service].execute(**self.__args) except Exception as err: self.__log.error(err) - #self.last_execution.set_execution_end() + # self.last_execution.set_execution_end() - #self.handle_threshold(self.service.get_threshold(), + # self.handle_threshold(self.service.get_threshold(), # self.last_execution.was_successful()) - #log.info("Job " + self.get_monitor_id() + + # log.info("Job " + self.get_monitor_id() + # ", Code: " + str(self.last_execution.get_error_code()) + # ", Message: " + str(self.last_execution.get_message())) - #self.monitor_information.set_response_message( + # self.monitor_information.set_response_message( # self.last_execution.get_response_message(self)) - #self.handle_tasks(self.monitor_information) + # self.handle_tasks(self.monitor_information) else: self.__log.info('job ' + self.get_monitor_id() + ' disabled') @@ -308,8 +306,8 @@ class MonitorExecution: class MonitorInformation: def __init__(self, monitor_id, service): self.monitor_id = monitor_id - #self.hostgroup = hostgroup - #self.host = host + # self.hostgroup = hostgroup + # self.host = host self.service = service self.response_massage = None diff --git a/linspector/core/singleton.py b/linspector/core/singleton.py index a84003c..62538a0 100644 --- a/linspector/core/singleton.py +++ b/linspector/core/singleton.py @@ -4,7 +4,8 @@ Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ -#see http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern + +# see http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern class Singleton: diff --git a/linspector/core/task.py b/linspector/core/task.py index 259b504..246b3e3 100644 --- a/linspector/core/task.py +++ b/linspector/core/task.py @@ -4,7 +4,7 @@ Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ from queue import Queue -from threading import Event, Thread +from threading import Thread from linspector.core.singleton import Singleton @@ -47,7 +47,7 @@ class Task: def get_arguments(self): return self._args - #def set_member(self, member): + # def set_member(self, member): # self.member = member def needs_arguments(self): @@ -57,7 +57,7 @@ class Task: try: self.execute(job) except Exception as e: - #logger.debug("Task execute failed!!!") + # logger.debug("Task execute failed!!!") raise e @@ -85,7 +85,7 @@ class TaskExecutor: msg, task = self.queue.get() if task: self.__log.debug('starting task execution...') - #task.execute(msg) + # task.execute(msg) self.queue.task_done() except Exception as err: diff --git a/linspector/notifications/sms.py b/linspector/notifications/sms.py index 8bd0215..f78838f 100644 --- a/linspector/notifications/sms.py +++ b/linspector/notifications/sms.py @@ -3,7 +3,6 @@ This file is part of Linspector (https://linspector.org/) Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ -import gammu from linspector.core.notification import Notification diff --git a/linspector/notifications/xmpp.py b/linspector/notifications/xmpp.py index 3fd24fa..7950ef2 100644 --- a/linspector/notifications/xmpp.py +++ b/linspector/notifications/xmpp.py @@ -3,7 +3,6 @@ This file is part of Linspector (https://linspector.org/) Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ -import xmpp from linspector.core.notification import Notification diff --git a/linspector/plugins/api.py b/linspector/plugins/api.py new file mode 100644 index 0000000..a94edd6 --- /dev/null +++ b/linspector/plugins/api.py @@ -0,0 +1,26 @@ +""" +This file is part of Linspector (https://linspector.org/) +Copyright (c) 2023 Johannes Findeisen . All Rights Reserved. +See LICENSE.txt (MIT license). +""" +# TODO: Make this a backend API using the modern FastAPI framework as a replacement for the +# traditional RPC plugin. Maybe it makes sense to maintain the RPC plugin too for simple usage by +# the Lish but I believe it makes sense to only create one backend for all clients. +from linspector.core.plugin import Plugin + + +def create(configuration, environment, linspector, log): + return APIPlugin(configuration, environment, linspector, log) + + +# TODO: check for all required configuration options and set defaults if needed. +class APIPlugin(Plugin): + def __init__(self, configuration, environment, linspector, log): + super().__init__(configuration, environment, linspector, log) + self.__configuration = configuration + self.__environment = environment + self.__linspector = linspector + self.__log = log + + def run(self): + return diff --git a/linspector/plugins/backendapi.py b/linspector/plugins/backendapi.py deleted file mode 100644 index 4516700..0000000 --- a/linspector/plugins/backendapi.py +++ /dev/null @@ -1,8 +0,0 @@ -""" -This file is part of Linspector (https://linspector.org/) -Copyright (c) 2023 Johannes Findeisen . All Rights Reserved. -See LICENSE.txt (MIT license). -""" -# TODO: Make this a backend API using the modern FastAPI framework as a replacement for the -# traditional RPC plugin. Maybe it makes sense to maintain the RPC plugin too for simple usage by -# the Lish but I believe it makes sense to only create one backend for all clients. \ No newline at end of file diff --git a/linspector/plugins/httpserver.py b/linspector/plugins/httpserver.py index a58d176..1f2b686 100644 --- a/linspector/plugins/httpserver.py +++ b/linspector/plugins/httpserver.py @@ -3,9 +3,10 @@ This file is part of Linspector (https://linspector.org/) Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ -import cherrypy import json +import cherrypy + from linspector.core.plugin import Plugin @@ -29,22 +30,22 @@ class HTTPServerPlugin(Plugin): @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) + \
-               '
' + 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) + \
-               '
' + 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): @@ -73,11 +74,11 @@ class HTTPServerPlugin(Plugin): # 'tools.staticdir.dir': './public' } } - #cherrypy.config.update({ + # cherrypy.config.update({ # 'global': { # 'engine.autoreload.on': False # } - #}) + # }) cherrypy.config.update({ 'global': { 'server.socket_host': self.__configuration.get_httpserver_host(), @@ -87,4 +88,4 @@ class HTTPServerPlugin(Plugin): }) cherrypy.tree.mount(root=None, config=conf) cherrypy.quickstart(self, '/', conf) - #cherrypy.server.bus.exit(self) + # cherrypy.server.bus.exit(self) diff --git a/linspector/services/misc/dummy.py b/linspector/services/misc/dummy.py index a47e76a..3150cb9 100644 --- a/linspector/services/misc/dummy.py +++ b/linspector/services/misc/dummy.py @@ -19,5 +19,5 @@ class DummyService(Service): def execute(self, **kwargs): self.__log.debug('DummyService object ' + str(self) + ' using kwargs: ' + str(kwargs)) - #log('debug', 'dummy object @' + str(self) + str(self.__kwargs['foo'])) + # log('debug', 'dummy object @' + str(self) + str(self.__kwargs['foo'])) return diff --git a/linspector/services/net/fritzboxphonestatus.py b/linspector/services/net/fritzboxphonestatus.py index baa5629..8c5b71c 100644 --- a/linspector/services/net/fritzboxphonestatus.py +++ b/linspector/services/net/fritzboxphonestatus.py @@ -3,7 +3,6 @@ This file is part of Linspector (https://linspector.org/) Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ -from fritzconnection.lib.fritzstatus import FritzStatus from linspector.core.service import Service diff --git a/linspector/services/net/fritzboxuplink.py b/linspector/services/net/fritzboxuplink.py index 29b0916..97fd707 100644 --- a/linspector/services/net/fritzboxuplink.py +++ b/linspector/services/net/fritzboxuplink.py @@ -3,7 +3,6 @@ This file is part of Linspector (https://linspector.org/) Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ -from fritzconnection.lib.fritzstatus import FritzStatus from linspector.core.service import Service diff --git a/linspector/services/net/speedtest.py b/linspector/services/net/speedtest.py index a8dc64c..834a26e 100644 --- a/linspector/services/net/speedtest.py +++ b/linspector/services/net/speedtest.py @@ -4,9 +4,10 @@ Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ import calendar -import requests import time +import requests + from linspector.core.service import Service diff --git a/linspector/services/net/ssh.py b/linspector/services/net/ssh.py index 51eee74..522590e 100644 --- a/linspector/services/net/ssh.py +++ b/linspector/services/net/ssh.py @@ -4,9 +4,10 @@ Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ import os -import paramiko import pprint +import paramiko + from linspector.core.service import Service @@ -31,9 +32,8 @@ class SSHService(Service): client.connect('hanez.org', username='hanez') - #self.command.call() ist dann das: + # self.command.call() ist dann das: stdin, stdout, stderr = client.exec_command('ls') for line in stdout: print('... ' + line.strip('\n')) client.close() - diff --git a/linspector/services/snmp/get.py b/linspector/services/snmp/get.py index e104544..ed7fbdc 100644 --- a/linspector/services/snmp/get.py +++ b/linspector/services/snmp/get.py @@ -3,7 +3,6 @@ This file is part of Linspector (https://linspector.org/) Copyright (c) 2022 Johannes Findeisen . All Rights Reserved. See LICENSE.txt (MIT license). """ -from pysnmp.entity.rfc3413.oneliner import cmdgen from linspector.core.service import Service