Skip to content

dumanburak/ping-alert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ping Monitor + Telegram Alert

A lightweight asynchronous tool that periodically checks websites or IP addresses and sends instant Telegram alerts when a target is unreachable or returns an HTTP error.


Features

  • Monitor multiple URLs or IPs simultaneously
  • Instant Telegram notifications for downtime or errors
  • Custom target names via a simple config file
  • Color-coded terminal output (green/yellow/red)
  • Works on Windows, Linux, and Raspberry Pi
  • Open-source and easy to customize

How It Works

Ping Monitor runs an async loop that sends HTTP requests to all defined targets at a fixed interval. If a target fails to respond or returns a non-200 code, it immediately sends a Telegram message.

Example Telegram alert:

Server A is DOWN!
Details: ConnectTimeout(...)

Installation

  1. Install dependencies:

    pip install -r requirements.txt
  2. Create config.json:

    {
      "telegram": {
        "bot_token": "123456789:ABCDEFyourTokenHere",
        "chat_id": "-yourChatIdHere"
      },
      "targets": [
        {"name": "Google", "url": "https://www.google.com"}
      ],
      "interval": 60,
      "timeout": 5
    }
  3. Run the monitor:

    python ping_monitor.py

Telegram Setup

  • Create a new bot using @BotFather
  • Copy your bot token and paste it into config.json
  • Add the bot to a chat or group
  • Use get_id_bot to find your chat_id

Example Output

Terminal:

[2025-10-09 15:47:11] [OK] Google is reachable.
[2025-10-09 15:48:11] [DOWN] Google is unreachable: ConnectTimeout(...)

Telegram:

Google is DOWN!
Details: ConnectTimeout(...)

Requirements

httpx
colorama

License

MIT License — free to use, modify, and distribute.


Author

Burak Duman Embedded & Backend Developer | OCPP · IoT · Python GitHub · LinkedIn

About

Lightweight Python tool for uptime monitoring and Telegram alerts using asyncio and httpx.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages