Class: Munin::RailsDatabaseTime
- Inherits:
-
RailsPlugin
- Object
- RequestLogAnalyzerPlugin
- RailsPlugin
- Munin::RailsDatabaseTime
- Defined in:
- lib/munin/plugins/rails_database_time.rb
Instance Attribute Summary
Attributes inherited from RailsPlugin
#after_time, #floor_time, #interval, #log_file, #log_format, #number_of_lines, #request_log_analyzer, #temp_file_name, #temp_folder, #temp_prefix
Attributes inherited from RequestLogAnalyzerPlugin
#debug, #environment, #graph_category, #passenger_memory_stats, #passenger_status
Instance Method Summary collapse
- #config ⇒ Object
-
#run ⇒ Object
Gather information.
Methods inherited from RailsPlugin
#ensure_configuration, #ensure_log_file, #fetch_or_create_yaml_file, #get_request_log_analyzer_file, #handle_arguments, #parse_request_log_analyzer_data
Methods inherited from RequestLogAnalyzerPlugin
#autoconf, #ensure_configuration, #handle_arguments, #initialize, #require_command, #require_gem, #require_passenger_gem, #require_passenger_memory_stats, #require_passenger_status, #require_request_log_analyzer_gem, #require_tail_command, #require_yaml_gem, #run_command
Constructor Details
This class inherits a constructor from Munin::RequestLogAnalyzerPlugin
Instance Method Details
#config ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/munin/plugins/rails_database_time.rb', line 3 def config puts <<-CONFIG graph_category #{graph_category} graph_title Database time graph_vlabel Seconds graph_args --base 1000 -l 0 graph_info The minimum, maximum and average database times - railsdoctors.com min.label min max.label max average.label avg CONFIG exit 0 end |
#run ⇒ Object
Gather information
19 20 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 |
# File 'lib/munin/plugins/rails_database_time.rb', line 19 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 |