Sha256: ad75f89393370e379bc9a77e2763ea0668810ddef1b3cb294f9cc5b858b3bc27
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
# encoding: utf-8 require "logstash/namespace" require "logstash/outputs/base" # The exec output will run a command for each event received. Ruby's # `system()` function will be used, i.e. the command string will # be passed to a shell. You can use `%{name}` and other dynamic strings # in the command to pass select fields from the event to the child # process. Example: # [source,ruby] # output { # if [type] == "abuse" { # exec { # command => "iptables -A INPUT -s %{clientip} -j DROP" # } # } # } # # WARNING: If you want it non-blocking you should use `&` or `dtach` # or other such techniques. There is no timeout for the commands being # run so misbehaving commands could otherwise stall the Logstash # pipeline indefinitely. # # WARNING: Exercise great caution with `%{name}` field placeholders. # The contents of the field will be included verbatim without any # sanitization, i.e. any shell metacharacters from the field values # will be passed straight to the shell. 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. This value can include `%{name}` and other # dynamic strings. 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
logstash-output-exec-3.0.1 | lib/logstash/outputs/exec.rb |
logstash-output-exec-3.0.0 | lib/logstash/outputs/exec.rb |
logstash-output-exec-2.0.4 | lib/logstash/outputs/exec.rb |