Created
May 23, 2017 14:27
-
-
Save yourtion/067b99589858b7a70eea96ef854dd99b to your computer and use it in GitHub Desktop.
shadowsocks monitor https://blog.bingxuecandong.com/?p=199
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# monit add : iptables -I OUTPUT -s 你的服务器IP -p tcp --sport 开放的端口 | |
# show : iptables -n -v -L -t filter | |
#统计流量 | |
flowname="/data/log/vpn/flow.log" | |
flownametail="/data/log/vpn/flow_tail.log" | |
flowregex="spt:端口起始到结尾" | |
date +"[%Y-%m-%d %H:%M:%S]" >> $flowname | |
iptables -n -v -L -t filter | egrep $flowregex | awk -F ' ' '{print $10 "\t" $2}' >> $flowname | |
iptables -n -v -L -t filter | egrep $flowregex | awk -F ' ' '{print $10 "\t" $2}' > $flownametail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# add to cron : * * * * * /home/shadowsocks/monitor.sh | |
#当前使用统计 | |
filename="/data/log/vpn/monitor.log" | |
regex="你开放的端口起始与结尾" | |
date +"[%Y-%m-%d %H:%M:%S]" >> $filename | |
netstat -anp | egrep $regex | grep -E "tcp.*ESTABLISHED" | awk '{print $4, $5}' | cut -d: -f2 | sort -u >> $filename | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment