mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
commit
9108268464
1 changed files with 34 additions and 0 deletions
34
lib/logstash/inputs/exec.rb
Normal file
34
lib/logstash/inputs/exec.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue