Sha256: 31a8de48a5ae17c0085cee2e33939a23955e4b04213686100fcbc528003b7722
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
require 'fluent/plugin/input' require 'fluent/plugin/parser_sflow' module Fluent::Plugin class SflowInput < Input Fluent::Plugin.register_input('sflow', self) helpers :server config_param :bind, :string, default: '0.0.0.0' config_param :port, :integer, default: 6343 config_param :tag, :string config_param :max_bytes, :integer, default: 2048 def configure(conf) super @parser = Fluent::Plugin::SflowParser.new end def start super server_create(:in_sflow_server, @port, proto: :udp, bind: @bind, max_bytes: @max_bytes) do |data, sock| receive(data, sock.remote_host) end end protected def receive(raw, exporter) log.on_debug do log.debug 'received sflow datagram', raw: raw, exporter: exporter end @parser.parse(raw, exporter) do |time, record| if !time || !record log.warn 'Failed to parse', raw: raw, exporter: exporter return end router.emit(@tag, time, record) end rescue log.warn 'Unexpected error on parsing', raw: raw, exporter: exporter, error_class: $!.class, error: $!.message end end end
Version data entries
4 entries across 4 versions & 1 rubygems