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?
Asked
Active
Viewed 129 times
2 Answers
5
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

quanta
- 51,413
- 19
- 159
- 217
-
`sort|uniq -c|sort -rn|` == `sort -ucrn`? – 84104 Sep 30 '11 at 02:21
-
No, `-uc` check for strict ordering: _sort: -:2: disorder: IP_ – quanta Sep 30 '11 at 02:27
-
You're right. My apologies. – 84104 Sep 30 '11 at 02:40
0
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

xofer
- 3,072
- 12
- 19