Permalink
Browse files

Merge branch 'master' of git://github.com/kjwierenga/autoperf

  • Loading branch information...
2 parents 38cea21 + 819e3f5 commit d732e18377a9b95ddc1903b97df2c41ef8359a8a @igrigorik committed Jun 19, 2010
Showing with 35 additions and 2 deletions.
  1. +33 −0 make_replay_log.rb
  2. +2 −2 sample.conf
View
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+# Make replay log by extracting the URI from an Apache CLF log file
+# replacing string 'match' by 'substitute' and concatenating them
+# together by replacing \n by \0
+
+progname = File.basename($0)
+
+if ARGV.size < 2
+ puts "Usage: ruby #{progname} 'match' 'substitute' file1 [file2 [file3]] > output_file"
+ puts "Usage: cat logfile | ruby #{progname} 'match' 'substitute' > output_file"
+ puts
+ puts "Example: cat /var/log/access_log | ruby #{progname} '/app' '/' > replay_log"
+ exit
+end
+
+match = ARGV.shift
+sub = ARGV.shift
+
+ARGF.each do |line|
+ request = line.split('"')[1]
+ next if request.nil?
+
+ uri = request.split[1]
+ next if uri.nil?
+
+ begin
+ uri[match] = sub
+ rescue IndexError
+ # simply output line that don't contain the 'replace' string
+ ensure
+ print uri.chomp + "\0"
+ end
+end
View
@@ -2,7 +2,7 @@
# The host, URI (relative to the document root) and port to test.
host = localhost
-uri = /homepage
+#uri = /homepage
port = 80
# The 'rate' is the number of number of connections to open per second.
@@ -18,7 +18,7 @@ rate_step = 50
# wlog specifies a replay log file (null terminated requests paths)
# 'n' prefix tells httperf to stop after all requests in the file
# have been replayed
-# httperf_wlog = n,requests_httperf
+httperf_wlog = n,replay_log
# Autoperf can generate different wlog instructions for every run if
# you set wlog (not httperf_wlog) to a glob pattern of the files you

0 comments on commit d732e18

Please sign in to comment.