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.4.tar.gz (49.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.4-py3-none-any.whl (78.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nyxmon-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4caa024ed47fc3039328e5da9e775fbc9a0147575cdd1621ccd8c79503c3ad66
MD5 2576880147e1c18dd0874da0e696a7d1
BLAKE2b-256 177f4136aeced734c37b6eac0f41902a51cf340a5b3c56c20f870630ed52d66e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for nyxmon-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c56b67f4953ee27cf634f40827d6835102db1469477ba56f63d26b76d86fd1a2
MD5 0ea949c717cac25a429cb7a3a3daf3e1
BLAKE2b-256 9895c726c740a2b546380e43bb501fc8e8627ba97c027ca0e62016766380c8be

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