A simple Python script that checks availabilty of multiple sites and sends error alerts to Telegram and/or Microsoft Teams.
Copy config_sample.py
to config.py
and edit accordingly.
# config.py
sites = [
"www.google.com",
"www.twitter.com"
]
# config.py
clients = {
"msteams" = False,
"telegram" = True
}
- Create a new Telegram Bot: https://core.telegram.org/bots#6-botfather
- Create a new Telegram group in the Telegram App and add the newly created bot
- Optionally: Grant your bot group admin permissions
- Open in Browser (Replace {TOKEN} in URL with your Token): https://api.telegram.org/bot{TOKEN}/getUpdates
- Copy Chat ID
Example JSON Responce:
chat: {
"id": "XXXXXXXXX",
"title": "my_group_name",
"type": "group"
}
- Set Telegram client to
True
inconfig.py
- Add Telegram Bot Token and Chat ID
# Telegram
tg_token = ""
tg_chat_id = ""
- Add Teams webhook to
config.py
msteams_webhook="XXXXXXXXXXXXXX"
python monitor.py
Setup a cronjob that runs the script every 5 minutes.(Change script location accordingly)
Edit /etc/crontab
and add following Line:
*/5 * * * * root python /opt/sitemap/monitor.py