Wednesday, January 27, 2010

Howto: Check Apache Connections

How to check number of connections to the Apache server?

netstat command will show you the accurate connections to each of your service. In order to check the number of connections to port 80, use the netstat command and grep the Apache port.

List the connections to port 80:

netstat -alntp | grep :80

To check the number of connections to port 80:

netstat -alntp | grep :80 | wc -l

List the remote IPs connecting to your server on port 80:

netstat -alntp | grep :80 | awk ‘{print $5}’ | cut -d: -f1 | sort

List the uniq remote IPs and the number of connections from each IP:

netstat -alntp | grep :80 | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n

Please note: If you copy paste the above commands on your server, the single quote around the {} brackets may change to dots (.) and the command will fail, so make sure you replace those dots with the singe quote and execute the command.

No comments:

Post a Comment