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
- #register ⇒ Object
-
#run(queue) ⇒ Object
def register.
-
#stop ⇒ Object
def run.
Instance Method Details
#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 40 41 42 43 44 45 46 |
# File 'lib/logstash/inputs/exec.rb', line 35 def run(queue) while !stop? start = Time.now execute(@command) duration = Time.now - start @logger.info? && @logger.info("Command completed", :command => @command, :duration => duration) wait_until_end_of_interval(duration) end # loop end |
#stop ⇒ Object
def run
48 49 50 51 52 53 |
# File 'lib/logstash/inputs/exec.rb', line 48 def stop if @io @io.close @io = nil end end |