Skip to main content

Minimal monitoring package

Project description

NyxMon

A monitoring application for services and health checks.

Documentation

Full documentation is available at nyxmon.readthedocs.io

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nyxmon-0.1.7.tar.gz
Algorithm Hash digest
SHA256 0fb165befd9ed8124e3272a05b416af5c87728298b06f840203a0e229e8330b5
MD5 066c6fa9bc6c8aed306858ede7600f7b
BLAKE2b-256 9421f8b7363a62b10bdb990bb410c708b5dabcf485ca5a4eced06c8653fd7edf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for nyxmon-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 126dd20016e35748528618ab841efd605b4f81a2bdb91736c778555c45da319f
MD5 82068c8e2e6f4e6cf6eaa9677cbe04cd
BLAKE2b-256 f89095cdb5959ff7253ba455c931e55b1118bf8dfe80277bee21437a609672d7

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