class Fluent::SstpOutput

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_sstp.rb, line 6
def initialize
  super
end

Public Instance Methods

build_message(tag, time, record) click to toggle source
# File lib/fluent/plugin/out_sstp.rb, line 41
    def build_message tag, time, record
      script = @script.result(binding)
      ERB.new(<<-'EOS'
<%= @request_method %> <%= @request_version %>
Sender: <%= @sender %>
Script: <%= script %>
Charset: UTF-8
        EOS
      ).result(binding).gsub("\n", "\r\n")
    end
configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_sstp.rb, line 17
def configure(conf)
  super

  @script = ERB.new(@script_template)
  raise "Unsupport post_type: #{@request_method}" unless @request_method == 'NOTIFY'
end
emit(tag, es, chain) click to toggle source
# File lib/fluent/plugin/out_sstp.rb, line 32
def emit(tag, es, chain)
  es.each {|time,record|
    message = build_message(tag, time, record)
    post message
  }

  chain.next
end
post(message) click to toggle source
# File lib/fluent/plugin/out_sstp.rb, line 52
def post(message)
  begin
    IO.popen("nc '#{@sstp_server}' '#{@sstp_port}'", 'w') do |io|
      io.puts message
    end
  rescue IOError, EOFError, SystemCallError
    # server didn't respond
    $log.warn "raises exception: #{$!.class}, '#{$!.message}'"
  end

  message
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_sstp.rb, line 28
def shutdown
  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_sstp.rb, line 24
def start
  super
end