Shell script for packet capture when the NIC is very large in linux

Source: Internet
Author: User

I shamelessly turned the Amin Linux script around, and sometimes it might be used when checking.

#!/bin/sh

#
# Setup Area
#

Snif_if=eth0
pkg_threshold=7000
Save_dir=/home/snif_log
snif_count=2000

#
# don ' t change
#
[!-D $SAVE _dir] && mkdir-p $SAVE _dir
While:;
Todo

Pkg_cur= ' sar-n DEV 1 2|grep $SNIF _if|head-n 2|tail-n 1|awk ' {print $} ' |cut-d.-f1 '
#如果sysstat以12小时 (AM,PM) time, then take it again to get the correct result
["X$pkg_cur" = "x$snif_if"] && pkg_cur= ' sar-n DEV 1 2|grep $SNIF _if|head-n 2|tail-n 1|awk ' {print $} ' |cut- D.-f1 '

If [$PKG _cur-gt $PKG _threshold];then
Tcpdump-n-I $SNIF _if-c $SNIF _count-vs0-w $SAVE _dir/$SNIF _if. ' Date +%m%d-%h%m '. Cap
#tcpdump-N-i $SNIF _if-c $SNIF _count-w $SAVE _dir/$SNIF _if. ' Date +%m%d-%h%m '. Cap
Fi

Sleep 300
Done

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.