Class: LogStash::Outputs::Exec

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

Overview

This output will run a command for any matching event.

Example:

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

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

This class inherits a constructor from LogStash::Outputs::Base

Instance Method Details

#receive(event) ⇒ Object



34
35
36
37
38
# File 'lib/logstash/outputs/exec.rb', line 34

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

#registerObject



29
30
31
# File 'lib/logstash/outputs/exec.rb', line 29

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