我们有一个运行在我们业务中的function齐全的双栈networking。 有没有人find一个简单的工具来监控给定主机上的IPv4和IPv6stream量比率? 当我说“简单”时,我正在考虑一个类似于“vnstat”的守护进程/
最简单forms的完美报告看起来像这样:
Total IPv4 IPv6 Ratio This Month: 300gb 100gb (33%) 200gb (66%) 1:2 This Week: 5gb 1gb (20%) 4gb (80%) 1:4 Today: 1.2gb 400mb (33%) 800mb (66%) 1:2
原谅我,如果我的math是错误的,这就是为什么我想要一个工具;)
我主要对Linux(CentOS 6)主机感兴趣,但是任何Windows(2008R2)工具也是有用的。
我发现了一个提示netstat -s -6 | grep -i octets的线程 netstat -s -6 | grep -i octets但-6选项在CentOS 6上无效; 我猜这是netstat最近的一个补充。
我已经这样做了,已经有一段时间了,使用munin和自己写的一个自定义插件,它从iptables审计规则中获取数据。 它运行在一个C6盒子上,所以如果没有人有更好的想法,你应该可以把它叉到位。 这不是你想要的简单单线程,而是工作,并产生这样的数据:

这个插件非常简单,只需要从/var/tmp创build的两个平面文件获取数据:
#!/bin/bash # # (c) Gatekeeper Technology Ltd., 2013 # May be used under the terms of GPLv3 or, at your discretion, any later version if [ "$1" = "config" ]; then echo 'graph_title Network Throughput' echo 'graph_category network' echo 'graph_info This is the total throughput on the NIC since the beginning of the calendar month, or the last reboot, whichever was mo st recent.' echo 'graph_vlabel bytes' echo 'graph_args --logarithmic' echo 'in4.label in v4' echo 'in4.colour ff0000' echo 'out4.label out v4' echo 'out4.colour 00ff00' echo 'in6.label in v6' echo 'in6.colour aa0088' echo 'out6.label out v6' echo 'out6.colour 00aa88' echo 'total.label total' echo 'total.colour 0000ff' exit 0 fi out=`head -3 /var/tmp/audit.out.counts | tail -1 | awk '{print $2}'` echo "out4.value $out" in=`head -3 /var/tmp/audit.in.counts | tail -1 | awk '{print $2}'` echo "in4.value $in" out6=`head -3 /var/tmp/audit.out.v6.counts | tail -1 | awk '{print $2}'` echo "out6.value $out6" in6=`head -3 /var/tmp/audit.in.v6.counts | tail -1 | awk '{print $2}'` echo "in6.value $in6" total=$(($in+$out+$in6+$out6)) echo "total.value $total"
使它们的crontab条目看起来像这样:
# output the audit rule counts for munin purposes * * * * * /sbin/iptables -L AUDIT-I -n -x -v > /var/tmp/audit.in.counts * * * * * /sbin/iptables -L AUDIT-O -n -x -v > /var/tmp/audit.out.counts * * * * * /sbin/ip6tables -L AUDIT-I -n -x -v > /var/tmp/audit.in.v6.counts * * * * * /sbin/ip6tables -L AUDIT-O -n -x -v > /var/tmp/audit.out.v6.counts # and zero the counts once a month 0 0 1 * * /sbin/iptables -Z AUDIT-I 0 0 1 * * /sbin/iptables -Z AUDIT-O 0 0 1 * * /sbin/ip6tables -Z AUDIT-I 0 0 1 * * /sbin/ip6tables -Z AUDIT-O
而iptables规则是用下面的/etc/sysconfig/iptables规则创build的:
:AUDIT-I - [0:0] :AUDIT-O - [0:0] # audit input traffic -A INPUT -i eth0 -j AUDIT-I [ALL OTHER INPUT RULES APPEAR HERE, AFTER THE AUDIT RULE] # audit outbound traffic -A OUTPUT -o eth0 -j AUDIT-O [ALL OTHER OUTPUT RULES APPEAR HERE, AFTER THE AUDIT RULE] # AUDIT rules -A AUDIT-I -p all -A AUDIT-O -p all
涉及crontab的原因是阻止需要以root权限运行的munin插件; 如果你不介意这样做的话,你可以通过调用iptables来直接获取包的数量。
计数器不能在重新启动后存活(因此上图中的额外下降到零),但是如果您的服务器设置为在重新启动时保存iptables规则和数据包计数 ,则这不会影响到您。
你可以在GitHub上试试这个IPv6 Munin插件: