VPSTrafficMonitor
This script monitors the remaining traffic of VMs on Vultr, DigitalOcean, and Linode. If the remaining traffic is zero, it shuts down the VM and sends a notification via Telegram.
Install / Use
/learn @iquping/VPSTrafficMonitorREADME
VM Traffic Monitor
This script monitors the remaining traffic of VMs on Vultr, DigitalOcean, and Linode. If the remaining traffic is zero, it shuts down the VM and sends a notification via Telegram.
Features
- Monitors VM traffic on Vultr, DigitalOcean, and Linode.
- Shuts down VM when traffic is depleted.
- Sends notification via Telegram.
Setup
- Clone the repository
git clone https://github.com/yourusername/vm-traffic-monitor.git
cd vm-traffic-monitor
- Install dependencies
pip install requests pyyaml python-telegram-bot
-
Configure the config.yaml
-
Add execution permissions to the script
chmod +x check_traffic.py
- Set up a cron job to run the script periodically
crontab -e
Add the following line to run the script every hour:
0 * * * * /usr/bin/python3 /path/to/check_traffic.py >> /path/to/check_traffic.log 2>&1
Running as a Daemon(Optional)
To run the script as a daemon, you can use systemd on Linux:
- Create a systemd service file
sudo nano /etc/systemd/system/vm-traffic-monitor.service
- Add the following content to the service file
[Unit]
Description=VM Traffic Monitor
After=network.target
[Service]
ExecStart=/usr/bin/python3 /path/to/check_traffic.py
WorkingDirectory=/path/to
StandardOutput=file:/var/log/vm-traffic-monitor.log
StandardError=file:/var/log/vm-traffic-monitor.log
Restart=always
[Install]
WantedBy=multi-user.target
- Reload systemd and start the service
sudo systemctl daemon-reload
sudo systemctl start vm-traffic-monitor
sudo systemctl enable vm-traffic-monitor
Related Skills
node-connect
348.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
