Method: Munin::RailsDatabaseTime#run

Defined in:
lib/munin/plugins/rails_database_time.rb

#runObject

Gather information



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/munin/plugins/rails_database_time.rb', line 21

def run
  ensure_log_file

  # Initialize values
  max_value = 0
  min_value = 1.0/0.0
  cumulative = 0
  hits = 0
  
  rla = parse_request_log_analyzer_data

  if rla && rla["Database time"]
    rla["Database time"].each do |item|
      max_value = item[1][:max] if item[1][:max] > max_value
      min_value = item[1][:min] if item[1][:min] < min_value
      hits += item[1][:hits]
      cumulative += item[1][:sum]
    end
  else
    hits = 1
    min_value = 0
  end

  # Report in seconds
  puts "max.value #{max_value}"
  puts "min.value #{min_value}"
  puts "average.value #{cumulative / hits.to_f}"
end