fluent-plugin-oui-filter 0.0.1 → 0.0.2

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: e6fa816c561f1ef9d9e480d119370c99c074fa42
4
- data.tar.gz: 726ef4b537fb93ce6f190112f6ace71019419048
3
+ metadata.gz: 3b59c0949439c849e106765462c4ee2716a607a5
4
+ data.tar.gz: 746da4d93bd5fa7c829083252199cade1d21ec5d
5
5
  SHA512:
6
- metadata.gz: 6cae8173ee7aca47496bfe55d8f25f2cc019e1f8f66ad0c12f23e841768a030b5a9a768ce6d1ddc5ee1a6a5472def3d3ad36a53e9d7330026bdb708226c3efa6
7
- data.tar.gz: d96555adfb496dbce9e443a3c1e82f09f8435eb4237d23edc8421720841f45abdb2215eb76e412d527fc7538f734cc97aa34464be464665d72eda38d4e50b3ce
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
- key_prefix vendor
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
- + `key_prefix` : add `mac_address` + `key_prefix` out field
35
+ + `key_prefix_vendor` : OUI vendor name
36
+ + `key_prefix_oui` : MAC address oui id
35
37
 
36
38
  ## Development
37
39
 
@@ -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-oui-filter"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["Tokyo Home SOC"]
9
9
  spec.email = ["github@homesoc.tokyo"]
10
10
 
@@ -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, :string, :default => File.dirname(__FILE__) + '/../../../ouilist/ouilist.csv'
8
- config_param :mac_address, :string, :default => 'mac_address'
9
- config_param :key_prefix, :string, :default => 'vendor'
10
- config_param :remove_prefix, :string, :default => nil
11
- config_param :add_prefix, :string, :default => nil
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
- @key_prefix = @mac_address + "_" + @key_prefix
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[@key_prefix] = getouiname(record[@mac_address]) rescue nil
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 getouiname(macaddress)
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.1
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-25 00:00:00.000000000 Z
11
+ date: 2016-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler