fluent-plugin-sflow 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8baabdbaaf5caeda2f0f5eee9493bf88a816b137
4
- data.tar.gz: 6d892b0e7cf8089ff152edfa0df98aefc4224bdc
3
+ metadata.gz: 0447a8846e6a71d5994fcf1c284e510b01991853
4
+ data.tar.gz: 8541fea3c74f3ebbe2c00fcb9b7867f702b228d4
5
5
  SHA512:
6
- metadata.gz: b0f9b0ea023f761018a08e446b463da2a8f382ab827775a74704f19c6346a30b523d8f880e47330c0ac8ea4328d8fb2258983d1c0a1bb3a5a7acda35bed900db
7
- data.tar.gz: 715c67e8dc992fc6e450a280e3b0fb0084c554031c1f8a128831031b96bbdd0c97b3b1fedd4239bbbb68e4ef4d8aeac5b7e7f63d9dd5c7ee3c6b709836aee889
6
+ metadata.gz: af658e53d271282c0e1b8a11525c82ad6744a1cb5e424b2e99444346fa5dca2943b8203242e502dd5cc92a9ac8cb2288006fc0436afb4f88d11f94ee67ae96b9
7
+ data.tar.gz: c790adea5b9e909c371e9e86cf41a6cc044e42a3fef203d44bc3f99edca004356cb57b06151f5e5729cad3af497df7b5081d01a2738eb8c492b04b91cdbffe72
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # fluent-plugin-sflow
2
2
 
3
- [![Build Status](https://travis-ci.org/codeout/fluent-plugin-sflow.svg?branch=master)](https://travis-ci.org/codeout/fluent-plugin-sflow)
3
+ [![Build Status](https://travis-ci.org/codeout/fluent-plugin-sflow.svg?branch=fluentd-0.14)](https://travis-ci.org/codeout/fluent-plugin-sflow)
4
4
 
5
- ## This branch is valid only for Fluentd 0.12.40 or later
5
+ ## This branch is valid only for Fluentd 0.14.x
6
6
 
7
- See [0.14.x branch](https://github.com/codeout/fluent-plugin-sflow/tree/fluentd-0.14) for Fluentd 0.14.x.
7
+ See [0.12.x branch](https://github.com/codeout/fluent-plugin-sflow) for Fluentd 0.12.x.
8
8
 
9
9
  ## Overview
10
10
 
@@ -103,13 +103,13 @@ See [sflowtool document](http://www.inmon.com/technology/sflowTools.php) for mor
103
103
 
104
104
  ## Requirement
105
105
 
106
- * Fluentd: 0.12.40 or later
107
- * See [0.14.x branch](https://github.com/codeout/fluent-plugin-sflow/tree/fluentd-0.14) for Fluentd 0.14.x.
106
+ * Fluentd: 0.14.x
107
+ * See [0.12.x](https://github.com/codeout/fluent-plugin-sflow) branch for Fluentd 0.12.x.
108
108
 
109
109
  ## Install
110
110
 
111
111
  ``` shell
112
- $ gem install fluent-plugin-sflow -v '~> 0.2.0'
112
+ $ gem install fluent-plugin-sflow
113
113
  ```
114
114
 
115
115
  You can also use ```fluent-gem``` or ```td-agent-gem``` instead of ```gem``` command.
@@ -248,8 +248,8 @@ UDP port number on which this plugin will accept sFlow.
248
248
  Here is a quick benchmark on Macbook Pro Mid 2015:
249
249
 
250
250
  * sFlow v5 flow samples, 5.88 samples per packet in average
251
- * Fluentd v0.12.40
252
- * 14202 sFlow v5 records/s
251
+ * Fluentd v0.14.17
252
+ * 13161 sFlow v5 records/s
253
253
 
254
254
 
255
255
  ## TODO
@@ -2500,7 +2500,7 @@ static void readExtendedTCPInfo(SFSample *sample)
2500
2500
  case PKTDIR_sent: direction = "sent"; break;
2501
2501
  default: direction = "<bad value>"; break;
2502
2502
  }
2503
- sf_log(sample, "\"tcpinfo_direction\":\"%s\",", direction);
2503
+ sf_log(sample, "tcpinfo_direction\":\"%s\",", direction);
2504
2504
  sf_log_next32(sample, "tcpinfo_send_mss");
2505
2505
  sf_log_next32(sample, "tcpinfo_receive_mss");
2506
2506
  sf_log_next32(sample, "tcpinfo_unacked_pkts");
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-sflow"
7
- spec.version = "0.2.1"
7
+ spec.version = "0.3.0"
8
8
  spec.authors = ["Shintaro Kojima"]
9
9
  spec.email = ["goodies@codeout.net"]
10
10
 
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
  spec.extensions = ["ext/sflowtool/extconf.rb"]
22
22
 
23
- spec.add_dependency "fluentd", "~> 0.12.40"
23
+ spec.add_dependency "fluentd", "~>0.14.0"
24
24
  spec.add_development_dependency "bundler", "~> 1.12"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rake-compiler", "~> 1.0"
@@ -1,10 +1,12 @@
1
- require 'cool.io'
1
+ require 'fluent/plugin/input'
2
2
  require 'fluent/plugin/parser_sflow'
3
3
 
4
4
 
5
- module Fluent
5
+ module Fluent::Plugin
6
6
  class SflowInput < Input
7
- Plugin.register_input('sflow', self)
7
+ Fluent::Plugin.register_input('sflow', self)
8
+
9
+ helpers :server
8
10
 
9
11
  config_param :bind, :string, default: '0.0.0.0'
10
12
  config_param :port, :integer, default: 6343
@@ -14,31 +16,14 @@ module Fluent
14
16
 
15
17
  def configure(conf)
16
18
  super
17
- @parser = Fluent::TextParser::SflowParser.new
19
+ @parser = Fluent::Plugin::SflowParser.new
18
20
  end
19
21
 
20
22
  def start
21
23
  super
22
- @loop = Coolio::Loop.new
23
- @handler = listen(method(:receive))
24
- @loop.attach @handler
25
-
26
- @thread = Thread.new(&method(:run))
27
- end
28
-
29
- def shutdown
30
- @loop.watchers.each {|w| w.detach }
31
- @loop.stop
32
- @handler.close
33
- @thread.join
34
- super
35
- end
36
-
37
- def run
38
- @loop.run
39
- rescue
40
- log.error 'unexpected error', error_class: $!.class, error: $!.message
41
- log.error_backtrace
24
+ server_create(:in_sflow_server, @port, proto: :udp, bind: @bind, max_bytes: @max_bytes) do |data, sock|
25
+ receive(data, sock.remote_host)
26
+ end
42
27
  end
43
28
 
44
29
 
@@ -61,28 +46,5 @@ module Fluent
61
46
  log.warn 'Unexpected error on parsing',
62
47
  raw: raw, exporter: exporter, error_class: $!.class, error: $!.message
63
48
  end
64
-
65
-
66
- private
67
-
68
- def listen(callback)
69
- log.info "listening sflow socket on #{@bind}:#{@port}"
70
- @sock = SocketUtil.create_udp_socket(@bind)
71
- @sock.bind @bind, @port
72
- UdpHandler.new @sock, callback
73
- end
74
-
75
- class UdpHandler < Coolio::IO
76
- def initialize(io, callback)
77
- super io
78
- @io = io
79
- @callback = callback
80
- end
81
-
82
- def on_readable
83
- msg, addr = @io.recvfrom_nonblock(4096)
84
- @callback.call msg, addr[3]
85
- end
86
- end
87
49
  end
88
50
  end
@@ -1,10 +1,11 @@
1
- require 'fluent/parser'
1
+ require 'fluent/plugin/parser'
2
+ require 'fluent/time'
2
3
  require 'json'
3
4
  require 'sflowtool'
4
5
 
5
6
 
6
7
  module Fluent
7
- class TextParser
8
+ module Plugin
8
9
  class SflowParser < Parser
9
10
  Plugin.register_parser('sflow', self)
10
11
 
@@ -13,7 +14,7 @@ module Fluent
13
14
  data = JSON.load(Sflowtool.parse(raw, remote_host))
14
15
 
15
16
  # NOTE: sFlow datagram doesn't have timestamp field, but sysUpTime only
16
- time = data['header']['unix_seconds_utc']
17
+ time = Fluent::EventTime.new(data['header']['unix_seconds_utc'])
17
18
 
18
19
  data['samples'].each do |sample|
19
20
  yield time, data['header'].merge(sample)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shintaro Kojima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-09 00:00:00.000000000 Z
11
+ date: 2017-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.12.40
19
+ version: 0.14.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.12.40
26
+ version: 0.14.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement