diff --git a/squirrel/replay.rb b/squirrel/replay.rb index afaf067..411ea6e 100755 --- a/squirrel/replay.rb +++ b/squirrel/replay.rb @@ -120,10 +120,11 @@ def parse_logline(line, metaArray) ######################################################################################################################## class Replay - def initialize(logfile, host, port) + def initialize(logfile, host, port, preference) @logfile = logfile @host = host @port = port + @preference = preference end def header() @@ -151,6 +152,14 @@ def output(query, data, malformed=false) end end + def build_curl_command_string() + base_uri = "#{@host}:#{@port}/#{data['index']}/_search/" + if @preference[0] + base_uri.concat(@preference[1]) + end + puts base_uri + end + ######################################################################################################################## # Execute slow query from log # ######################################################################################################################## @@ -161,12 +170,13 @@ def execute_query(query, data) data['new_timestamp'] = Time.now data['new_start_time'] = Time.now.to_f * 1000 #puts "curl -s -XGET #{Settings.host}:#{Settings.port}/#{data['index']}/_search/ -d '#{query}'" - curl_result = `curl -s -XGET '#{@host}:#{@port}/#{data['index']}/_search/' -d '#{query}'` - data['new_end_time'] = Time.now.to_f * 1000 - data['new_duration'] = data['new_end_time'] - data['new_start_time'] - data['original_dur'] = data['took'] - data = data.merge(JSON.parse(curl_result)) - output(query, data) + build_curl_command_string + #curl_result = `curl -s -XGET '#{@host}:#{@port}/#{data['index']}/_search/' -d '#{query}'` + #data['new_end_time'] = Time.now.to_f * 1000 + #data['new_duration'] = data['new_end_time'] - data['new_start_time'] + #data['original_dur'] = data['took'] + #data = data.merge(JSON.parse(curl_result)) + #output(query, data) else puts "error don't know search type, please throw an exception here" end