embulk-input-pcapng-files 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,8 +12,14 @@ Obsoletes enukane/embulk-plugin-input-pcapng-files
12
12
 
13
13
  ## Configuration
14
14
 
15
- - **paths**: Paths to search pcapng (not recursive)
16
- - **schema**: List of fields to extract
15
+ ### Original options
16
+
17
+ |name|type|required?|default|description|
18
+ |:---|:---|:--------|:------|:----------|
19
+ | paths | string | required | [] | paths where pcapng files exist (no recursive searching|
20
+ | convertdot | string | optional | nil | convert "." in field name (for outputing into DB who doesn't accept "dot" in schema)|
21
+ | schema| array of field hash | required | nil | list of field to extract from pcapng file |
22
+ |field hash| hash ({name, type}) | required | nil | "name" matches field name for tshakr (-e), "type" should be "long", "double", "string" |
17
23
 
18
24
  ## Example
19
25
 
@@ -21,11 +27,13 @@ Obsoletes enukane/embulk-plugin-input-pcapng-files
21
27
  in:
22
28
  type: pcapng_files
23
29
  paths: [ /Users/enukane/Desktop/emtestpcap/ ]
30
+ convertdot: "__"
24
31
  threads: 2
25
32
  schema:
26
33
  - { name: frame.number, type: long }
27
- - { name: frame.time_epoch, type: long }
34
+ - { name: frame.time_epoch, type: double }
28
35
  - { name: frame.len, type: long }
36
+ - { name: wlan_mgt.ssid, type: string }
29
37
  ```
30
38
 
31
39
  ## Build
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "embulk-input-pcapng-files"
4
- spec.version = "0.1.3"
4
+ spec.version = "0.1.4"
5
5
  spec.authors = ["enukane"]
6
6
  spec.summary = "Pcapng Files input plugin for Embulk"
7
7
  spec.description = "Pcapng Files input plugin for Embulk"
@@ -10,10 +10,11 @@ module Embulk
10
10
  task = {
11
11
  'paths' => [],
12
12
  'done' => config.param('done', :array, default: []),
13
+ 'convertdot' => config.param('convertdot', :string, default: nil),
13
14
  }
14
15
 
15
16
  task['paths'] = config.param('paths', :array, default: []).map {|path|
16
- next [] unless Dir.exists?(path)
17
+ next [] unless Dir.exist?(path)
17
18
  Dir.entries(path).sort.select {|entry| entry.match(/^.+\.pcapng$/)}.map {|entry|
18
19
  path + "/" + entry
19
20
  }
@@ -30,7 +31,9 @@ module Embulk
30
31
  idx = 0
31
32
  columns.concat schema.map{|c|
32
33
  idx += 1
33
- Column.new(idx, "#{c['name']}", c['type'].to_sym)
34
+ name = c['name']
35
+ name = name.gsub(".", task['convertdot']) if task['convertdot'] != nil # convert dot
36
+ Column.new(idx, "#{name}", c['type'].to_sym)
34
37
  }
35
38
 
36
39
  commit_reports = yield(task, columns, task['paths'].length)
@@ -65,12 +68,15 @@ module Embulk
65
68
  def convert val, type
66
69
  v = val
67
70
  v = "" if val == nil
68
- if type == :long
71
+ case type
72
+ when :long
69
73
  if v.is_a?(String) and v.match(/^0x[0-9a-fA-F]+$/)
70
74
  v = v.hex
71
75
  else
72
76
  v = v.to_i
73
77
  end
78
+ when :double
79
+ v = v.to_f
74
80
  end
75
81
  return v
76
82
  end
@@ -78,6 +84,7 @@ module Embulk
78
84
  def build_options(fields)
79
85
  options = ""
80
86
  fields.each do |field|
87
+ field = field.gsub(task['convertdot'], '.') if task['convertdot'] != nil # put converted back to dot for tshark
81
88
  options += "-e \"#{field}\" "
82
89
  end
83
90
  return options
@@ -96,15 +103,6 @@ module Embulk
96
103
  end
97
104
  io.close
98
105
  end
99
-
100
- def fetch_from_pcap(path, fields)
101
- options = build_options(fields)
102
- io = IO.popen("tshark -E separator=, #{options} -T fields -r #{path}")
103
- data = io.read
104
- io.close
105
- return data
106
- end
107
-
108
106
  end
109
107
  end
110
108
  end
metadata CHANGED
@@ -1,41 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-pcapng-files
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - enukane
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-08-22 00:00:00.000000000 Z
12
+ date: 2015-09-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '1.0'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '10.0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '10.0'
41
46
  description: Pcapng Files input plugin for Embulk
@@ -45,7 +50,7 @@ executables: []
45
50
  extensions: []
46
51
  extra_rdoc_files: []
47
52
  files:
48
- - ".gitignore"
53
+ - .gitignore
49
54
  - Gemfile
50
55
  - LICENSE.txt
51
56
  - README.md
@@ -55,25 +60,32 @@ files:
55
60
  homepage: https://github.com/enukane/embulk-input-pcapng-files
56
61
  licenses:
57
62
  - MIT
58
- metadata: {}
59
63
  post_install_message:
60
64
  rdoc_options: []
61
65
  require_paths:
62
66
  - lib
63
67
  required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
64
69
  requirements:
65
- - - ">="
70
+ - - ! '>='
66
71
  - !ruby/object:Gem::Version
67
72
  version: '0'
73
+ segments:
74
+ - 0
75
+ hash: -4490009824512618125
68
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
69
78
  requirements:
70
- - - ">="
79
+ - - ! '>='
71
80
  - !ruby/object:Gem::Version
72
81
  version: '0'
82
+ segments:
83
+ - 0
84
+ hash: -4490009824512618125
73
85
  requirements: []
74
86
  rubyforge_project:
75
- rubygems_version: 2.4.5
87
+ rubygems_version: 1.8.23
76
88
  signing_key:
77
- specification_version: 4
89
+ specification_version: 3
78
90
  summary: Pcapng Files input plugin for Embulk
79
91
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 30b497c71278b04611e349cf6b5b2f373146ebea
4
- data.tar.gz: f6e57ea08bc45a8708340ac1a3b17163d72c7c5d
5
- SHA512:
6
- metadata.gz: 5380028c8c911c542bcac93b0c035228dc563e5699937d5c1cadf6995cd5f7dbabe5093accf2ecf66774e5775f6d9a609675dca20a980dd7cdc5ba4baa754d19
7
- data.tar.gz: b96e95d2ced69d8eea48a1bcc6606b57d82ffe35406375a35bfe5f82e8772b0265fb0c20a390665b4a417f9546f1afda64e0b650ee371371e0fac07a23294693