Skip to content

Instantly share code, notes, and snippets.

@sheeplogh
sheeplogh / gist:4372179
Created December 25, 2012 07:59
get total bytes transferred in MB from apache accesslog.
$ cat ACCESS_lOG | awk '{bytes = bytes + $10} END {print bytes/1048576}'
@sheeplogh
sheeplogh / amazons3.lf
Created September 3, 2012 02:34
[urchin] logformat conf for Amazon S3
#-----------------------------------------------------------------------------------------------
# Urchin Logformat Map - Custom Format
#
# Urchin uses this file to determine which fields are contained in the log file.
# The file contains name/value pairs which affect the parsing of the data fields.
# The log file can contain lines with up to two different formats which are
# denoted as Primary and Secondary in the name/value pairs below.
#
# Lines beginning with a '#' are ignored. Fields in this file are separated by
# whitespace (spaces or tabs). Any fields that have whitespace in them must be
@sheeplogh
sheeplogh / gist:3550039
Created August 31, 2012 07:56
[shell] List file-permissions in octal notation
$ find ./20120831_testdir -type f -print0 | xargs -0 stat --format='%a %N' | sed -e "s/[\`']//g"
755 ./20120831_testdir/2009032/httpdconf.pl
777 ./20120831_testdir/showmod.sh
@sheeplogh
sheeplogh / gist:3521534
Created August 30, 2012 01:42
[mod_rewrite]Redirect HTTP requests by UA(PC/Smartphone/...)
## SET ENV "UA" ##
### DEFAULT
RewriteRule .* - [E=UA:default]
### PC
RewriteCond %{HTTP_USER_AGENT} Windows [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Mac\sOS\sX [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Macintosh [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Mac_ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Linux [NC,OR]
@sheeplogh
sheeplogh / gist:3421464
Created August 22, 2012 02:06
grep an accesslog(apache) file within a specific time period
$ cat ACCESS_LOG | awk '$4 >= "[29/Jan/2012:12:00:00" && $4 < "[29/Jan/2012:13:00:00"'