Skip to content

Monitors the status of your servers and sends notifications to Telegram if the server is unavailable

License

Notifications You must be signed in to change notification settings

Romancha/server-healthcheck-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Server Health Check Telegram Bot

GitHub release (with filter) GitHub Release Date - Published_At License

Introduction

The Server Health Check Telegram Bot monitors the status of your servers and sends notifications to Telegram if the server is unavailable.

Bot sends requests to the servers and checks the response code. If the response code is not 2xx, the bot sends a message to the specified chat.

Features

  • HTTP status code monitoring (2xx is considered success)
  • Response time monitoring with configurable thresholds
  • Expected content verification in responses
  • SSL certificate expiration monitoring with configurable alert thresholds
    • SSL expiry notifications are limited to once per day to prevent spam
  • Availability statistics tracking
  • Human-readable time formats for last checks
  • Inline buttons for easy server management
  • Detailed server statistics
  • Telegram commands menu for easy access to all commands

Installation and Usage

Docker (Recommended)

  1. Install Docker and Docker Compose
  2. Create your bot and get a token from @BotFather
  3. Get chat_id from @userinfobot
  4. Set mandatory env in docker-compose.yml:
    • TELEGRAM_TOKEN - your bot token
    • TELEGRAM_CHAT - your chat id
    • Configure the volumes to persist servers list
  5. Run: docker-compose up -d

From source

You can also run the bot from source code, build Go binary and run it.

Configuration

Param Description
TELEGRAM_TOKEN Telegram bot token, take from @BotFather
TELEGRAM_CHAT Chat ID where the bot will send messages. @userinfobot Can help to get chat id
ALERT_THRESHOLD The number of failed requests after which the bot will send a notification. Default 3
CHECKS_CRON Cron with seconds to checks server status. Default */30 * * * * *
HTTP_TIMEOUT HTTP request timeout in seconds. Default 10
SSL_EXPIRY_ALERT Days before SSL expiry to start alerting. Default 30
DEFAULT_RESPONSE_TIME Default response time threshold in milliseconds (0 to disable). Default 0
DEBUG Enable debug mode. Default false

Commands

All commands are available in the Telegram commands menu (/) for easy access.

Command Description
/add [url] [name] Add server to monitor. For example: /add github.com github
/remove [name] Remove server from monitor. For example: /remove github
/removeall Remove all servers from monitor
/list Show list of monitored servers with action buttons
/stats Show detailed statistics for all servers
/details [name] Show detailed information for a specific server
/setresponsetime [name] [ms] Set response time threshold in milliseconds
/setcontent [name] [text] Set expected content that should be present in the response
/setsslthreshold [name] [days] Set SSL expiry threshold for specific server
/setglobalsslthreshold [days] Set global SSL expiry threshold for all servers
/help Show help message with all available commands

Contributing

We welcome contributions to improve this project.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

About

Monitors the status of your servers and sends notifications to Telegram if the server is unavailable

Topics

Resources

License

Stars

Watchers

Forks

Packages