Created
March 11, 2015 09:47
-
-
Save pauiglesias/450a11c643af8486e8d2 to your computer and use it in GitHub Desktop.
Filter HTTP log by time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Filter log by hour and minute | |
sudo cat /my/log/path | grep "11\/Mar\/2015\:09\:3" | grep -v "[avoid server ip address]" > filtered.log | |
# # Filter log by hour and minute avoiding certain file extensions | |
sudo cat /my/log/path | grep "11\/Mar\/2015\:09\:3" | grep -v "\.css" | grep -v "\.js" | grep -v "\.png" | grep -v "\.jpg" | grep -v "\.jpeg" | grep -v "\.gif" | grep -v "\/wp-admin\/" > filtered.log | |
# Sort 10 IPs ordered by requests | |
awk '{print $1}' filtered.log | sort | uniq -c | sort -n | tail -10 | |
# Sort 10 IPS and DNS ordered by requests | |
awk '{print $1}' filtered.log | sort | uniq -c | sort -n | tail -10 | awk '{print $2,$2,$1}' | /usr/bin/logresolve | awk '{printf "%6d %s (%s)\n",$3,$1,$2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment