Class: Fluent::SstpOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::SstpOutput
- Defined in:
- lib/fluent/plugin/out_sstp.rb
Instance Method Summary collapse
- #build_message(tag, time, record) ⇒ Object
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ SstpOutput
constructor
A new instance of SstpOutput.
- #post(message) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ SstpOutput
Returns a new instance of SstpOutput.
6 7 8 |
# File 'lib/fluent/plugin/out_sstp.rb', line 6 def initialize super end |
Instance Method Details
#build_message(tag, time, record) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fluent/plugin/out_sstp.rb', line 41 def tag, time, record script = @script.result(binding) ERB.new("<%= @request_method %> <%= @request_version %>\nSender: <%= @sender %>\nScript: <%= script %>\nCharset: UTF-8\n EOS\n ).result(binding).gsub(\"\\n\", \"\\r\\n\")\nend\n" |
#configure(conf) ⇒ Object
17 18 19 20 21 22 |
# 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) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fluent/plugin/out_sstp.rb', line 32 def emit(tag, es, chain) es.each {|time,record| = (tag, time, record) post } chain.next end |
#post(message) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fluent/plugin/out_sstp.rb', line 52 def post() begin IO.popen("nc '#{@sstp_server}' '#{@sstp_port}'", 'w') do |io| io.puts end rescue IOError, EOFError, SystemCallError # server didn't respond $log.warn "raises exception: #{$!.class}, '#{$!.message}'" end end |
#shutdown ⇒ Object
28 29 30 |
# File 'lib/fluent/plugin/out_sstp.rb', line 28 def shutdown super end |
#start ⇒ Object
24 25 26 |
# File 'lib/fluent/plugin/out_sstp.rb', line 24 def start super end |