Updated at: 2024-03-01
https://github.com/txthinking/brook
--serverLog 格式如下
{"bytes":"2190","dst":"8.8.8.8:53","from":"34.105.110.232:49514","network":"tcp","time":"2024-02-26T09:56:12Z"}
{"bytes":"2237","dst":"8.8.8.8:53","from":"34.105.110.232:49331","network":"udp","time":"2024-02-26T09:57:12Z"}
可以从 --serverLog 里统计流量,比如用 jb 脚本统计 /tmp/brook.log
日志里的流量总和
jb 'var s=0; read_file("/tmp/brook.log").trim().split("\n").map(v=>JSON.parse(v)).forEach(v=> s+= v.bytes ? parseInt(v.bytes) : 0); echo(s)'
我们知道这样:
brook server -l :9999 -p hello
现在, 创建一个文件 /root/any_name
:
server -l :9999 -p hello
我们就可以这样:
brook /root/any_name