Merge pull request #40 from nickethier/master

Exec Input
This commit is contained in:
Jordan Sissel 2011-08-16 21:09:36 -07:00
commit 9108268464

View file

@ -0,0 +1,34 @@
require "logstash/inputs/base"
require "logstash/namespace"
# Sample STDOUT from commands (ex. vmstat)
#
class LogStash::Inputs::Exec < LogStash::Inputs::Base
config_name "exec"
# Set this to true to enable debugging on an input.
config :debug, :validate => :boolean, :default => false
# Command to run
config :exec, :validate => :string, :required => true
# Period to run the command
config :period, :validate => :number, :required => true
public
def register
@logger.info(["Registering Exec Input", {:type => @type, :exec => @exec, :period => @period}])
end # def register
public
def run(queue)
while(1)
out = IO.popen(@exec)
e = to_event(out.read, @exec)
queue << e
sleep @period
end
end
end