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.

Build the package

The build backend has to be hatchling to allow for multiple top level packages (nyxmon and nyxboard). To build the package, run:

uv build --sdist --wheel

And then publish the package:

uv publish --token pypi-your-token

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.3.tar.gz (49.2 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.3-py3-none-any.whl (78.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nyxmon-0.1.3.tar.gz
Algorithm Hash digest
SHA256 822a519eb31ccdf3f42a2e50376108bc00d485a2e0a5ae86ef9f07f502b4fd7f
MD5 89b668d0d986264b69bdb4bda3698901
BLAKE2b-256 cef2ab7726835d7dd5dda0c9f7bf9fc6014a8ac8475d1e168d5be5380f9e0473

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for nyxmon-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 817d1e2acfc9ff8c7a41d856f47dc57396124d9d7f91b8dd5f4408bde52171d5
MD5 780f6cea4e942c72d381a47f507b259a
BLAKE2b-256 aae83df7ea0ec879f9411a6ec7572f12cbfe9b651aac51a519737de03156a22b

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