nfagent 0.9.50 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/squid_log_writer +20 -1
 - data/lib/nfagent.rb +1 -1
 - data/lib/nfagent/client.rb +2 -4
 - data/lib/nfagent/config.rb +9 -6
 - data/lib/nfagent/server.rb +3 -2
 - data/nfagent.conf +1 -1
 - metadata +3 -3
 
    
        data/bin/squid_log_writer
    CHANGED
    
    | 
         @@ -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 
     | 
    
         
            -
             
     | 
| 
      
 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
         
     | 
    
        data/lib/nfagent.rb
    CHANGED
    
    
    
        data/lib/nfagent/client.rb
    CHANGED
    
    | 
         @@ -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( 
     | 
| 
      
 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'))
         
     | 
    
        data/lib/nfagent/config.rb
    CHANGED
    
    | 
         @@ -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 | 
     | 
| 
       20 
     | 
    
         
            -
                   
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
       23 
     | 
    
         
            -
                   
     | 
| 
       24 
     | 
    
         
            -
                   
     | 
| 
      
 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
         
     | 
    
        data/lib/nfagent/server.rb
    CHANGED
    
    | 
         @@ -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",  
     | 
| 
      
 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
         
     | 
    
        data/nfagent.conf
    CHANGED
    
    
    
        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. 
     | 
| 
      
 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:  
     | 
| 
      
 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:  
     | 
| 
      
 187 
     | 
    
         
            +
                  hash: -4434578557288111645
         
     | 
| 
       188 
188 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       189 
189 
     | 
    
         
             
              none: false
         
     | 
| 
       190 
190 
     | 
    
         
             
              requirements:
         
     |