Package: fastchecks
🚥 Fast website monitoring backend serviceFeatures🍀 Feature-richEach check tracks:timestampresponse timeHTTP response status codeoptionally, given regex is (safely) tested if it matches the response body or notinfo about possible connection errors, like timeouts and/or unreachable hostWebsites to check & their results are stored in postgres by default 🐘 (the library is ready for other data stores / sockets).You can use postgres locally installed, running on docker, or with a DBaaS, e.g. Aiven.Monitor stored websites once, at configurable-scheduled intervals (each website check can use an independent interval or use a default), or even with your system's cron.The scheduling keeps running even if the computer goes to sleep.Nice, configurable logging.CLI API & Python's (Python >= 3.11).Awebserveris planned....and more!🚀 SpeedAll operations are asynchronous. This app sits on 3 giants:aiohttppsycopg (v3)APScheduler (v4)Written inPython 3.11 for maximum speed🐍Speedy regex checking thanks togoogle-re2 regex. Note thatgoogle-re2 syntaxis very similar to python's nativerebut not equal. In particular, backreferences are not supported, to gain on speed andsafety.No ORM libraries. Just good old (safely-escaped) SQL queries.🧘SafetyBinary or too big responses will not be read.Safe regex thanks togoogle-re2 regex.Safe escaping of SQL queries withpsycopg.Security static analysis withbandit,snyk, andGitHub CodeQL.Code is fullytype-annotatedand type-checked with mypy.Further type checking with Pydantic (v2).Further static analysis with pyflakes.InstallVia pip# You need to run this with a Python 3.11 environment -- You can manage different python versions for instance with `pyenv`pipinstall-Ufastchecksor via sourceYou need to havepython poetryinstalled. Then:# clone this repository_reponame="fastchecks";_branch="main";gitclone-b"${_branch}""https://github.com/juanmirocks/${_reponame}";cd${_reponame}# Install projectpoetryinstall# Enter into the project's shell environment for simplicity with the running commandspoetryshellRunCreate a postgres DB and take note of its postgres URL conninfo. NOTE: this app was tested with Postgres v15 only; some older versions should work too.For instance, if you have a local postgres installation:_dbname="fastchecks";createdb"${_dbname}"# Its postgres URL (assuming default user) will be:# postgres://localhost/fastchecks# Then you need to pass the conninfo to the CLI,# * either with the explicit optional parameter `--pg_conninfo`, or# * by setting the envar: `FC_POSTGRES_CONNINFO`# For simplicity, commands below assume you've set `FC_POSTGRES_CONNINFO`, e.g.:exportFC_POSTGRES_CONNINFO='postgres://localhost/fastchecks'Add some website URLs to later check for:fastchecksupsert_check'https://example.org'# Add a simple URL checkfastchecksupsert_check'https://example.org'--regex'Example D[a-z]+'# Update the URL check to match the response body with a regexfastchecksupsert_check'https://python.org'--interval5# Add another URL check with a specific interval (in seconds)Run the checks at the scheduled intervals in the foreground until stopped.fastcheckscheck_all_loop_fg# checks without interval will run with a default (configurable; see command help)That's it! You might want to explore further options:For all possibilities, run:fastchecks -hFor instance, might you want to run all checks only once (e.g. to schedule with cron), run:fastchecks check_all_onceOr run a single website check once (without registering it):fastchecks check_website 'https://www.postgresql.org/'Copyright / LicenseCopyright 2023 Dr. Juan Miguel CejuelaSPDX-License-Identifier: Apache-2.0See files:LICENSE&NOTICE.