Skip to content

Instantly share code, notes, and snippets.

@bjpirt
Created May 2, 2012 16:19
Show Gist options
  • Save bjpirt/2577899 to your computer and use it in GitHub Desktop.
Save bjpirt/2577899 to your computer and use it in GitHub Desktop.
Quick bucketing of PG logs
#!/usr/bin/env ruby
outputs = {}
STDIN.each_line do |line|
data = line.gsub(';', '').split(' ')
outputs[data[1].to_i] = [] unless outputs[data[1].to_i]
outputs[data[1].to_i] << data[0].to_f
end
outputs.keys.sort.each do |k|
v = outputs[k]
puts k
puts " Min: #{v.min}"
puts " Avg: #{v.inject{ |sum, el| sum + el }.to_f / v.size}"
puts " Max: #{v.max}"
end
cat pglog_oldskool | grep "SELECT \* " | cut -d " " -f 7,30 | ./bucket.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment