我有rhel4和rhel6主机。
我可以使用netstat -s来查看发送/接收的段数的信息。 我可以使用ifconfig来查看给定接口上发送/接收的字节数(对于我而言,只有一个是重要的,其余的总传输less于三个数量级)。
我怎样才能find通过TCP传输的总字节数?
编辑:我没有在有问题的主机上的root访问权限。
用iptables定义一个数据包过滤规则来统计所有的tcp数据包。
使用tcp协议统计所有传入数据包:
# iptables -I INPUT -p tcp
使用tcp协议统计所有传出的数据包:
# iptables -I OUTPUT -p tcp
显示iptables规则,包括传入数据包的数据包计数:
# iptables -nvL INPUT
显示iptables规则,包括传出数据包的数据包计数:
# iptables -nvL OUTPUT
iptables -nvL显示前两列的数据包数和字节数。 这两个定义的规则将是列表顶部的第一个。 如果你有很多的iptables规则,额外的链可能是有帮助的:
# iptables -N count_in # create custom chain named 'count_in' # iptables -A count_in -j RETURN # append RETURN action to chain 'count_in' # iptables -I INPUT -j count_in # insert chain at the top of chain INPUT # iptables -I count_in 1 -p tcp # insert rule that matches all tcp packets # and has no action (does nothing) # iptables -nvL count_in # list chain 'count_in' rules
使用自定义链count_out对传出数据包执行相同count_out 。