nfagent 0.9.50 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'socket'
4
+ require 'optparse'
4
5
 
5
6
  class Client
6
7
  def initialize(host, port)
@@ -34,7 +35,25 @@ class Client
34
35
  end
35
36
  end
36
37
 
37
- client = Client.new("127.0.0.1", "10000")
38
+
39
+ options = {
40
+ port: 10110,
41
+ host: '127.0.0.1'
42
+ }
43
+ OptionParser.new do |opts|
44
+ opts.banner = "Usage: squid_log_writer [options]"
45
+
46
+ opts.on("-p", "--port", "Submit logs to agent running on port [port]") do |port|
47
+ options[:port] = port
48
+ end
49
+
50
+ opts.on("-H", "--host", "Submit logs to agent running on host [host]") do |host|
51
+ options[:host] = host
52
+ end
53
+ end.parse!
54
+
55
+
56
+ client = Client.new(options[:host], options[:port])
38
57
 
39
58
  while !$stdin.eof?
40
59
  line = $stdin.readline
@@ -36,5 +36,5 @@ require 'nfagent/cli'
36
36
  require 'nfagent/tests'
37
37
 
38
38
  module NFAgent
39
- VERSION = '0.9.50'
39
+ VERSION = '1.0.0'
40
40
  end
@@ -1,12 +1,10 @@
1
1
  module NFAgent
2
2
  class Client
3
- # TODO: Make this a config option
4
- SERVICE_HOST = "sandbox.netfox.com"
5
-
6
3
  def self.post(end_point, data_hash)
4
+ Log.info("Submitting to #{Config.service_host} on port #{Config.service_port}")
7
5
  proxy_class = Net::HTTP::Proxy(Config.http_proxy_host, Config.http_proxy_port, Config.http_proxy_user, Config.http_proxy_password)
8
6
  # TODO: Enable SSL
9
- proxy_class.start(SERVICE_HOST, 80) do |http|
7
+ proxy_class.start(Config.service_host, Config.service_port) do |http|
10
8
  http.read_timeout = 120 # 2 minutes TODO: Make this a config option with 120 as default
11
9
  req = Net::HTTP::Post.new("/#{end_point}")
12
10
  p({"key" => Config.client_key}.merge(data_hash).delete('data'))
@@ -16,12 +16,15 @@ module NFAgent
16
16
  # mapping: Class, this is a plugin class which must be stored in a file in the directory /etc/nfagent/plugins/
17
17
  # parse: (optional, default: 'remotely'): String, either 'remotely' or 'locally'
18
18
  #
19
- defaults do |c|
20
- c.mode = 'normal'
21
- c.parse = 'remotely'
22
- c.chunk_timeout = 60
23
- c.time_zone = 'UTC'
24
- c.plugin_directory = '/etc/nfagent/plugins/'
19
+ defaults do |config|
20
+ config.mode = 'normal'
21
+ config.parse = 'remotely'
22
+ config.chunk_timeout = 60
23
+ config.time_zone = 'UTC'
24
+ config.plugin_directory = '/etc/nfagent/plugins/'
25
+ config.service_host = 'collector.beta.netfox.com'
26
+ config.service_port = 80
27
+ config.agent_port = 10110
25
28
  end
26
29
 
27
30
  class << self
@@ -1,7 +1,8 @@
1
1
  module NFAgent
2
2
  class Server
3
3
  def run
4
- Log.info("Starting up")
4
+ Log.info("Starting up: Listening on port #{Config.agent_port}")
5
+ Log.info("Data will be submitted to #{Config.service_host}:#{Config.service_port}")
5
6
  NFAgent::Plugin.load_plugins
6
7
 
7
8
  Log.info("Parsing #{Config.parse}")
@@ -11,7 +12,7 @@ module NFAgent
11
12
  poller = Poller.new
12
13
 
13
14
  EM.run {
14
- EM.start_server "0.0.0.0", 10000, Event, chunk_handler, poller
15
+ EM.start_server "0.0.0.0", Config.agent_port, Event, chunk_handler, poller
15
16
  EM::PeriodicTimer.new(5) do
16
17
  chunk_handler.check_full_or_expired
17
18
  end
@@ -1,4 +1,4 @@
1
- client_key = hOFxKEgYEBf1Ni8WqJ02
1
+ client_key = Rfu5eaa0SZo8k4FdzBWo
2
2
  dump_dir = sandbox/dumps
3
3
  log_file = sandbox/debug
4
4
  pid_file = sandbox/nfagent.pid
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nfagent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.50
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-25 00:00:00.000000000 Z
12
+ date: 2014-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: svutil
@@ -184,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  segments:
186
186
  - 0
187
- hash: 3602518525496297623
187
+ hash: -4434578557288111645
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  none: false
190
190
  requirements: