Skip to content

Instantly share code, notes, and snippets.

@banesto
Created November 3, 2016 13:25
Show Gist options
  • Save banesto/1cd768c769b1e412d279677a1127217c to your computer and use it in GitHub Desktop.
Save banesto/1cd768c769b1e412d279677a1127217c to your computer and use it in GitHub Desktop.
# Usage:
# cat <environment>.log | grep Load | grep SELECT | ruby filter.rb
MAX_TIME = 300.0
h = {}
STDIN.read.split("\n").each do |line|
list = line.split(' ')
time = list[2].scan(/\((.*)\./).flatten[0].to_f
h[list[3]] = time
end
h.sort_by{ |query, time| time }.reverse.select{ |query, time| time > MAX_TIME }.each do |query, time|
puts "#{time} - #{query}"
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment