fluent-plugin-sflow 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.gitmodules +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/fluentd.conf +9 -0
- data/fluent-plugin-sflow.gemspec +42 -0
- data/lib/fluent/plugin/in_sflow.rb +45 -0
- data/lib/sflow/Gemfile +8 -0
- data/lib/sflow/Gemfile.lock +38 -0
- data/lib/sflow/LICENSE.txt +22 -0
- data/lib/sflow/README.md +67 -0
- data/lib/sflow/Rakefile +12 -0
- data/lib/sflow/bin/bundler +16 -0
- data/lib/sflow/bin/rake +16 -0
- data/lib/sflow/bin/sflow.rb +7 -0
- data/lib/sflow/etc/config.yaml +10 -0
- data/lib/sflow/lib/sflow.rb +10 -0
- data/lib/sflow/lib/sflow/collector.rb +69 -0
- data/lib/sflow/lib/sflow/config.rb +15 -0
- data/lib/sflow/lib/sflow/models/binary_models.rb +176 -0
- data/lib/sflow/lib/sflow/models/ipv4header.rb +69 -0
- data/lib/sflow/lib/sflow/models/protocol.rb +47 -0
- data/lib/sflow/lib/sflow/models/tcpheader.rb +82 -0
- data/lib/sflow/lib/sflow/models/udpheader.rb +36 -0
- data/lib/sflow/lib/sflow/parsers/parsers.rb +68 -0
- data/lib/sflow/lib/sflow/snmp/iface_names.rb +40 -0
- data/lib/sflow/lib/sflow/storage/storage.rb +34 -0
- data/lib/sflow/lib/sflow/version.rb +3 -0
- data/lib/sflow/misc/kibana-schema.json +1364 -0
- data/lib/sflow/misc/screen1.png +0 -0
- data/lib/sflow/sflow.gemspec +23 -0
- data/lib/sflow/test/lib/sflow/version_test.rb +8 -0
- data/lib/sflow/test/test_helper.rb +4 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d9c3c885041bedb4c217b540403169ced547ce9b
|
4
|
+
data.tar.gz: 77b1c300fac1ed1ac74fc4eb94b5b957caca45de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bde1017e8f337f70fdcb14d41585d1aceec7e9095805085adf284359ae41d35f8f3ef1f1a4910718a920fe834a3c9e4913405daa4364e0d4d30e0931fbfb5e8
|
7
|
+
data.tar.gz: a0d3e198ed3619d5b9dcabce56634501d63eb27b57e3ad0d8da7efc0ac1c4963f0864398931441fd2e0db5df4fc8e299341dc0dd9d02fdb99c715035bc601a58
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 enukane
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## Overview
|
2
|
+
|
3
|
+
[Fluentd](http://fluentd.org/) input plugin that acts as sFlow collector.
|
4
|
+
sFlow parser is based on [NETWAYS/sflow](https://github.com/NETWAYS/sflow/).
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Use RubyGems:
|
10
|
+
|
11
|
+
```
|
12
|
+
fluent-gem install fluent-plugin-sflow
|
13
|
+
```
|
14
|
+
|
15
|
+
## Configuration
|
16
|
+
|
17
|
+
```
|
18
|
+
<source>
|
19
|
+
@type sflow
|
20
|
+
bind 0.0.0.0
|
21
|
+
tag example.sflow
|
22
|
+
</source>
|
23
|
+
|
24
|
+
<match example.sflow>
|
25
|
+
@type stdout
|
26
|
+
</match>
|
27
|
+
```
|
28
|
+
|
29
|
+
**bind**
|
30
|
+
|
31
|
+
IP address on which this plugin will accept sFlow. Default is "0.0.0.0".
|
32
|
+
|
33
|
+
**port**
|
34
|
+
|
35
|
+
UDP port number on which this plugin will accept sFlow. Default is 6343.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fluent/plugin/sflow"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-sflow"
|
7
|
+
spec.version = "0.1.0"
|
8
|
+
spec.authors = ["enukane"]
|
9
|
+
spec.email = ["enukane@glenda9.org"]
|
10
|
+
|
11
|
+
spec.summary = %q{sFlow plugin for Fluentd}
|
12
|
+
spec.description = %q{sFlow input plugin for Fluentd}
|
13
|
+
spec.homepage = "https://github.com/enukane/fluent-plugin-sflow"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
gem_dir = File.expand_path(File.dirname(__FILE__)) + "/"
|
20
|
+
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
21
|
+
Dir.chdir(submodule_path) do
|
22
|
+
submodule_relative_path = submodule_path.sub gem_dir, ""
|
23
|
+
# issue git ls-files in submodule's directory and
|
24
|
+
# prepend the submodule path to create absolute file paths
|
25
|
+
`git ls-files`.split($\).each do |filename|
|
26
|
+
spec.files << "#{submodule_relative_path}/#{filename}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
37
|
+
spec.add_development_dependency "test-unit"
|
38
|
+
|
39
|
+
spec.add_dependency "fluentd", "~> 0.14.10"
|
40
|
+
spec.add_dependency "bindata", "1.8.1"
|
41
|
+
spec.add_dependency "eventmachine", "~> 1.2.3"
|
42
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'fluent/plugin/input'
|
2
|
+
|
3
|
+
require 'bindata'
|
4
|
+
require 'eventmachine'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
dir = 'sflow/lib/sflow'
|
8
|
+
['models/ipv4header', 'models/tcpheader', 'models/udpheader', 'models/protocol', 'models/binary_models','parsers/parsers'].each do |req|
|
9
|
+
require File.join(dir, req)
|
10
|
+
end
|
11
|
+
|
12
|
+
#$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'sflow', 'lib'))
|
13
|
+
#require 'sflow'
|
14
|
+
|
15
|
+
module Fluent::Plugin
|
16
|
+
class SflowInput < Input
|
17
|
+
Fluent::Plugin.register_input("sflow", self)
|
18
|
+
|
19
|
+
helpers :server
|
20
|
+
|
21
|
+
config_param :bind, :string, default: '0.0.0.0'
|
22
|
+
config_param :port, :integer, default: 6343
|
23
|
+
config_param :tag, :string
|
24
|
+
|
25
|
+
def configure(conf)
|
26
|
+
super
|
27
|
+
|
28
|
+
# dummy data
|
29
|
+
$switch_hash = {}
|
30
|
+
end
|
31
|
+
|
32
|
+
def start
|
33
|
+
super
|
34
|
+
|
35
|
+
server_create(:in_sflow_server, @port, bind: @bind, proto: :udp, max_bytes: 2048) do |data, sock|
|
36
|
+
sflow = SflowParser.parse_packet(data)
|
37
|
+
router.emit(@tag, Fluent::EventTime.now, sflow)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def shutdown
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/sflow/Gemfile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sflow (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
bindata (1.8.1)
|
10
|
+
elasticsearch (1.0.1)
|
11
|
+
elasticsearch-api (= 1.0.1)
|
12
|
+
elasticsearch-transport (= 1.0.1)
|
13
|
+
elasticsearch-api (1.0.1)
|
14
|
+
multi_json
|
15
|
+
elasticsearch-transport (1.0.1)
|
16
|
+
faraday
|
17
|
+
multi_json
|
18
|
+
eventmachine (1.0.3)
|
19
|
+
faraday (0.8.8)
|
20
|
+
multipart-post (~> 1.2.0)
|
21
|
+
json (1.8.1)
|
22
|
+
minitest (5.3.4)
|
23
|
+
multi_json (1.7.9)
|
24
|
+
multipart-post (1.2.0)
|
25
|
+
rake (10.2.0)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bindata
|
32
|
+
bundler (~> 1.5)
|
33
|
+
elasticsearch
|
34
|
+
eventmachine
|
35
|
+
json
|
36
|
+
minitest
|
37
|
+
rake
|
38
|
+
sflow!
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Sebastian Saemann <ssaemann@netways.de>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/sflow/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Sflow
|
2
|
+
|
3
|
+
Tiny sflow collector and parser script based on eventmachine. It listens for sflow v5 samples, parses them and sends it to logstash.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Clone this repository
|
8
|
+
|
9
|
+
$ git clone http://github.com/netways/sflow
|
10
|
+
|
11
|
+
Change directory
|
12
|
+
|
13
|
+
$ cd sflow
|
14
|
+
|
15
|
+
Install dependencies using bundler
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Configure your logstash endpoint
|
20
|
+
|
21
|
+
$ vi ./etc/config.yaml
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle exec ./bin/sflow.rb
|
26
|
+
|
27
|
+
## Logstash Configuration
|
28
|
+
|
29
|
+
A complete logstash installation is a prerequisite.
|
30
|
+
|
31
|
+
For getting the parsed sflow-packets as JSON via UDP into logstash you have to configure a input, filter and a output accordingly:
|
32
|
+
|
33
|
+
input {
|
34
|
+
udp {
|
35
|
+
port => 6543
|
36
|
+
type => "sflow"
|
37
|
+
codec => 'json'
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
filter {
|
42
|
+
json {
|
43
|
+
source => "message"
|
44
|
+
type => "json"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
output {
|
49
|
+
elasticsearch_http {
|
50
|
+
workers => 8
|
51
|
+
host => "elasticsearch.host"
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
## Kibana
|
56
|
+
|
57
|
+
You can create your very own kibana dashboard for viewing the information and graphs you are interested in. For a quick start you'll find a dashboard in the misc folder, which can be imported via the kibana webinterface.
|
58
|
+
|
59
|
+
![Alt text](misc/screen1.png?raw=true "Demo screen")
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it ( http://github.com/netways/sflow/fork )
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create new Pull Request
|
data/lib/sflow/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby1.9.1
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'bundler' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('bundler', 'bundler')
|
data/lib/sflow/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby1.9.1
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|