π§ͺ Project is under active development. While not production-stable yet, contributions and feedback are highly welcome!
Minimal, secure and extensible Telegram bot to monitor and control your Linux server β from anywhere.
Telegram Server Manager Bot is a lightweight self-hosted bot that lets you:
- Monitor server metrics (uptime, CPU, RAM, disk, swap, temperature, and more)
- Manage systemd services (start/stop/restart)
- View and tail logs from services or files
- Upload/download files directly through Telegram
- Inspect network: local/public IP, bandwidth usage, listening ports
- Identify top processes by CPU/RAM
- Whitelisted admin-only access
Ideal for hobbyists, sysadmins, and minimal Linux lovers who donβt want to deal with full dashboards like Cockpit or Netdata.
- System Metrics: uptime, CPU, RAM, disk, swap, CPU temperature, load average
- Network Info: local/public IP, downloaded/uploaded bytes (human-readable), packet counts
- Processes: top CPU and RAM consumers
- Hostname: server identifier in status header
- Security: access limited by Telegram ID(s) & access logs
- Extensible: modular utilities, middleware, and decorators for easy expansion
- Systemd service manager: allows you to view and manage detailed information about the service
- Service Down Alerts: notifies you via Telegram if any monitored systemd service goes offline
- Threshold Alerts: monitors system metrics (CPU, RAM, swap, load average, disk usage, CPU temperature) and sends Telegram alerts when user-defined thresholds are exceeded
- Clone the repo
git clone https://github.com/df1gg/server-manager-bot.git && cd server-manager-bot- Create and activate virtualenv
python3 -m venv .venv
source .venv/bin/activate- Install dependencies
pip install -r requirements.txt- Create
.envfile
BOT_TOKEN=your_telegram_bot_token
OWNER_IDS=123456789,987654321 # comma-separated list of admin IDs or one ID- (Recommend) Allow the bot to use systemctl without sudo password
If you want the bot to manage system services (start, stop, restart) via systemctl, your user must be allowed to use it without entering a password.
- First, find the full path to systemctl:
which systemctl(Usually it's /bin/systemctl)
- Then open sudoers file:
# Option 1 β nano (easy for beginners)
sudo EDITOR=nano visudo
# Option 2 β vim
sudo EDITOR=vim visudo- Add this line at the bottom, replacing
yourusernamewith your actual username:
yourusername ALL=(ALL) NOPASSWD: /bin/systemctl(Replace /bin/systemctl with actual path if different)
visudo to avoid syntax errors!
- Run the bot as a systemd service
This allows the bot to start automatically with your system and run in the background.
- Create a systemd service file:
# Replace "yourusername" with your actual Linux username
sudo nano /etc/systemd/system/server-manager-bot.service
# Or use vim: sudo nano /etc/systemd/system/server-manager-bot.servicePaste this content into the file:
[Unit]
Description=Server Manager Bot
After=network.target
[Service]
User=yourusername
WorkingDirectory=/home/yourusername/server-manager-bot
ExecStart=/home/yourusername/server-manager-bot/.venv/bin/python main.py
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.targetβ IMPORTANT:
Make sure to replace yourusername and the paths (WorkingDirectory, ExecStart)
with the correct ones for your system. Use pwd to check the full path to your project.
Also make sure .venv/bin/python exists β or adjust to the correct Python path.
- Reload systemd and enable the service:
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable server-manager-bot
sudo systemctl start server-manager-bot- Check logs (optional):
journalctl -u server-manager-bot -f- If you ever want to stop the bot:
sudo systemctl stop server-manager-botπ Congratulations! Your Server Manager Bot is now running as a background service and will automatically start on boot.
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m "feat: your feature description") - Push and open a Pull Request against
dev
Please keep the code clean and follow the project style.
- Python 3.11+
- Aiogram 3.x β Telegram Bot Framework (async)
asyncio,socket,os,psutil,subprocessβ core system toolsSQLAlchemy,aiosqliteβ database for save optionsloguruβ structured and colorized loggingsystemdβ Background service handlingdotenvβ Secure environment-based config
- Only IDs in
OWNER_IDScan interact with the bot - Unauthorized users receive a
β Access deniedmessage and no handlers run - Flexible middleware and decorator support for further restrictions or authentication
- Display server status info with inline refresh button
- Admin-only access control by Telegram ID(s)
- Service management
- Automatic discovery of available systemd services
- Add/remove services from management list
- OS version display (distribution and kernel)
- Auto-refresh status periodically
- Reboot & Poweroff functionality
- Docker integration: list containers, start/stop/restart via buttons
- Graphs: CPU/RAM/Disk/Swap usage over the last hours
- Alerts & Notifications: send Telegram alerts on high load or service failure
- Port scanner: list listening TCP ports with process names
- Cron-manager: add/remove cron jobs via bot commands
- Log search: grep-like filtering of logs
- Internationalization (i18n) β multi-language support
- CI/CD trigger β deploy or tests via bot
- Batch commands execution β run multiple commands in sequence
This project is licensed under the MIT License.
Feel free to use, modify, and share.
Made by df1gg with β€οΈ


