Skip to content

Instantly share code, notes, and snippets.

@jorben
Created August 10, 2016 08:02
Show Gist options
  • Save jorben/f58f0bdbfc902cc7e6b17979ad58ee35 to your computer and use it in GitHub Desktop.
Save jorben/f58f0bdbfc902cc7e6b17979ad58ee35 to your computer and use it in GitHub Desktop.
根据端口抓捕低频发包进程
#!/bin/bash
i=1
while(($i>0))
do
pid=''
PSPID=''
GOTED=`ss -natp|grep ESTAB|grep -E ":9003 "`
if [ -n "$GOTED" ]; then
pid=`echo $GOTED|awk '{print $6}'|awk -F"," '{print $2}'`
fi
if [ -n "$pid" ]; then
PSPID=`ps aux|grep -v 'grep'|grep $pid`
fi
if [ -n "$GOTED$PSPID" ]; then
echo "==================" >> ./tmp.txt
echo `date` >> ./tmp.txt
echo "ss by port : "$GOTED >> ./tmp.txt
echo "ps by pid : "$PSPID >> ./tmp.txt
fi
sleep 2s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment