脚本
点击查看代码
#!/bin/bash
mkdir /tmp/tcpdump
export TcpDump=tcpdump
export SliPackeLen=0
export SliptCapPacket=50000
for ((iLoop=0; iLoop<1000; iLoop++))
do
ip a |grep bond0 &>/dev/null
if [ $? -eq 0 ]
then
$TcpDump -i bond0 -s $SliPackeLen -c $SliptCapPacket -w /tmp/tcpdump/all_$iLoop.dmp "(conditions)"and not icmp
else
$TcpDump -i eth0 -s $SliPackeLen -c $SliptCapPacket -w /tmp/tcpdump/all_$iLoop.dmp "(conditions)" and not icmp
fi
#{
#find /tmp/tcpdump -name '*dmp' -mtime +1 -delete
#}&
done
echo ""
注:
抓包长度使用 -s 参数指定为0 不限制长度,否则会展示时引起kafka truncate 错误