Skip to content

Instantly share code, notes, and snippets.

@pauiglesias
Created March 11, 2015 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pauiglesias/450a11c643af8486e8d2 to your computer and use it in GitHub Desktop.
Save pauiglesias/450a11c643af8486e8d2 to your computer and use it in GitHub Desktop.
Filter HTTP log by time
# 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