1、抓包腳本
成都創(chuàng)新互聯(lián)公司是一家專注于做網(wǎng)站、成都網(wǎng)站制作與策劃設(shè)計(jì),獲嘉網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)十載,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:獲嘉等地區(qū)。獲嘉做網(wǎng)站價(jià)格咨詢:13518219792
# cat capturepackages.sh
#!/usr/bin/sh
#
while [ 1 ]
do
STIME=`date +%F"@"%H%M%S`
DATE_DIR=`date +%F`
if [ ! -d /tnm/capture/$DATE_DIR ];then
mkdir -p /tnm/capture/$DATE_DIR
fi
/usr/local/sbin/tcpdump -w /tnm/capture/$DATE_DIR/$STIME.log -s 5000 -i lan0
done
2、停抓包的腳本
# cat stopscript.sh
#!/usr/bin/sh
STIME=`date +%F"@"%H%M%S`
zhuabao=`ps -ef|grep tcpdump|awk '/lan0/ { print $2 }'`
jiaoben=`ps -ef|grep capturepackages|awk '/bin/ { print $2 }'`
if [ -n "$zhuabao" ] && [ -n "$jiaoben" ];
then
kill -9 $jiaoben
kill -9 $zhuabao
echo " This $STIME the script is execute success! " >> /tnm/capture/messages
else
echo " The script has problem! "
fi
3、把這兩個(gè)腳本加入crontab定時(shí)任務(wù)