Class: LogStash::Inputs::Pipe
- Defined in:
- lib/logstash/inputs/pipe.rb
Overview
Stream events from a long running command pipe.
By default, each event is assumed to be one line. If you want to join lines, you’ll want to use the multiline filter.
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Inputs::Base
Instance Method Details
#register ⇒ Object
27 28 29 |
# File 'lib/logstash/inputs/pipe.rb', line 27 def register @logger.info("Registering pipe input", :command => @command) end |
#run(queue) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/logstash/inputs/pipe.rb', line 32 def run(queue) loop do begin @pipe = IO.popen(@command, mode="r") hostname = Socket.gethostname @pipe.each do |line| line = line.chomp source = "pipe://#{hostname}/#{@command}" @logger.debug? && @logger.debug("Received line", :command => @command, :line => line) @codec.decode(line) do |event| event["host"] = hostname event["command"] = @command decorate(event) queue << event end end rescue Exception => e @logger.error("Exception while running command", :e => e, :backtrace => e.backtrace) end # Keep running the command forever. sleep(10) end end |