Class: Munin::Command
- Inherits:
-
Object
- Object
- Munin::Command
- Defined in:
- lib/munin/command.rb
Constant Summary collapse
- PASSENGER_PLUGINS =
%W{munin_passenger_memory_stats munin_passenger_queue munin_passenger_status}
- RAILS_PLUGINS =
%W{munin_rails_database_time munin_rails_request_duration munin_rails_request_error munin_rails_requests munin_rails_view_render_time}
- PASSENGER_PLUGIN_CONFIG =
<<-DATA [<%= plugin_target_name %>] user root command /usr/local/bin/ruby %c env.passenger_status '/usr/local/bin/passenger-status' env.passenger_memory_stats '/usr/local/bin/passenger-memory-stats' env.graph_category Passenger DATA
- RAILS_PLUGIN_CONFIG =
<<-DATA [<%= plugin_target_name %>] env.log_file <%= options[:log_file] %> user root command /usr/local/bin/ruby %c env.request_log_analyzer /usr/local/bin/request-log-analyzer env.graph_category <%= plugin_target_name %> DATA
Instance Method Summary collapse
- #add_plugin(plugin_file, plugin_target_name = nil) ⇒ Object
- #add_plugin_config(plugin_target_name, config_template, options = {}) ⇒ Object
- #install_application(args) ⇒ Object
- #install_passenger_plugins ⇒ Object
- #munin_dir ⇒ Object
- #munin_plugin_config_path ⇒ Object
- #munin_plugins_path ⇒ Object
- #run(args) ⇒ Object
Instance Method Details
#add_plugin(plugin_file, plugin_target_name = nil) ⇒ Object
59 60 61 62 63 |
# File 'lib/munin/command.rb', line 59 def add_plugin(plugin_file, plugin_target_name = nil) FileUtils.mkdir_p(munin_plugins_path) plugin_target_name ||= plugin_file `ln -nsf "#{File.join(munin_dir, plugin_file)}" "#{munin_plugins_path}/#{plugin_target_name}"` end |
#add_plugin_config(plugin_target_name, config_template, options = {}) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/munin/command.rb', line 51 def add_plugin_config(plugin_target_name, config_template, = {}) FileUtils.mkdir_p(munin_plugin_config_path) template = ERB.new config_template File.open(File.join(munin_plugin_config_path, plugin_target_name), "w+") do |file| file << template.result(binding) end end |
#install_application(args) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/munin/command.rb', line 34 def install_application(args) app_name = args.shift log_file = args.shift RAILS_PLUGINS.each do |plugin| plugin_target_name = [app_name, plugin].join("_") add_plugin(plugin, plugin_target_name) add_plugin_config(plugin_target_name, RAILS_PLUGIN_CONFIG, :log_file => log_file) end end |
#install_passenger_plugins ⇒ Object
44 45 46 47 48 49 |
# File 'lib/munin/command.rb', line 44 def install_passenger_plugins PASSENGER_PLUGINS.each do |plugin| add_plugin(plugin, plugin) add_plugin_config(plugin, PASSENGER_PLUGIN_CONFIG) end end |
#munin_dir ⇒ Object
73 74 75 |
# File 'lib/munin/command.rb', line 73 def munin_dir File.join(File.dirname(__FILE__), "..", "..", "munin") end |
#munin_plugin_config_path ⇒ Object
69 70 71 |
# File 'lib/munin/command.rb', line 69 def munin_plugin_config_path "/etc/munin/plugin-conf.d" end |
#munin_plugins_path ⇒ Object
65 66 67 |
# File 'lib/munin/command.rb', line 65 def munin_plugins_path "/etc/munin/plugins" end |
#run(args) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/munin/command.rb', line 5 def run(args) if args.first == "install" install_passenger_plugins elsif args.first == "add" args.shift install_application(args) end end |