Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Telewrapperz

Remote command monitoring made simple โ€” Execute any command and get real-time updates directly on Telegram with live system stats.

Python Telegram Bot API License: MIT


โœจ Features

Feature Description
๐Ÿ“Š Live Dashboard Single auto-updating Telegram message with command output
๐Ÿ–ฅ๏ธ System Monitoring Real-time CPU, RAM usage tracking
๐ŸŽฎ GPU Support NVIDIA GPU utilization & VRAM stats (via pynvml)
๐ŸŒ Multi-Host Ready Run on multiple machines with the same bot token
โฑ๏ธ Execution Timer Track how long your commands have been running
๐ŸŽ›๏ธ Remote Control Terminate processes or close wrapper via inline buttons
๐Ÿ–ฅ๏ธ Cross-Platform Works on Windows, macOS, and Linux
๐Ÿ“ˆ Progress Bar Support Smart handling of tqdm and rich progress bars, with proper terminal emulation
๐Ÿ’พ Log Saving Use --log to automatically save the full command output locally and download it via Telegram

๐Ÿ“ฆ Installation

# Clone the repository
git clone https://github.com/duccioo/telewrapper.git
cd telewrapper

# Install the package
pip install .

# Development install, useful when editing this checkout
pip install -e .

Dependencies: Automatically installed via pip

  • python-telegram-bot>=20.0
  • psutil
  • pynvml (optional, for NVIDIA GPU stats)
  • rich (used by the long progress demo and supported command output)

โš™๏ธ Configuration

Option 1: Environment Variables (Recommended)

export TELEGRAM_TOKEN="your_bot_token_here"
export TELEGRAM_CHAT_ID="your_chat_id_here"

Option 2: Command Line Arguments

telewrapperz --token "your_token" --chat_id "your_chat_id" "your_command"

Option 3: Config File (YAML or INI)

Create a config file and pass it with --config:

YAML format (recommended):

telegram:
  token: your_bot_token_here
  chat_id: your_chat_id_here

settings:
  update_interval: 5.0  # seconds between dashboard updates
  enable_log: true      # save full output and enable the Telegram download button

INI format (legacy):

[Telegram]
token = your_bot_token_here
chat_id = your_chat_id_here

[Settings]
update_interval = 5.0
enable_log = true

You can also enable persistent log files with an environment variable:

export TELEWRAPPERZ_ENABLE_LOG=true

๐Ÿš€ Usage

Basic Usage

# Run any command
telewrapperz "python train.py"

# Run a long-running script
telewrapperz "python -u my_training_script.py --epochs 100"

# Save the full output locally and show a "Download Log" button
telewrapperz --log "python -u my_training_script.py --epochs 100"

# Test your bot connection
telewrapperz --test

Progress Bar Demo

The repository includes a longer local demo that exercises different terminal output styles:

  • plain log lines
  • carriage-return spinners
  • single-line progress bars
  • training-style progress bars with metrics
  • multi-line cursor-up dashboards
  • Rich progress bars with multiple concurrent tasks

Run it directly:

python test/long_test.py

Run it through Telewrapperz:

telewrapperz --config config.yaml "python test/long_test.py"

For live progress demos, keep settings.update_interval low, for example 5.0. Higher values such as 60.0 reduce Telegram traffic but may make short commands appear stuck on the initial Starting... message until the next update or the final forced refresh.

Temperature Alerts

You can create temperature alerts by wrapping a monitoring command/script with Telewrapperz. When the command prints an alert message (or exits with code 1), you will see it immediately in Telegram and the status will become โŒ Error.

Example (Linux, NVIDIA GPU alert at 80ยฐC):

telewrapperz --log 'bash -lc '"'"'
while true; do
  T=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits | head -n1)
  echo "GPU Temp: ${T}ยฐC"
  if [ "$T" -ge 80 ]; then
    echo "๐Ÿ”ฅ ALERT: GPU temperature threshold exceeded (${T}ยฐC >= 80ยฐC)"
    exit 1
  fi
  sleep 15
done
'"'"''

Tip: if you already have a custom monitoring script, run that script through Telewrapperz to receive the same alerts remotely.

What You'll See on Telegram

๐Ÿ–ฅ MacBook-Pro (PID: 12345)
โš™๏ธ python train.py

Status: ๐ŸŸข Running
Time: 1:23:45
CPU: 45% | RAM: 62%
GPU 0: 87% | VRAM: 8.2/24.0GB (34%)

๐Ÿ“œ Recent Log (Last 50):
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
โ”‚ Epoch 15/100
โ”‚ Loss: 0.0234, Accuracy: 98.7%
โ”‚ Validation: 97.2%
โ”‚ ...
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

[๐Ÿ”„ Refresh] [๐Ÿ›‘ Terminate Process]

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                Telewrapperz                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚   Command   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Log Buffer    โ”‚   โ”‚
โ”‚  โ”‚   Process   โ”‚     โ”‚  (Last 50 lines)โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                               โ”‚            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚            โ”‚
โ”‚  โ”‚   System    โ”‚              โ”‚            โ”‚
โ”‚  โ”‚   Monitor   โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค            โ”‚
โ”‚  โ”‚ (CPU/RAM/GPU)              โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚            โ”‚
โ”‚                               โ–ผ            โ”‚
โ”‚                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚                    โ”‚    Telegram     โ”‚     โ”‚
โ”‚                    โ”‚    Dashboard    โ”‚     โ”‚
โ”‚                    โ”‚  (Auto-update)  โ”‚     โ”‚
โ”‚                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ”‚                                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ Command Line Options

Option Description
command The command to execute (wrap in quotes)
--token Telegram Bot Token
--chat_id Telegram Chat ID
--config Path to configuration file
--log Save full command output to a file and enable download button
--test Run a connection test

๐Ÿ’พ Log Files

Full log files are disabled by default unless you pass --log, set settings.enable_log: true, or export TELEWRAPPERZ_ENABLE_LOG=true.

When enabled, Telewrapperz writes logs to:

telewrapperz_log/telewrapperz_YYYYMMDD_HHMMSS.log

The Telegram dashboard also shows a Scarica Log / Download Log button while that file exists.


๐Ÿ”ง How to Get Your Telegram Credentials

1. Create a Bot Token

  1. Open Telegram and search for @BotFather
  2. Send /newbot and follow the instructions
  3. Copy the token provided

2. Get Your Chat ID

  1. Start a chat with your new bot
  2. Send any message to the bot
  3. Visit: https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
  4. Look for "chat":{"id":XXXXXXXX} โ€” that's your Chat ID

๐Ÿ’ก Tips & Best Practices

  • ๐Ÿ Use python -u for unbuffered Python output
  • ๐Ÿ“ The dashboard shows the last 50 lines of output
  • โฐ Dashboard updates every 5 seconds (configurable via update_interval)
  • ๐Ÿ–ฅ๏ธ GPU stats only appear if NVIDIA GPU is detected
  • ๐Ÿ”„ Use the Refresh button for immediate updates
  • ๐Ÿ“ˆ Progress bars (tqdm, rich, carriage-return bars, and simple cursor-up dashboards) are handled by the log buffer
  • ๐Ÿค– Run only one active Telewrapperz polling instance per Telegram bot token. Telegram will raise Conflict: terminated by other getUpdates request if two wrappers poll the same bot at once, which can break inline buttons.

๐Ÿ–ฅ๏ธ Platform Support

Platform Terminal Emulation Notes
Linux PTY (full) Best support, native terminal emulation
macOS PTY (full) Native terminal emulation
Windows PIPE Subprocess with line-buffered output

๐Ÿ“„ License

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


Made with โค๏ธ for remote monitoring

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages