Skip to content

Instantly share code, notes, and snippets.

@skitazaki
Created April 11, 2012 13:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skitazaki/2359180 to your computer and use it in GitHub Desktop.
Save skitazaki/2359180 to your computer and use it in GitHub Desktop.
Simple access_log analysis
# Calculate by response status code.
cat /usr/local/nginx/latest/logs/access.log |
awk '$9 < 200 || $9 >= 600 { print $0 > "/dev/stderr"; }
$9 >= 200 && $9 < 600 { print $9; }' |
sort |
uniq -c
# Show raw lines of specific response status code line.
cat /usr/local/nginx/latest/logs/access.log |
awk '$9 == 301 { print $0 ; }'
# Calculate by access time.
cat /usr/local/nginx/latest/logs/access.log |
sed -e 's/^.*\[\(.*\) \(.*\)\].*$/\1/' |
awk -F":" '{ print $1, $2, $3, $4; }' |
awk -F"/" '{ print $1, $2, $3; }' |
awk '{ printf "%s,%d %02d:%02d:%02d\n", $2, $1, $4, $5, $6; }' |
sort |
uniq -c
# Show raw lines of specific access time.
cat /usr/local/nginx/latest/logs/access.log |
awk '$4 == "[11/Apr/2012:09:17:49" { print $0 ; }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment