Skip to main content

Minimal monitoring package

Project description

NyxMon

A monitoring application for services and health checks.

Setup for Development

  1. Install Python (3.12 or higher)
uv python install
  1. Create a virtual environment:
uv venv
  1. Install dependencies and local packages in editable mode:
uv sync
  1. Install pre-commit hooks:
uvx pre-commit install
  1. Run tests:
uv run pytest
  1. Run static analysis:
uv run mypy src/

Usage

Run Database Migrations

Before running the application, make sure to run the database migrations:

uv run src/django/manage.py migrate

This will create an SQLite database file in the project root directory.

Starting the monitoring agent and Django dashboard

At the moment, there's only the development version of the monitoring agent and a Django dashboard. You can start both of them using honcho:

uvx honcho start

This will start the monitoring agent and the Django dashboard in separate processes. You can add services and health checks through the Django dashboard.

Creating development data

For development and testing purposes, you can quickly generate sample services and checks using the create_devdata management command:

uv run src/django/manage.py create_devdata

This command creates:

If you already have data and want to add the development data anyway, use the --force flag:

uv run src/django/manage.py create_devdata --force

The checks run every 60 seconds, so after starting the monitoring agent, you'll see results within a minute.

The start-agent command

The monitoring agent registers an entrypoint named start-agent in the pyproject.toml file.

uv run start-agent --db /path/to/database.sqlite

Options:

  • --db: Path to SQLite database file (required)
  • --interval: Check interval in seconds (default: 5)
  • --log-level: Set the logging level (default: INFO)
  • --enable-telegram: Enable Telegram notifications

Running the Django dashboard

PYTHONUNBUFFERED=true uv run src/django/manage.py runserver 0.0.0.0:8000

Notifications

Telegram Notifications

To enable Telegram notifications:

  1. Create a Telegram bot using BotFather and get the token
  2. Find your chat ID (you can use the userinfobot)
  3. Set environment variables:
    export TELEGRAM_BOT_TOKEN=your_bot_token
    export TELEGRAM_CHAT_ID=your_chat_id
    
    Or set them in your .env file. They'll get loaded automatically by honcho.

Creating a Custom Notifier

You can create a custom notifier by implementing the Notifier interface:

from nyxmon.adapters.notification import Notifier

class CustomNotifier(Notifier):
    def notify_check_failed(self, check, result):
        # Implement your notification logic
        pass
        
    def notify_service_status_changed(self, service, status):
        # Implement your notification logic
        pass

# In your setup code (modify bootstrap.py or cli.py):
my_notifier = CustomNotifier()
bus = bootstrap(notifier=my_notifier)

Deployment

The choice of sqlite as a database backend was deliberate. How to monitor a database going down, when you depend on the database to monitor?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nyxmon-0.1.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nyxmon-0.1.0-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file nyxmon-0.1.0.tar.gz.

File metadata

  • Download URL: nyxmon-0.1.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.5

File hashes

Hashes for nyxmon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba2dddb4b76420eb8bf27727189554723fd1fcbf4e49eb95cb369045e0e03dce
MD5 61bc1076b2bd38de849b9d5a20ae2141
BLAKE2b-256 d4f4bd97182411d2d09e52cc91ce0814386720012c51b26f0b0b7506c922d39f

See more details on using hashes here.

File details

Details for the file nyxmon-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nyxmon-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.5

File hashes

Hashes for nyxmon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93e4846c6cf7cdf9dbe121149bc914b699f6f9a93df487f3aebe359d3bbe3d71
MD5 3adfc971dc6bc4a0319943b6b1e4a319
BLAKE2b-256 4beeaa3347142fe08f0085967fac4f122ebd9add8fd7ed02c1b54d347ae79f5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page