Class: Munin::RailsRequests

Inherits:
RailsPlugin show all
Defined in:
lib/munin/plugins/rails_requests.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

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_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

#configObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/munin/plugins/rails_requests.rb', line 5

def config
  puts <<-CONFIG
graph_category #{graph_category}
graph_title Processed requests
graph_vlabel Requests per second
graph_info The amount of requests processed by this application server - railsdoctors.com

get.label get
get.draw AREA
post.label post
post.draw STACK
put.label put
put.draw STACK
delete.label delete
delete.draw STACK
CONFIG
  exit 0
end

#runObject

Gather information



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/munin/plugins/rails_requests.rb', line 25

def run
  ensure_log_file

  # Initialize values
  get_value     = 0
  post_value    = 0
  put_value     = 0
  delete_value  = 0

  # Walk through the 
  File.open(get_request_log_analyzer_file).each_line{ |line|
    if match = line.match(/^\s+GET\:\s(\d+).*/)
      get_value = match[1].to_i
    elsif match = line.match(/^\s+POST\:\s(\d+).*/)
      post_value = match[1].to_i
    elsif match = line.match(/^\s+PUT\:\s(\d+).*/)
      put_value = match[1].to_i
    elsif match = line.match(/^\s+DELETE\:\s(\d+).*/)
      delete_value = match[1].to_i
    end
  }

  puts "get.value #{get_value / interval.to_f}"
  puts "post.value #{post_value / interval.to_f}"
  puts "put.value #{put_value / interval.to_f}"
  puts "delete.value #{delete_value / interval.to_f}"
end