A simple Telegram bot designed to gather basic information about the status of your local servers. The bot operates synchronously. It does not use webhooks.
The bot was written using the pyTelegramBotAPI. Use psutil and docker-py libraries for gather information.
- Load average information
- Summary memory usage information (with swap)
- Sensors information
- Summary process information
- Uptime information
- File system base information
- Containers (only docker and only on Linux) base information
- Use
Jinja2
for answers template - Use docker logs collector (
sudo docker logs container_id
) - Use emoji :)
Screenshots are available here: screenshots.md. Video demo see in YouTube Shorts here
Initially, the bot was designed to ensure its correct operation only within the Docker container. I have not tested it running on a local system, either inside or outside a virtual environment. Therefore, please make sure that Docker is installed on your system.
Full list of Python dependencies see in requirements.txt
- See installation.md
The bot has an authorization mechanism. That is based on a unique value we can get from the message's
variable from_user.id
, which is the Telegram user ID.
By comparing this value with the user.id
values specified in the bot's settings
(which is done at the initial stage of configuring the bot), we can determine the behavior of the bot.
All failed attempts to authorize are logged with an ERROR
flag.
βββ Dockerfile - Main Dockerfile
βββ LICENSE - Licence file
βββ README.md - Main README
βββ SECURITY.md - Security police
βββ app
β βββ __init__.py
β βββ core
β β βββ __init__.py - Bot core
β β βββ adapters
β β β βββ __init__.py
β β β βββ docker_adapter.py - Docker adapter
β β β βββ podman_adapter.py - Podman adapter (in development)
β β β βββ psutil_adapter.py - Psutil adapter
β β βββ exceptions.py - Custom exceptions
β β βββ handlers
β β β βββ __init__.py
β β β βββ default_handlers
β β β β βββ __init__.py - Import all defaults handlers
β β β β βββ containers_handler.py - Container handler
β β β β βββ fs_handler.py - Filesystem handler
β β β β βββ load_avg_handler.py - Load average handler
β β β β βββ memory_handler.py - Memory handler
β β β β βββ process_handler.py - Process handler
β β β β βββ sensors_handler.py - Sensors handler
β β β β βββ start_handler.py - Main, start handler
β β β β βββ uptime_handlers.py - Uptime handler
β β β βββ handler.py - Base handler class (abc)
β β β βββ handlers_aggregator.py - Main handlers aggregator
β β β βββ inline_handlers
β β β βββ __init__.py
β β β βββ swap_handler.py - Swap inline handler
β β βββ jinja2
β β β βββ __init__.py
β β β βββ jinja2.py - Main jinja2 class
β β βββ keyboards
β β β βββ __init__.py
β β β βββ keyboards.py - Main keyboards class
β β βββ middleware
β β β βββ __init__.py
β β β βββ auth.py - Auth middleware class
β β βββ settings
β β βββ __init__.py
β β βββ bot_settings.py - Class to load configuration from .pytmbotenv
β β βββ keyboards.py - Keyboards settings
β β βββ loggers.py - Logger templates
β βββ main.py - Main bot class
β βββ templates
β β βββ containers.jinja2 - Containers jinja2 template
β β βββ fs.jinja2 - Filesystem jinja2 template
β β βββ index.jinja2 - Start jinja2 template
β β βββ load_average.jinja2 - Load average jinja2 template
β β βββ memory.jinja2 - Memory jinja2 template
β β βββ none.jinja2 - Docker jinja2 template
β β βββ process.jinja2 - Process jinja2 template
β β βββ sensors.jinja2 - Sensors jinja2 template
β β βββ swap.jinja2 - Swap jinja2 template
β β βββ uptime.jinja2 - Uptime jinja2 template
β βββ utilities
β βββ __init__.py
β βββ utilities.py - Some utility
βββ bot_cli
β βββ cfg_templates
β β βββ env.py - Template for initial setup
β βββ fs.py - Filesystem utility
βββ docker-compose.yml - Docker Compose file (used main Dockerfile)
βββ docs
β βββ docker.md - README for hub.docker.com
β βββ installation.md - Installation guide
β βββ roadmap.md - Roadmap guide
β βββ screenshots.md - Bots screenshot
βββ hub.Dockerfile - Dockerfile for Docker CI/CD based on Alpine
βββ logs
β βββ pytmbot.log - Main logs file
βββ poetry.lock - Poetry file
βββ pyproject.toml - Poetry file
βββ requirements.txt - Requirements for build Docker image
βββ setup_bot.py - Initial setup bot script
βββ setup_req.txt - Setup requirements
βββ tests
β βββ bot_tests.py - Bots tests
- See roadmap.md
- You tell me :)
I am a novice Python developer. This is my first publicly available project in this great programming language.