Sha256: 378e200478fbb21e066ccd6330f71bb94664601f340cba609f5209d69c4a8df0

Contents?: true

Size: 980 Bytes

Versions: 5

Compression:

Stored size: 980 Bytes

Contents

# encoding: utf-8
require "logstash/namespace"
require "logstash/outputs/base"

# 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
class LogStash::Outputs::Exec < LogStash::Outputs::Base

  config_name "exec"

  # Command line to execute via subprocess. Use dtach or screen to make it non blocking
  config :command, :validate => :string, :required => true

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

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
logstash-output-exec-2.0.0 lib/logstash/outputs/exec.rb
logstash-output-exec-1.0.0 lib/logstash/outputs/exec.rb
logstash-output-exec-0.1.4 lib/logstash/outputs/exec.rb
logstash-output-exec-0.1.3 lib/logstash/outputs/exec.rb
logstash-output-exec-0.1.2 lib/logstash/outputs/exec.rb