A secure Telegram bot for remote system operations and monitoring on Linux hosts
Project description
tg-ops
Remote system operations and monitoring on Linux hosts via Telegram.
tg-ops is a lightweight bot that runs a small HTTP webhook server to let you monitor health, check status, and execute commands on your Linux servers directly from a Telegram chat.
Features
Bot commands
/pingCheck bot responsiveness./uptimeReturns the server's uptime./status"detailed dashboard: CPU/RAM usage, monitored disks space, and systemd service status."/exec"Shell Execution: Run arbitrary commands (e.g., /exec ls -la)."/dockerContainer Management via Interactive menu./rebootComing Soon.
Requirements
- Python:
>= 3.11 - OS: Linux
- Docker: optional (only needed if you use
/docker) - Network: A public HTTPS URL (e.g. Cloudflare Tunnel, or ngrok) reachable by Telegram's webhook servers.
Installation
You can install tg-ops via Poetry or standard pip.
From source (Poetry)
# 1. Install Poetry if you haven't already
pip install poetry
# 2. Install dependencies
poetry install
# 3. Run the app
poetry run tg-ops --help
With pip
pip install tg-ops
# Run the app
tg-ops --help
Configuration
tg-ops relies on a TOML configuration file.
- Run the app once to generate a default config file at
~/.tg-ops.toml(or specify a custom path with-f):
tg-ops run
- Edit ~/.tg-ops.toml with your details.
Minimal example (~/.tg-ops.toml):
# Telegram bot token from @BotFather
bot_token = "YOUR_BOT_TOKEN"
# Base public URL for your webhook server (the app uses the /webhook path)
webhook_url = "https://your-domain.example"
# HTTP port to listen on
port = 5000
# Optional, recommended: Telegram webhook secret token
secret_token = "super-secret-random-string"
# Optional
log_level = "INFO"
# Optional monitoring lists
monitored_services = ["docker", "nginx", "ssh"]
monitored_disks = ["/", "/mnt/data"]
# Optional docker container mapping:
# keys are container names shown in the menu,
# values are docker-compose file paths used for actions.
[monitored_containers]
myapp = "/opt/myapp/docker-compose.yml"
webapp = "/opt/web/docker-compose.yml"
db = "/opt/db/docker-compose.yml"
Usage
Start the server and bot
tg-ops run
Use a custom config path:
tg-ops -f /path/to/config.toml run
The server listens on 0.0.0.0:<port> and serves Telegram updates at:
<webhook_url>/webhook
Manage Telegram webhooks
# Register the webhook with Telegram (uses settings from config)
tg-ops webhook set
# Check current webhook status
tg-ops webhook get
# Remove the webhook integration
tg-ops webhook unset
Notes:
webhook setregisters<webhook_url>/webhook.- If you configured a
secret_tokenin your TOML file, webhook set will automatically register it with Telegram, ensuring the server rejects any requests without the correct header.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tg_ops-0.1.0.tar.gz.
File metadata
- Download URL: tg_ops-0.1.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e4d3008bf5eaa2c4e5a5a1432bccf5f85f2cba02f9443106cd1a2f92488785c
|
|
| MD5 |
30c06a79ed3f18ff42c900df3f556da5
|
|
| BLAKE2b-256 |
97c44e1c5f398b20c6238331aa4df53f7c0362bace355d1b25d39123f2364b57
|
Provenance
The following attestation bundles were made for tg_ops-0.1.0.tar.gz:
Publisher:
python-publish.yml on idirxv/tg-ops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tg_ops-0.1.0.tar.gz -
Subject digest:
6e4d3008bf5eaa2c4e5a5a1432bccf5f85f2cba02f9443106cd1a2f92488785c - Sigstore transparency entry: 798921678
- Sigstore integration time:
-
Permalink:
idirxv/tg-ops@553f678979bbb8aaa140a12e866dde4a6d46d9c0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/idirxv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@553f678979bbb8aaa140a12e866dde4a6d46d9c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tg_ops-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tg_ops-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7239b4042abf1c0a6da00429a883dec8862587655936bd0d6bf39dd8ccf29d0d
|
|
| MD5 |
0e2421384bb275f6f388a4f95f8df4ad
|
|
| BLAKE2b-256 |
a410ec054f0840a8d874e118dd71b986944d9765771c7c6deeb3ec0527f2c66d
|
Provenance
The following attestation bundles were made for tg_ops-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on idirxv/tg-ops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tg_ops-0.1.0-py3-none-any.whl -
Subject digest:
7239b4042abf1c0a6da00429a883dec8862587655936bd0d6bf39dd8ccf29d0d - Sigstore transparency entry: 798921680
- Sigstore integration time:
-
Permalink:
idirxv/tg-ops@553f678979bbb8aaa140a12e866dde4a6d46d9c0 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/idirxv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@553f678979bbb8aaa140a12e866dde4a6d46d9c0 -
Trigger Event:
push
-
Statement type: