Sha256: 9ed731ab331c5df4cf820c4e9b6f776d0cb9c0eeb10d809e28c0f06dac191fc2

Contents?: true

Size: 952 Bytes

Versions: 2

Compression:

Stored size: 952 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)
    
    @logger.debug("running exec command", :command => event.sprintf(@command))
    system(event.sprintf(@command))
  end # def receive

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-output-exec-2.0.2 lib/logstash/outputs/exec.rb
logstash-output-exec-2.0.1 lib/logstash/outputs/exec.rb