Skip to content

Instantly share code, notes, and snippets.

@bencaron
Last active September 24, 2015 20:12
Show Gist options
  • Save bencaron/61e090843d5cdde9c882 to your computer and use it in GitHub Desktop.
Save bencaron/61e090843d5cdde9c882 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Extract URI from an Apache log and generate a
# full URL file (like for exemple load-testing with Siege)
#
# Usage:
# extract-url.rb your.domain.name.com logfile [logfile logfile logfile]
#
targetdomain = ARGV.shift
ARGV.each do |logfile|
File.foreach(logfile, "rt") do |line|
matches = /^.*GET\s([^\s]*)\sHTTP\S*\s(\d+)/.match(line)
unless matches == nil
puts 'http://'+ targetdomain + matches[1]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment