Skip to content

This Python script monitors the availability of specified web hosts. It checks the status of URLs and sends notifications through various messaging services if any host is unreachable or returns an error. Support Telegram, Discord, Gotify, Ntfy, Pushbullet, Pushover, Slack, Matrix, Mattermost, Rocket.chat

Notifications You must be signed in to change notification settings

2boom-ua/web_check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Host Monitoring Script

Overview

This Python script monitors the availability of specified web hosts. It checks the status of URLs and sends notifications through various messaging services if any host is unreachable or returns an error.

Features

  • Web Host Monitoring: Regularly checks if specified URLs are accessible.
  • Real-time notifications with support for multiple accounts via:
    • Telegram
    • Discord
    • Slack
    • Gotify
    • Ntfy
    • Pushbullet
    • Pushover
    • Rocket.chat
    • Matrix
    • Mattermost
  • Dynamic Configuration: Load URLs and settings from JSON files.
  • Polling Period: Adjustable interval for checking host availability.

Requirements

  • Python 3.x
  • Docker installed and running
  • Dependencies: requests, schedule

Clone the repository:

git clone https://github.com/2boom-ua/web_check.git
cd web_check

Install required Python packages:

pip install -r requirements.txt

Edit config.json:

A config.json file in the same directory as the script, and include your API tokens and configuration settings.

{
    "TELEGRAM": {
        "ON": true,
        "TOKENS": [
            "first tocken",
            "second tocken",
            "...."
        ],
        "CHAT_IDS": [
            "first chat_id",
            "second chat_id",
            "...."
        ]
    },
    "DISCORD": {
        "ON": false,
        "WEBHOOK_URLS": [
            "first url",
            "second url",
            "...."
        ]
    },
    "SLACK": {
        "ON": false,
        "TOKENS": [
            "first tocken",
            "second tocken",
            "...."
        ]
    },
    "GOTIFY": {
        "ON": false,
        "TOKENS": [
            "first tocken",
            "second tocken",
            "...."
        ],
        "CHAT_WEB": [
            "first server_url",
            "second server_url",
            "...."
        ]
    },
    "NTFY": {
        "ON": true,
        "TOKENS": [
            "first tocken",
            "second tocken",
            "...."
        ],
        "CHAT_WEB": [
            "first server_url",
            "second server_url",
            "...."
        ]
    },
    "PUSHBULLET": {
        "ON": false,
        "TOKENS": [
            "first tocken",
            "second tocken",
            "...."
        ]
    },
    "PUSHOVER": {
        "ON": true,
        "TOKENS": [
            "first tocken",
            "second tocken",
            "...."
        ],
        "USER_KEYS": [
            "first user_key",
            "second user_key",
            "...."
        ]
    },
    "MATRIX": {
        "ON": false,
        "TOKENS": [
            "first tocken",
            "second tocken",
            "...."
        ],
        "SERVER_URLS": [
            "first server_url",
            "second server_url",
            "...."
        ],
        "ROOM_IDS": [
            "!first room_id",
            "!second room_id",
            "...."
        ]
    },
    "MATTERMOST": {
        "ON": false,
        "CHAT_URLS": [
            "first server_url",
            "second server_url",
            "...."
        ]
    },
    "ROCKET": {
        "ON": false,
        "TOKENS": [
            "first tocken",
            "second tocken",
            "...."
        ],
		"USER_IDS": [
            "first user_id",
            "second user_id",
            "...."
        ],
        "SERVER_URLS": [
           "first server_url",
            "second server_url",
            "...."
        ],
		"CHANNELS": [
            "#first channel",
            "#second channel",
            "...."
        ]
    },
    "DEFAULT_DOT_STYLE": true,
    "MIN_REPEAT": 1
}
Item Required Description
DEFAULT_DOT_STYLE true/false Round/Square dots.
SEC_REPEAT 1 Set the poll period in seconds. Minimum is 1 minute.

Running as a Linux Service

You can set this script to run as a Linux service for continuous monitoring.

Create a systemd service file:

nano /etc/systemd/system/web_check.service
[Unit]
Description=check active hosts
After=multi-user.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 /opt/web_check/web_check.py

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable web_check.service
systemctl start web_check.service

License

This project is licensed under the MIT License - see the MIT License for details.

Author

About

This Python script monitors the availability of specified web hosts. It checks the status of URLs and sends notifications through various messaging services if any host is unreachable or returns an error. Support Telegram, Discord, Gotify, Ntfy, Pushbullet, Pushover, Slack, Matrix, Mattermost, Rocket.chat

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages