traffic-monitor
监控服务器指定网卡月度网络流量,定期生成使用报告并在流量超过80%阈值时提供警告。
MIT-0 · Free to use, modify, and redistribute. No attribution required.
⭐ 0 · 18 · 0 current installs · 0 all-time installs
by@binyuli
MIT-0
Security Scan
OpenClaw
Benign
high confidencePurpose & Capability
Name and description claim monthly network traffic monitoring; the SKILL.md and traffic_report.py both use vnstat and /proc/net/dev to produce monthly and cumulative reports. The requested items (vnstat, systemctl commands) align with the stated purpose.
Instruction Scope
SKILL.md instructs the agent to run vnstat and the included script and to check vnstat service status — all within scope. Note: the script writes a state file at /root/.openclaw/workspace/memory/traffic-state.json (not mentioned in SKILL.md), and the fallback to /proc/net/dev is only a cumulative since-boot view (the code does avoid using it as monthly data). Running the script as a non-root user may fail to create or write the state file as currently configured.
Install Mechanism
No install spec (instruction-only with a single included script). Nothing is downloaded or written during install beyond running the provided script — low install risk.
Credentials
The skill requests no environment variables or credentials, which is appropriate. Minor mismatch: SKILL.md lists vnstat DB location (/var/lib/vnstat/vnstat.db) as vnstat's data store (expected), while the script independently stores state under /root/.openclaw/... — an internal state file path that may be surprising and requires write access.
Persistence & Privilege
always is false and model invocation is normal. The script persists its own small JSON state file but does not modify other skills or system-wide config. It does not request elevated privileges explicitly, though interacting with vnstat/systemctl or writing to /root may require root permissions.
Assessment
This skill appears to do what it says: generate monthly traffic reports using vnstat and optionally show realtime cumulative stats. Before installing or running: 1) Ensure vnstat is installed and running (vnstat uses /var/lib/vnstat by default). 2) Be aware the included script writes state to /root/.openclaw/workspace/memory/traffic-state.json — if you run the agent as a non-root user you may need to change STATE_FILE in the script or run as a user with write permission to that path. 3) The script calls the local vnstat binary and reads /proc/net/dev only as a fallback (those are local operations; there are no external network calls). 4) If you want different interface, monthly limit, or state location, edit INTERFACE, MONTHLY_LIMIT_GB, or STATE_FILE in traffic_report.py. 5) If you need tighter review, verify the script contents yourself (it is short and straightforward) and confirm any automation (heartbeat) will run under an account that has permission to run vnstat and write the state file.Like a lobster shell, security has layers — review code before you run it.
Current versionv1.0.0
Download ziplatest
License
MIT-0
Free to use, modify, and redistribute. No attribution required.
SKILL.md
Traffic Monitor Skill
version: 1.0.0
监控服务器网络流量使用情况,定期报告月度流量消耗。
背景
服务器每月有 2T 流量限制,需要监控使用情况避免超额。
快速查询
# 查看当前月度流量
vnstat -m -i eth0
# 查看实时流量
vnstat -l -i eth0
# 查看日流量
vnstat -d -i eth0
# 查看流量摘要
traffic_report.py
技能脚本
traffic_report.py
生成人类可读的流量报告:
python3 ~/.openclaw/skills/traffic-monitor/traffic_report.py
输出示例:
📊 本月流量统计
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📥 入站: 125.3 GB
📤 出站: 89.2 GB
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📦 总计: 214.5 GB / 2048 GB (10.5%)
⚠️ 剩余: 1833.5 GB
心跳检查
可以在 HEARTBEAT.md 中添加流量检查:
## 流量检查(每天一次)
- 运行 traffic_report.py
- 如果使用超过 80%,发送警告
配置
- 网卡: eth0
- 月度限制: 2TB (2048 GB)
- 警告阈值: 80% (1638 GB)
- 数据存储: /var/lib/vnstat/vnstat.db
注意事项
- vnstat 服务必须运行:
systemctl status vnstat - 首次安装需要几分钟收集数据
- 数据持久化存储,重启不丢失
- 统计的是网卡流量,包括所有出入站流量
相关命令
# 检查 vnstat 服务状态
systemctl status vnstat
# 重启 vnstat
systemctl restart vnstat
# 查看所有接口
vnstat --iflist
# 导出 JSON 格式
vnstat -m -i eth0 --json
Files
2 totalSelect a file
Select a file to preview.
Comments
Loading comments…
