🚥 Fast website monitoring backend service
Project description
🚥 Fast website monitoring backend service
Features
🍀 Feature-rich
- Websites 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.
- Run stored all websites once, at configurable-scheduled intervals, or even with your system's cron.
- The scheduling keeps running even if the computer goes to sleep!
- CLI API (with
argparse
) & Python's (Python >= 3.11).- A webserver is planned.
- ...and more!
🚀 Speed
- All operations are asynchronous. This app sits on 3 giants:
- aiohttp
- psycopg (v3)
- APScheduler (v4)
- Written in Python 3.11 for maximum speed 🐍
- Speedy regex checking thanks to google-re2 regex. Note that google-re2 syntax is very similar to python's native
re
but not equal. In particular, backreferences are not supported, to gain on speed and safety. - No ORM libraries. Just good old (safely-escaped) SQL queries.
🧘 Safety
- Binary or too big responses will not be read.
- Safe regex thanks to google-re2 regex.
- Safe escaping of SQL queries with psycopg.
- Security static analysis with bandit, snyk, and GitHub CodeQL.
- Code is fully type-annotated and type-checked with mypy.
- Further type checking with Pydantic (v2).
- Further static analysis with pyflakes.
Install
From source
You need to have python poetry installed. Then:
# clone this repository
_reponame="fastchecks";
_branch="main";
git clone -b "${_branch}" "https://github.com/juanmirocks/${_reponame}";
cd ${_reponame}
# Install project
poetry install
# Enter into the project's shell environment for simplicity with the running commands
poetry shell
Run
-
Create 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.: export FC_POSTGRES_CONNINFO='postgres://localhost/fastchecks'
-
Add some website URL checks info (to do check later)
python -m fastchecks.cli upsert_check 'https://example.org' # Add a simple URL check python -m fastchecks.cli upsert_check 'https://example.org' --regex 'Example D[a-z]+' # Update the URL check to match the response body with a regex python -m fastchecks.cli upsert_check 'https://python.org' --interval 5 # Add another URL check with a specific interval (in seconds)
-
Run the checks at the scheduled intervals in the foreground until stopped.
python -m fastchecks.cli check_all_loop_fg # checks without interval will run with a default (configurable by the envar: `FC_DEFAULT_CHECK_INTERVAL_SECONDS`)
-
That's it! You might want to explore further options:
- For all possibilities, run:
python -m fastchecks.cli -h
- For instance, might you want to run all checks only once (e.g. to schedule with cron), run:
python -m fastchecks.cli check_all_once
- Or run a single website check once (without registering it):
python -m fastchecks.cli check_website 'https://www.postgresql.org/'
- For all possibilities, run:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastchecks-0.1.0rc5.tar.gz
(20.2 kB
view hashes)
Built Distribution
Close
Hashes for fastchecks-0.1.0rc5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeddbfb63e598846fa1650144633ac356792d8aab83c7275af55d841472ca4ca |
|
MD5 | 1e52e300a458dc8e59c90ef130582936 |
|
BLAKE2b-256 | 8f570c48ca76a8e6d6b9e42e23f06f2ebfd8b23b8b3abcd3fb93c573893b35e6 |