Class: LogStash::Inputs::Exec

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/exec.rb

Overview

Periodically run a shell command and capture the whole output as an event.

Notes:

  • The ‘command` field of this event will be the command run.

  • The ‘message` field of this event will be the entire stdout of the command.

Instance Method Summary collapse

Instance Method Details

#inner_run(queue) ⇒ Object

def run



38
39
40
41
42
43
44
45
46
# File 'lib/logstash/inputs/exec.rb', line 38

def inner_run(queue)
  start = Time.now
  execute(@command, queue)
  duration = Time.now - start

  @logger.debug? && @logger.debug("Command completed", :command => @command, :duration => duration)

  wait_until_end_of_interval(duration)
end

#registerObject



26
27
28
29
30
# File 'lib/logstash/inputs/exec.rb', line 26

def register
  @logger.info("Registering Exec Input", :type => @type, :command => @command, :interval => @interval)
  @hostname = Socket.gethostname
  @io       = nil
end

#run(queue) ⇒ Object

def register



32
33
34
35
36
# File 'lib/logstash/inputs/exec.rb', line 32

def run(queue)
  while !stop?
    inner_run(queue)
  end # loop
end

#stopObject



48
49
50
51
52
# File 'lib/logstash/inputs/exec.rb', line 48

def stop
  return if @io.nil? || @io.closed?
  @io.close
  @io = nil
end