Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running Apache server and would like to find out who (IP address) is making a lot of request for the last 24 hours using command line. Also like to find out who has the most open connection at the moment?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

I am running Apache server and would like to find out who (IP address) is making a lot of request for the last 24 hours using command line.

awk '/29\/Sep\/2011/ { print $1 }' /path/to/access_log | sort | uniq -c | sort -rn | head

Also like to find out who has the most open connection at the moment?

netstat -natp | grep httpd | awk '{ print $5 }' | cut -d: -f1 | sort | uniq -c | sort -rn | head
share|improve this answer
    
sort|uniq -c|sort -rn| == sort -ucrn? –  84104 Sep 30 '11 at 2:21
    
No, -uc check for strict ordering: sort: -:2: disorder: IP –  quanta Sep 30 '11 at 2:27
    
You're right. My apologies. –  84104 Sep 30 '11 at 2:40
add comment

You can use tail /path/to/apache_log_file (check in /var/log/apache2). One way to see current connections is to use mod_status. You can also use netstat -a |grep www

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.