[TrafficCop] 监控 VPS 流量使用,到达限制自动限流,保留 SSH 端口可用

5 天前
 bacon159

借助 claude 写了个监控 VPS 流量使用的脚本,调试了大概三四天,今天终于是完全体了! github 项目地址: https://github.com/ypq123456789/TrafficCop 喜欢这个项目的可以给个 star !

TrafficCop - 智能流量监控与限制脚本

特别提醒

流量统计是从你开始安装 vnstat 开始的

流量统计是从你开始安装 vnstat 开始的

流量统计是从你开始安装 vnstat 开始的

如果你在安装本脚本之前没有安装过 vnstat ,请注意:本脚本基于 vnstat 的流量统计,而 vnstat 只会从它安装好之后开始统计流量!

一键安装脚本

标准安装(可能有几分钟延迟):

curl -fsSL https://raw.githubusercontent.com/ypq123456789/TrafficCop/main/trafficcop.sh -o /root/traffic_monitor.sh && chmod +x /root/traffic_monitor.sh && bash /root/traffic_monitor.sh

快速更新版本:

curl -H "Accept: application/vnd.github.v3.raw" -fsSL "https://api.github.com/repos/ypq123456789/TrafficCop/contents/trafficcop.sh" | tr -d '\r' > /root/traffic_monitor.sh && chmod +x /root/traffic_monitor.sh && bash /root/traffic_monitor.sh

实用命令

查看日志:

tail -f -n 30 /root/traffic_monitor.log

查看当前配置:

cat traffic_monitor_config.txt

紧急停止所有 traffic_monitor 进程(用于脚本出现问题时):

pkill -f traffic_monitor.sh

一键解除限速

curl -sSL https://raw.githubusercontent.com/ypq123456789/TrafficCop/main/remove_traffic_limit.sh | sudo bash

脚本逻辑

脚本特色

预设配置

阿里云 CDT 200G:

curl -o /root/traffic_monitor_config.txt https://raw.githubusercontent.com/ypq123456789/TrafficCop/main/ali-200g

阿里云 CDT 20G:

curl -o /root/traffic_monitor_config.txt https://raw.githubusercontent.com/ypq123456789/TrafficCop/main/ali-20g

我拿阿里云香港 cdt 共享带宽试了下,精度还是比较高的!如下图所示

求个点赞不过分吧家人们!真的调试了很久!有 bug 可以提 isuue 或者 pr ,我这个小菜鸡尽量修复

343 次点击
所在节点    VPS
2 条回复
tpxcer
5 天前
友情提醒,图片未加载。
bacon159
5 天前
@tpxcer 换成 github 的图片了,现在能看见吗

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1054345

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX