Parent

Class/Module Index [+]

Quicksearch

Fluent::MonitorAgentInput

Constants

MONITOR_INFO

Public Class Methods

collect_children(pe, array=[]) click to toggle source

get nexted plugins (such as <store> of the copy plugin) from the plugin `pe` recursively

# File lib/fluent/plugin/in_monitor_agent.rb, line 209
def self.collect_children(pe, array=[])
  array << pe
  if pe.is_a?(MultiOutput) && pe.respond_to?(:outputs)
    pe.outputs.each {|nop|
      collect_children(nop, array)
    }
  end
  array
end
new() click to toggle source
# File lib/fluent/plugin/in_monitor_agent.rb, line 25
def initialize
  require 'cgi'
  super
end

Public Instance Methods

all_plugins() click to toggle source
# File lib/fluent/plugin/in_monitor_agent.rb, line 193
def all_plugins
  array = []

  # get all input plugins
  array.concat Engine.sources

  # get all output plugins
  Engine.matches.each {|m|
    MonitorAgentInput.collect_children(m.output, array)
  }

  array
end
get_monitor_info(pe, opts={}) click to toggle source

get monitor info from the plugin `pe` and return a hash object

# File lib/fluent/plugin/in_monitor_agent.rb, line 261
def get_monitor_info(pe, opts={})
  obj = {}

  # run MONITOR_INFO in plugins' instance context and store the info to obj
  MONITOR_INFO.each_pair {|key,code|
    begin
      obj[key] = pe.instance_eval(code)
    rescue
    end
  }

  # include all instance variables if :with_debug_info is set
  if opts[:with_debug_info]
    iv = {}
    pe.instance_eval do
      instance_variables.each {|sym|
        key = sym.to_s[1..-1]  # removes first '@'
        iv[key] = instance_variable_get(sym)
      }
    end
    obj['instance_variables'] = iv
  end

  obj
end
plugin_info_by_id(plugin_id, opts={}) click to toggle source

search a plugin by plugin_id

# File lib/fluent/plugin/in_monitor_agent.rb, line 232
def plugin_info_by_id(plugin_id, opts={})
  found = all_plugins.find {|pe|
    pe.respond_to?(:plugin_id) && pe.plugin_id.to_s == plugin_id
  }
  if found
    get_monitor_info(found, opts)
  else
    nil
  end
end
plugin_info_by_tag(tag, opts={}) click to toggle source

try to match the tag and get the info from the matched output plugin

# File lib/fluent/plugin/in_monitor_agent.rb, line 221
def plugin_info_by_tag(tag, opts={})
  m = Engine.match(tag)
  if m
    pe = m.output
    get_monitor_info(pe, opts)
  else
    nil
  end
end
plugins_info_all(opts={}) click to toggle source
# File lib/fluent/plugin/in_monitor_agent.rb, line 254
def plugins_info_all(opts={})
  all_plugins.map {|pe|
    get_monitor_info(pe, opts)
  }
end
plugins_info_by_type(type, opts={}) click to toggle source

This method returns an array because multiple plugins could have the same type

# File lib/fluent/plugin/in_monitor_agent.rb, line 245
def plugins_info_by_type(type, opts={})
  array = all_plugins.select {|pe|
    pe.config['type'] == type rescue nil
  }
  array.map {|pe|
    get_monitor_info(pe, opts)
  }
end
shutdown() click to toggle source
# File lib/fluent/plugin/in_monitor_agent.rb, line 172
def shutdown
  if @srv
    @srv.shutdown
    @srv = nil
  end
  if @thread
    @thread.join
    @thread = nil
  end
end
start() click to toggle source
# File lib/fluent/plugin/in_monitor_agent.rb, line 157
def start
  $log.debug "listening monitoring http server on http://#{@bind}:#{@port}/api/plugins"
  @srv = WEBrick::HTTPServer.new({
    :BindAddress => @bind,
    :Port => @port,
    :Logger => WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
    :AccessLog => [],
  })
  @srv.mount('/api/plugins', LTSVMonitorServlet, self)
  @srv.mount('/api/plugins.json', JSONMonitorServlet, self)
  @thread = Thread.new {
    @srv.start
  }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.