How to get Apache Concurrent Connection & IP

The following script will give you the concurrent connection on your Apache Server with Currently accessing source IP Address. The script is checking only 80 port now, you can change the port to 443 if you are on SSL.

 

#!/bin/bash
[ $# -eq 0 ] && { echo “Usage: $0 <refresh time>” ; exit 1; }
while true
do
clear;
echo “Number of Active Connections:”;
netstat -an | grep 80 | grep tcp | grep -v 0.0.0.0 | grep -v ::: | cut -d’:’ -f2 | cut -d’ ‘ -f12 | sort | uniq | wc -l;
echo;
echo “Current Active IP’s:”;
netstat -an | grep 80 | grep tcp | grep -v 0.0.0.0 | grep -v ::: | cut -d’:’ -f2 | cut -d’ ‘ -f12 | sort | uniq;
sleep $1;
done

stacker has written 18 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Humans Only. * Time limit is exhausted. Please reload the CAPTCHA.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>