Class: LogStash::Inputs::Exec
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Exec
- 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
-
#inner_run(queue) ⇒ Object
def run.
- #register ⇒ Object
-
#run(queue) ⇒ Object
def register.
- #stop ⇒ Object
Instance Method Details
#inner_run(queue) ⇒ Object
def run
41 42 43 44 45 46 47 48 49 |
# File 'lib/logstash/inputs/exec.rb', line 41 def inner_run(queue) start = Time.now execute(@command, queue) duration = Time.now - start @logger.info? && @logger.info("Command completed", :command => @command, :duration => duration) wait_until_end_of_interval(duration) end |
#register ⇒ Object
29 30 31 32 33 |
# File 'lib/logstash/inputs/exec.rb', line 29 def register @logger.info("Registering Exec Input", :type => @type, :command => @command, :interval => @interval) @hostname = Socket.gethostname @io = nil end |
#run(queue) ⇒ Object
def register
35 36 37 38 39 |
# File 'lib/logstash/inputs/exec.rb', line 35 def run(queue) while !stop? inner_run(queue) end # loop end |
#stop ⇒ Object
51 52 53 54 55 |
# File 'lib/logstash/inputs/exec.rb', line 51 def stop return if @io.nil? || @io.closed? @io.close @io = nil end |