Class: Fluent::Plugin::SstpOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::SstpOutput
- Defined in:
- lib/fluent/plugin/out_sstp.rb
Instance Method Summary collapse
- #build_message(tag, time, record) ⇒ Object
- #configure(conf) ⇒ Object
- #post(message) ⇒ Object
- #process(tag, es) ⇒ Object
Instance Method Details
#build_message(tag, time, record) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fluent/plugin/out_sstp.rb', line 32 def (tag, time, record) # Generate the script content using the template rendered_script = @script_erb.result(binding) # Build the complete SSTP message ERB.new("<%= @request_method %> <%= @request_version %>\nSender: <%= @sender %>\nOption: <%= @option %>\nScript: <%= rendered_script %>\nCharset: UTF-8\n EOS\n ).result(binding).gsub(\"\\n\", \"\\r\\n\")\nend\n" |
#configure(conf) ⇒ Object
19 20 21 22 23 |
# File 'lib/fluent/plugin/out_sstp.rb', line 19 def configure(conf) super @script_erb = ERB.new(@script_template) raise Fluent::ConfigError, "Unsupported request_method: #{@request_method}" unless @request_method == 'NOTIFY' end |
#post(message) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fluent/plugin/out_sstp.rb', line 47 def post() begin socket = TCPSocket.new(@sstp_server, @sstp_port) socket.puts() socket.close rescue => e log.warn "Failed to send SSTP message: #{e.class}, '#{e.message}'" end end |
#process(tag, es) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/fluent/plugin/out_sstp.rb', line 25 def process(tag, es) es.each do |time, record| = (tag, time, record) post() end end |