Class: LogStash::Outputs::Exec

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

Overview

This output will run a command for any matching event. Example:

source,ruby

output

exec {
  type => abuse
  command => "iptables -A INPUT -s %{clientip -j DROP"
}

}

Run subprocesses via system ruby function

WARNING: if you want it non-blocking you should use & or dtach or other such techniques

Instance Method Summary collapse

Instance Method Details

#receive(event) ⇒ Object



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

def receive(event)
  return unless output?(event)
  @logger.debug("running exec command", :command => event.sprintf(@command))
  system(event.sprintf(@command))
end

#registerObject



27
28
29
# File 'lib/logstash/outputs/exec.rb', line 27

def register
  @logger.debug("exec output registered", :config => @config)
end