Skip to main content

A simple application to monitor the health of multiple applications and send notifications to Discord.

Project description

Pynitor

Pynitor is a simple Python application to monitor the health of multiple applications and send notifications to a Discord channel if any of them become unhealthy. It supports specifying individual webhooks for each application to allow for targeted notifications.

Installation

First, clone the repository and navigate into the directory:

git clone https://github.com/na0495/pynitor.git
cd pynitor

Then, install the package:

pip install .

Usage

After installation, you can run the monitor using the command:

pynitor

Configuration

The configuration is defined in app/config.py. This file contains a list of applications to monitor, along with their health check URLs and optional webhook URLs for notifications. Here's a breakdown of the configuration options:

  • APPLICATIONS: A list of dictionaries where each dictionary represents an application to monitor. Each dictionary can have:

    • name: A name for the application (used in notifications).
    • url: The health check URL for the application.
    • webhook_url (optional): The Discord webhook URL for notifications specific to this application.
  • DEFAULT_WEBHOOK_URL: The default webhook URL to use if an application doesn't specify its own webhook.

  • CHECK_INTERVAL: How often (in seconds) to check the health of the applications.

Example Configuration

In app/config.py, you can define your applications like this:

APPLICATIONS = [
    {
        "name": "App1",
        "url": "https://yourapp1.com/health/",
        "webhook_url": "https://discord.com/api/webhooks/your-webhook-id-1"
    },
    {
        "name": "App2",
        "url": "https://yourapp2.com/health/",
        "webhook_url": "https://discord.com/api/webhooks/your-webhook-id-2"
    },
    # Add more applications as needed
]

# Default webhook URL if none is specified for an application
DEFAULT_WEBHOOK_URL = "https://discord.com/api/webhooks/default-webhook-id"

CHECK_INTERVAL = 300  # Check interval in seconds (e.g., 300 seconds = 5 minutes)

Adding Applications

To monitor more applications, simply add them to the APPLICATIONS list in app/config.py. Each application can have its own webhook_url. If no webhook_url is provided, the DEFAULT_WEBHOOK_URL will be used.

Deployment

  • Running Periodically: To run pynitor periodically, you can set up a cron job (Linux/macOS) or use Task Scheduler (Windows). For example, to run the script every 5 minutes, add this to your crontab:
    */5 * * * * /path/to/python /path/to/pynitor
    
    Replace /path/to/python with the path to the Python executable and /path/to/pynitor with the path to the pynitor command.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing

If you want to contribute to this project, feel free to create a pull request or open an issue in the GitHub repository.

Author

Saad Mrabet
Email: saad.mrabet@kubicbits.com

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

pynitor-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

pynitor-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynitor-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pynitor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e0911789904266705321fee65f9ca20d295f01d55d72c4bcc2d4664891578a5f
MD5 e6c6796fb423d359eefda0d74bdb230d
BLAKE2b-256 7ebf1e30699932ab374b29bddb0ad84eae886f8e01a4187879dd362d50d86396

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynitor-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pynitor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c96541192fe48fa596a399982d59a8cdb6235a06de0bb465531d5f577f47ec32
MD5 cb7b3485292db208a7b9ca569a845f4c
BLAKE2b-256 a811497b3e44357d0a2faf782413c80355df358c2f854dd3475ac5f8b9147475

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