nfagent 0.9.30 → 0.9.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ module NFAgent
13
13
  if data && data.length > 10
14
14
  @handler.append(data)
15
15
  end
16
- #send_data('OK')
16
+ send_data('OK')
17
17
  end
18
18
 
19
19
  def unbind
@@ -1,6 +1,6 @@
1
1
 
2
2
  module NFAgent
3
- class Payload < Struct.new(:data, :checksum, :filename, :line_count, :chunk_expired, :key)
3
+ class Payload < Struct.new(:data, :checksum, :filename, :line_count, :chunk_expired)
4
4
  def initialize
5
5
  yield self
6
6
  end
@@ -23,19 +23,16 @@ module NFAgent
23
23
  end
24
24
 
25
25
  def to_hash
26
- ret = {
26
+ {
27
27
  "payload" => self.data,
28
28
  "checksum" => self.checksum,
29
29
  "line_count" => self.line_count,
30
30
  "chunk_expired" => self.chunk_expired
31
31
  }
32
- ret["key"] = self.key unless self.key.blank?
33
- ret
34
32
  end
35
33
 
36
34
  def write_to_disk(directory)
37
- filename = [ self.checksum, self.attempt, self.key ].compact.join("-")
38
- File.open(File.join(directory, filename), "w") do |file|
35
+ File.open(File.join(directory, "#{self.checksum}-#{self.attempt}"), "w") do |file|
39
36
  file << self.data
40
37
  end
41
38
  end
@@ -51,14 +48,14 @@ module NFAgent
51
48
  filename && File.exists?(lockfile)
52
49
  end
53
50
 
54
- def self.read_from_file(filename, dir = Config.dump_dir)
51
+ def self.read_from_file(filename)
55
52
  # Ensure the file is only relative
56
53
  filename = File.basename(filename)
57
54
  self.new do |payload|
58
55
  payload.filename = filename
59
- payload.checksum, payload.attempt, payload.key = filename.split("-")
56
+ payload.checksum, payload.attempt = filename.split("-")
60
57
  payload.data = ""
61
- ref = File.join(dir, filename)
58
+ ref = File.join(Config.dump_dir, filename)
62
59
  File.open(ref, "r") do |file|
63
60
  payload.data << file.read
64
61
  end
@@ -71,8 +68,7 @@ module NFAgent
71
68
 
72
69
  def try_again_later
73
70
  # TODO: Move the file to a new name with a later timetamp
74
- new_filename = [ self.checksum, self.attempt, self.key ].compact.join("-")
75
- FileUtils.mv(File.join(Config.dump_dir, self.filename), File.join(Config.dump_dir, new_filename))
71
+ FileUtils.mv(File.join(Config.dump_dir, self.filename), File.join(Config.dump_dir, "#{self.checksum}-#{self.attempt}"))
76
72
  end
77
73
 
78
74
  private
@@ -2,11 +2,6 @@ module NFAgent
2
2
  class Server
3
3
  def run
4
4
  Log.info("Starting up")
5
- NFAgent::Plugin.load_plugins
6
-
7
- Log.info("Parsing #{Config.parse}")
8
- Log.info("Mode set to #{Config.mode}")
9
-
10
5
  chunk_handler = ChunkHandler.new
11
6
  poller = Poller.new
12
7
 
@@ -15,7 +15,6 @@ module NFAgent
15
15
  response = Client.post(:collector, @payload.to_hash)
16
16
  if response.ok?
17
17
  succeed(@payload)
18
- Log.info("Submitted #{@payload.line_count} lines")
19
18
  else
20
19
  Log.error "Submission Failed: #{response.message}"
21
20
  fail(@payload)
@@ -1,4 +1,4 @@
1
- client_key = FNX3tyOkG6J7nk2uC3QX
2
- dump_dir = sandbox/dumps
3
- log_file = sandbox/debug
4
- pid_file = sandbox/nfagent.pid
1
+ client_key = 1234
2
+ dump_dir = /tmp/dumps
3
+ log_file = /tmp/debug
4
+ pid_file = /tmp/nfagent.pid
metadata CHANGED
@@ -1,177 +1,148 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: nfagent
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 9
8
- - 30
9
- version: 0.9.30
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.31
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Daniel Draper
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-02-18 00:00:00 +10:30
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-03-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: svutil
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- - 1
30
- - 3
31
- version: 0.1.3
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.12
32
22
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: eventmachine
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- - 12
44
- - 8
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.12
30
+ - !ruby/object:Gem::Dependency
31
+ name: eventmachine
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
45
37
  version: 0.12.8
46
38
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: squiggle
50
39
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- - 0
58
- - 8
59
- version: 0.0.8
60
- type: :runtime
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: hoe
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.12.8
46
+ - !ruby/object:Gem::Dependency
47
+ name: newgem
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.5.3
54
+ type: :development
64
55
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 2
71
- - 4
72
- - 0
73
- version: 2.4.0
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.5.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: hoe
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.5'
74
70
  type: :development
75
- version_requirements: *id004
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.5'
76
78
  description: Logging Agent for NetFox Online
77
- email:
79
+ email:
78
80
  - daniel@netfox.com
79
- executables:
81
+ executables:
80
82
  - nfagent
81
83
  - squid_log_writer
82
84
  extensions: []
83
-
84
- extra_rdoc_files:
85
+ extra_rdoc_files:
86
+ - PostInstall.txt
85
87
  - History.txt
86
88
  - Manifest.txt
87
- - PostInstall.txt
89
+ - README.txt
88
90
  - nfagent.init.ubuntu.txt
89
91
  - nfagent.init.redhat.txt
90
- files:
91
- - History.txt
92
- - Manifest.txt
93
- - PostInstall.txt
94
- - README.rdoc
92
+ files:
95
93
  - Rakefile
96
- - script/console
97
- - script/destroy
98
- - script/generate
99
- - test/test_chunk.rb
100
- - test/test_chunk_handler.rb
101
- - test/test_client.rb
102
- - test/test_config.rb
103
- - test/test_helper.rb
104
- - test/test_mapper_proxy.rb
105
- - test/test_nfagent.rb
106
- - test/test_payload.rb
107
- - test/test_plugin.rb
108
- - test/config
109
- - sandbox/dumps/debug
110
- - test/plugins/my_mapper.rb
111
94
  - lib/nfagent.rb
112
- - lib/nfagent/base64.rb
113
- - lib/nfagent/chunk.rb
114
- - lib/nfagent/chunk_handler.rb
115
95
  - lib/nfagent/cli.rb
116
- - lib/nfagent/client.rb
117
- - lib/nfagent/client_response.rb
118
- - lib/nfagent/config.rb
96
+ - lib/nfagent/base64.rb
119
97
  - lib/nfagent/encoder.rb
120
- - lib/nfagent/event.rb
121
- - lib/nfagent/info.rb
98
+ - lib/nfagent/server.rb
99
+ - lib/nfagent/chunk_handler.rb
122
100
  - lib/nfagent/log.rb
123
- - lib/nfagent/mapper_proxy.rb
124
- - lib/nfagent/object_extra.rb
101
+ - lib/nfagent/info.rb
102
+ - lib/nfagent/event.rb
125
103
  - lib/nfagent/payload.rb
126
- - lib/nfagent/plugin.rb
127
104
  - lib/nfagent/poller.rb
128
- - lib/nfagent/server.rb
129
- - lib/nfagent/submitter.rb
105
+ - lib/nfagent/chunk.rb
106
+ - lib/nfagent/client.rb
107
+ - lib/nfagent/client_response.rb
108
+ - lib/nfagent/config.rb
130
109
  - lib/nfagent/tail.rb
131
110
  - lib/nfagent/tests.rb
111
+ - lib/nfagent/submitter.rb
132
112
  - bin/nfagent
133
113
  - bin/squid_log_writer
114
+ - PostInstall.txt
115
+ - History.txt
116
+ - Manifest.txt
117
+ - README.txt
134
118
  - nfagent.conf
135
119
  - nfagent.init.ubuntu.txt
136
120
  - nfagent.init.redhat.txt
137
- has_rdoc: true
138
- homepage: http://github.com/#{github_username}/#{project_name}
121
+ - .gemtest
122
+ homepage: http://netfox.com
139
123
  licenses: []
140
-
141
124
  post_install_message: PostInstall.txt
142
- rdoc_options:
125
+ rdoc_options:
143
126
  - --main
144
- - README.rdoc
145
- require_paths:
127
+ - README.txt
128
+ require_paths:
146
129
  - lib
147
- required_ruby_version: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- segments:
152
- - 0
153
- version: "0"
154
- required_rubygems_version: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- segments:
159
- - 0
160
- version: "0"
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
161
142
  requirements: []
162
-
163
143
  rubyforge_project: nfagent
164
- rubygems_version: 1.3.6
144
+ rubygems_version: 1.8.24
165
145
  signing_key:
166
146
  specification_version: 3
167
147
  summary: Logging Agent for NetFox Online
168
- test_files:
169
- - test/test_chunk.rb
170
- - test/test_chunk_handler.rb
171
- - test/test_client.rb
172
- - test/test_config.rb
173
- - test/test_helper.rb
174
- - test/test_mapper_proxy.rb
175
- - test/test_nfagent.rb
176
- - test/test_payload.rb
177
- - test/test_plugin.rb
148
+ test_files: []
@@ -1,18 +0,0 @@
1
- module NFAgent
2
- class MapperProxy
3
- class << self
4
- def instance
5
- return @instance if @instance
6
- raise "No Mapper Set" if Config.mapper.blank?
7
- @instance = Object.const_get(Config.mapper).new
8
- end
9
-
10
- # TODO: Can we delegate?
11
- def find_account_id(username, client_ip)
12
- instance.find_account_id(username, client_ip)
13
- end
14
-
15
- # TODO: before shutdown
16
- end
17
- end
18
- end
@@ -1,5 +0,0 @@
1
- class Object
2
- def blank?
3
- respond_to?(:empty?) ? empty? : !self
4
- end
5
- end
@@ -1,14 +0,0 @@
1
- module NFAgent
2
- class Plugin
3
- class << self
4
- def load_plugins
5
- if Config.plugin_directory && !Config.plugin_directory.empty? && File.exists?(Config.plugin_directory)
6
- Dir.glob(File.join(Config.plugin_directory, "*.rb")).each do |file|
7
- Log.info("Loading plugin: #{file}")
8
- load(file)
9
- end
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/nfagent.rb'}"
9
- puts "Loading nfagent gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)