Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1121

cheap bash script to monitor connections to an IP

$
0
0
this will trace only connections in the SYN_SENT status ... if you get a SocketTimeoutException, the connection will never transition in the ESTABLISHED state, it will only wait in the SYS_SENT state until it times out...


cat monitornet.sh

while true
do
lines=`netstat -an | grep YOURDESTINATIONIP | grep SYN`
sleep 0.1
if [ "$lines" ]; then
echo `date` $lines
echo ""
fi
done




Maybe running netstat 10 times a second will kill your server, so you better sleep a bit more


Viewing all articles
Browse latest Browse all 1121

Trending Articles