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.

This entry was posted on Thursday, October 1st, 2009 and is filed under Linux Administration. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

2 Responses to “Howto: Check Apache Connections”

  1. Mark Nett

    If there are two Nic’s on the server, how to find which nic APache is listening on

  2. admin

    In this case, Apache by default will listen on the first NIC i.e. eth0 unless defined to listen on eth1 or other.