Created
May 2, 2012 16:19
-
-
Save bjpirt/2577899 to your computer and use it in GitHub Desktop.
Quick bucketing of PG logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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