fluent-plugin-oui-filter 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/fluent-plugin-oui-filter.gemspec +1 -1
- data/lib/fluent/plugin/filter_oui.rb +15 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b59c0949439c849e106765462c4ee2716a607a5
|
4
|
+
data.tar.gz: 746da4d93bd5fa7c829083252199cade1d21ec5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1316c01e77b46e346fd422a3e90cc5292ff870877e49475b6f00ab0a9f5039a16579b8f0d8937a3b7e44735a5a2ae0d378bfc042eb784b6db18e013cdc5765df
|
7
|
+
data.tar.gz: e858105d1aea140937c45d3205d16dae937db7aedf473d2d2bc5afdbaa49a0d70b5eb9e2d1c6b92eddd169ffe58fd8d7e6337ec780f8366887d25624f53f54ff
|
data/README.md
CHANGED
@@ -26,12 +26,14 @@ Or install it yourself as:
|
|
26
26
|
<filter oui.**>
|
27
27
|
type oui
|
28
28
|
mac_address mac_address
|
29
|
-
|
29
|
+
key_prefix_vendor vendor
|
30
|
+
key_prefix_oui oui
|
30
31
|
</filter>
|
31
32
|
```
|
32
33
|
+ `database_path` : OUI Database path
|
33
34
|
+ `mac_address` : MAC Address field
|
34
|
-
+ `
|
35
|
+
+ `key_prefix_vendor` : OUI vendor name
|
36
|
+
+ `key_prefix_oui` : MAC address oui id
|
35
37
|
|
36
38
|
## Development
|
37
39
|
|
@@ -4,16 +4,18 @@ module Fluent::Plugin
|
|
4
4
|
class OuiFilter < Filter
|
5
5
|
Fluent::Plugin.register_filter('oui', self)
|
6
6
|
|
7
|
-
config_param :database_path,
|
8
|
-
config_param :mac_address,
|
9
|
-
config_param :
|
10
|
-
config_param :
|
11
|
-
config_param :
|
7
|
+
config_param :database_path, :string, :default => File.dirname(__FILE__) + '/../../../ouilist/ouilist.csv'
|
8
|
+
config_param :mac_address, :string, :default => 'mac_address'
|
9
|
+
config_param :key_prefix_vendor, :string, :default => 'vendor'
|
10
|
+
config_param :key_prefix_oui, :string, :default => 'oui'
|
11
|
+
config_param :remove_prefix, :string, :default => nil
|
12
|
+
config_param :add_prefix, :string, :default => nil
|
12
13
|
|
13
14
|
def configure(conf)
|
14
15
|
super
|
15
16
|
@remove_prefix = Regexp.new("^#{Regexp.escape(remove_prefix)}\.?") unless conf['remove_prefix'].nil?
|
16
|
-
@
|
17
|
+
@key_prefix_vendor = @mac_address + "_" + @key_prefix_vendor
|
18
|
+
@key_prefix_oui = @mac_address + "_" + @key_prefix_oui
|
17
19
|
end
|
18
20
|
|
19
21
|
def filter_stream(tag, es)
|
@@ -23,18 +25,23 @@ module Fluent::Plugin
|
|
23
25
|
|
24
26
|
es.each do |time, record|
|
25
27
|
unless record[@mac_address].nil?
|
26
|
-
record[@
|
28
|
+
record[@key_prefix_oui] = getoui(record[@mac_address]) rescue nil
|
29
|
+
record[@key_prefix_vendor] = getouiname(getoui(record[@mac_address])) rescue nil
|
27
30
|
end
|
28
31
|
new_es.add(time, record)
|
29
32
|
end
|
30
33
|
return new_es
|
31
34
|
end
|
32
35
|
|
33
|
-
def
|
36
|
+
def getoui(macaddress)
|
34
37
|
macaddress = macaddress.gsub(/[0-9a-fA-F:]{1,8}$/, '')
|
35
38
|
macaddress = macaddress.gsub(/:/, '')
|
36
39
|
macaddress = macaddress.upcase
|
37
40
|
|
41
|
+
return macaddress
|
42
|
+
end
|
43
|
+
|
44
|
+
def getouiname(ouiaddress)
|
38
45
|
CSV.open(@database_path,"r") do |csv|
|
39
46
|
csv.each do |row|
|
40
47
|
if row[0] == macaddress
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-oui-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tokyo Home SOC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|