This Python script monitors a list of UDP streams (unicast or multicast) and sends a Telegram alert if any stream becomes inactive or unreachable.
Perfect for IPTV providers, network admins, or anyone relying on uninterrupted UDP stream delivery.
- ✅ Supports both multicast and unicast UDP streams.
- ✅ Retries failed stream checks before declaring them down.
- ✅ Optional requirement for receiving actual data (for more accurate checks).
- ✅ Sends real-time alerts to Telegram when streams go down.
- ✅ Uses a scheduler to run periodic checks (default: every 1 hour).
- ✅ Detailed logs for monitoring, alerts, and debugging.
- Python 3.6+
- Install dependencies using:
pip install -r requirements.txtContents of requirements.txt:
requests==2.32.3
apscheduler==3.10.4Create a file named config.json in the same directory:
{
"telegram": {
"bot_token": "your_telegram_bot_token_here",
"chat_id": "your_telegram_chat_id_here"
},
"streams": {
"udp": [
{
"name": "Channel 1",
"url": "udp://239.1.1.1:1234"
},
{
"name": "Channel 2",
"url": "udp://239.1.1.2:5678"
}
]
}
}- Replace
bot_tokenandchat_idwith your Telegram bot credentials. - Add as many UDP streams as needed, each with a descriptive
nameand validurl.
- Loads UDP streams and Telegram bot settings from
config.json. - Parses each stream's address and checks for availability.
- If multicast, joins the group before checking.
- Optionally listens for real UDP traffic (
require_data=True). - Retries failed streams before marking them as down.
- Sends a Telegram alert if any streams are unreachable.
Run the script with:
python main.pyWhat it does:
- Immediately runs a stream check.
- Starts a background scheduler that checks every hour.
- Keeps running until terminated manually.
You can adjust the stream-check behavior by modifying the parameters inside the scheduled_task() function:
check_channels(
udp_streams,
timeout=10, # Timeout per attempt (in seconds)
retry_attempts=2, # Number of retries before failure
retry_delay=2, # Delay between retries (in seconds)
require_data=True # Set to True to require actual packet reception
)- Message @BotFather
- Create a new bot:
/newbot - Copy the generated
bot_token - To find your chat ID:
- Start a conversation with your bot.
- Visit:
https://api.telegram.org/bot<your_bot_token>/getUpdates - Look for
"chat":{"id":...}in the JSON response.
🚨 IPTV Stream Alert 🚨
The following channels are DOWN:
- Channel 1: No response or timeout
- Channel 2: Invalid URL
MIT License — free to use, modify, and distribute.
Built with ❤️ by eyaadh
📧 Email: eyaadh@eyaadh.net
💬 Telegram: @eyaadh