Class: Fluent::Plugin::ExecInput
- Defined in:
- lib/fluent/plugin/in_exec.rb
Constant Summary
Constants included from Configurable
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary
Attributes included from Fluent::PluginLoggerMixin
Attributes inherited from Base
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ ExecInput
constructor
A new instance of ExecInput.
- #run(io) ⇒ Object
- #setup_parser(conf) ⇒ Object
- #start ⇒ Object
Methods included from Fluent::PluginHelper::Mixin
Methods included from Fluent::PluginLoggerMixin
Methods included from Fluent::PluginId
#plugin_id, #plugin_id_configured?, #plugin_id_for_test?
Methods inherited from Base
#after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #close, #closed?, #configured?, #has_router?, #inspect, #shutdown, #shutdown?, #started?, #stop, #stopped?, #terminate, #terminated?
Methods included from SystemConfig::Mixin
#system_config, #system_config_override
Methods included from Configurable
#config, included, lookup_type, register_type
Constructor Details
#initialize ⇒ ExecInput
Returns a new instance of ExecInput.
31 32 33 34 |
# File 'lib/fluent/plugin/in_exec.rb', line 31 def initialize super require 'fluent/plugin/exec_util' end |
Instance Method Details
#configure(conf) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fluent/plugin/in_exec.rb', line 55 def configure(conf) super if conf['localtime'] @localtime = true elsif conf['utc'] @localtime = false end if conf['timezone'] @timezone = conf['timezone'] Fluent::Timezone.validate!(@timezone) end if !@tag && !@tag_key raise Fleunt::ConfigError, "'tag' or 'tag_key' option is required on exec input" end if @time_key if @time_format f = @time_format @time_parse_proc = begin strptime = Strptime.new(f) Proc.new { |str| Fluent::EventTime.from_time(strptime.exec(str)) } rescue Proc.new {|str| Fluent::EventTime.from_time(Time.strptime(str, f)) } end else @time_parse_proc = Proc.new {|str| Fluent::EventTime.from_time(Time.at(str.to_f)) } end end @parser = setup_parser(conf) end |
#run(io) ⇒ Object
121 122 123 |
# File 'lib/fluent/plugin/in_exec.rb', line 121 def run(io) @parser.call(io) end |
#setup_parser(conf) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/fluent/plugin/in_exec.rb', line 91 def setup_parser(conf) case @format when 'tsv' if @keys.empty? raise Fluent::ConfigError, "keys option is required on exec input for tsv format" end Fluent::ExecUtil::TSVParser.new(@keys, method(:on_message)) when 'json' Fluent::ExecUtil::JSONParser.new(method(:on_message)) when 'msgpack' Fluent::ExecUtil::MessagePackParser.new(method(:on_message)) else Fluent::ExecUtil::TextParserWrapperParser.new(conf, method(:on_message)) end end |
#start ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/fluent/plugin/in_exec.rb', line 107 def start super if @run_interval child_process_execute(:exec_input, @command, interval: @run_interval, mode: [:read]) do |io| run(io) end else child_process_execute(:exec_input, @command, immediate: true, mode: [:read]) do |io| run(io) end end end |