nfagent 0.0.99 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nfagent.rb CHANGED
@@ -24,5 +24,5 @@ require 'nfagent/server'
24
24
  require 'nfagent/cli'
25
25
 
26
26
  module NFAgent
27
- VERSION = '0.0.99'
27
+ VERSION = '0.9.0'
28
28
  end
data/lib/nfagent/chunk.rb CHANGED
@@ -27,10 +27,8 @@ module NFAgent
27
27
  end
28
28
 
29
29
  def dump
30
- puts @array.join("\n")
31
30
  payload = Encoder.encode64url(Zlib::Deflate.deflate(@array.join("\n"), Zlib::BEST_COMPRESSION))
32
31
  checksum = Digest::SHA1.hexdigest(payload)
33
- Log.info "Submitting chunk to server (#{checksum})"
34
32
  [ payload, checksum ]
35
33
  end
36
34
 
@@ -7,8 +7,10 @@ module NFAgent
7
7
  @key = key
8
8
  end
9
9
 
10
- def submit(payload, checksum)
11
- puts "submitting paylod: #{payload}"
10
+ def submit(payload, checksum, options = {})
11
+ attempt = options[:attempt] || 1
12
+ raise "Delaying attempt" unless [ 1, 2, 4, 8, 16 ].include?(attempt)
13
+ puts "Submitting Payload: #{checksum}, Attempt #{attempt}, (#{payload.size + 1} bytes)"
12
14
  proxy_class = Net::HTTP::Proxy(Config.proxy.host, Config.proxy.port, Config.proxy.user, Config.proxy.password)
13
15
  proxy_class.start(@service_host, 80) do |http|
14
16
  req = Net::HTTP::Post.new('/collector')
@@ -18,11 +20,11 @@ module NFAgent
18
20
  end
19
21
  rescue
20
22
  Log.error "Submission Failed: #{$!}"
21
- write_failed_dump(payload, checksum)
23
+ write_failed_dump(payload, checksum, attempt)
22
24
  end
23
25
 
24
- def write_failed_dump(payload, checksum)
25
- File.open(File.join(Config.dump_dir, checksum), "w") do |file|
26
+ def write_failed_dump(payload, checksum, attempt)
27
+ File.open(File.join(Config.dump_dir, "#{checksum}-#{attempt}"), "w") do |file|
26
28
  file << payload
27
29
  end
28
30
  end
@@ -40,14 +42,18 @@ module NFAgent
40
42
  submitter = Submitter.new(Config.client_key)
41
43
  dump_dir = Dir.new(Config.dump_dir)
42
44
  dump_dir.entries.select { |e| not e =~ /^\./ }.each do |entry|
43
- Log.info "Resubmitting #{entry }"
45
+ dump_file, attempt = entry.split("-")
46
+ Log.info "Resubmitting #{entry}"
44
47
  payload = ""
45
48
  ref = File.join(dump_dir.path, entry)
46
49
  File.open(ref, "r") do |file|
47
50
  payload << file.read
48
51
  end
49
- FileUtils.rm(ref)
50
- submitter.submit(payload, entry)
52
+ FileUtils.rm_f(ref)
53
+ attempt = attempt.to_i + 1
54
+ if attempt <= 16
55
+ submitter.submit(payload, dump_file, :attempt => attempt)
56
+ end
51
57
  end
52
58
  end
53
59
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nfagent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.99
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 9
8
+ - 0
9
+ version: 0.9.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Daniel Draper
@@ -9,50 +14,66 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-05 00:00:00 +10:30
17
+ date: 2010-07-07 00:00:00 +09:30
13
18
  default_executable: nfagent
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: svutil
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 0
30
+ - 3
23
31
  version: 0.0.3
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: eventmachine
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 12
44
+ - 8
33
45
  version: 0.12.8
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  - !ruby/object:Gem::Dependency
36
49
  name: newgem
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
40
52
  requirements:
41
53
  - - ">="
42
54
  - !ruby/object:Gem::Version
43
- version: 1.5.2
44
- version:
55
+ segments:
56
+ - 1
57
+ - 5
58
+ - 3
59
+ version: 1.5.3
60
+ type: :development
61
+ version_requirements: *id003
45
62
  - !ruby/object:Gem::Dependency
46
63
  name: hoe
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
50
66
  requirements:
51
67
  - - ">="
52
68
  - !ruby/object:Gem::Version
53
- version: 2.3.3
54
- version:
55
- description: ""
69
+ segments:
70
+ - 2
71
+ - 4
72
+ - 0
73
+ version: 2.4.0
74
+ type: :development
75
+ version_requirements: *id004
76
+ description: Logging Agent for NetFox Online
56
77
  email:
57
78
  - daniel@netfox.com
58
79
  executables:
@@ -89,7 +110,7 @@ files:
89
110
  - nfagent.init.ubuntu.txt
90
111
  - nfagent.init.redhat.txt
91
112
  has_rdoc: true
92
- homepage:
113
+ homepage: http://netfox.com
93
114
  licenses: []
94
115
 
95
116
  post_install_message: PostInstall.txt
@@ -102,18 +123,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
123
  requirements:
103
124
  - - ">="
104
125
  - !ruby/object:Gem::Version
126
+ segments:
127
+ - 0
105
128
  version: "0"
106
- version:
107
129
  required_rubygems_version: !ruby/object:Gem::Requirement
108
130
  requirements:
109
131
  - - ">="
110
132
  - !ruby/object:Gem::Version
133
+ segments:
134
+ - 0
111
135
  version: "0"
112
- version:
113
136
  requirements: []
114
137
 
115
138
  rubyforge_project: nfagent
116
- rubygems_version: 1.3.3
139
+ rubygems_version: 1.3.6
117
140
  signing_key:
118
141
  specification_version: 3
119
142
  summary: Logging Agent for NetFox Online