bipbip 0.6.21 → 0.6.22
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.
- checksums.yaml +4 -4
 - data/lib/bipbip/plugin/network.rb +28 -2
 - data/lib/bipbip/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f33e545c81e128bad9a19a2700b5a7b91ff6183e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d5a950064107b491a79d897599a396c7582a0b8e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: f4bde45b9595343c0686575a0f0de40cd7312093fa72f46b95dfc6824435fe87645d55bf9e8d458ea0d3930355ff421d9d5b48b28f40bac7971e7b89e1921177
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1598338e7a03fb49300eb8ed33f846f6f39d591581052c2c70c93dd0261c6d5d94aea5b9e1930e92edc7566f181c87ee82bc3ad1b9799c5892f5ae6625940a48
         
     | 
| 
         @@ -2,7 +2,11 @@ module Bipbip 
     | 
|
| 
       2 
2 
     | 
    
         
             
              class Plugin::Network < Plugin
         
     | 
| 
       3 
3 
     | 
    
         
             
                def metrics_schema
         
     | 
| 
       4 
4 
     | 
    
         
             
                  [
         
     | 
| 
       5 
     | 
    
         
            -
                    { name: 'connections_total', type: 'gauge', unit: 'Connections' }
         
     | 
| 
      
 5 
     | 
    
         
            +
                    { name: 'connections_total', type: 'gauge', unit: 'Connections' },
         
     | 
| 
      
 6 
     | 
    
         
            +
                    { name: 'rx_errors', type: 'counter', unit: 'Errors' },
         
     | 
| 
      
 7 
     | 
    
         
            +
                    { name: 'rx_dropped', type: 'counter', unit: 'Packets' },
         
     | 
| 
      
 8 
     | 
    
         
            +
                    { name: 'tx_errors', type: 'counter', unit: 'Errors' },
         
     | 
| 
      
 9 
     | 
    
         
            +
                    { name: 'tx_dropped', type: 'counter', unit: 'Packets' }
         
     | 
| 
       6 
10 
     | 
    
         
             
                  ]
         
     | 
| 
       7 
11 
     | 
    
         
             
                end
         
     | 
| 
       8 
12 
     | 
    
         | 
| 
         @@ -10,8 +14,30 @@ module Bipbip 
     | 
|
| 
       10 
14 
     | 
    
         
             
                  tcp_summary = `ss -s | grep '^TCP:'`
         
     | 
| 
       11 
15 
     | 
    
         
             
                  tcp_counters = /^TCP:\s+(\d+) \(estab (\d+), closed (\d+), orphaned (\d+), synrecv (\d+), timewait (\d+)\/(\d+)\), ports (\d+)$/.match(tcp_summary)
         
     | 
| 
       12 
16 
     | 
    
         
             
                  raise "Cannot match ss-output `#{tcp_summary}`" unless tcp_counters
         
     | 
| 
      
 17 
     | 
    
         
            +
                  {
         
     | 
| 
      
 18 
     | 
    
         
            +
                    'connections_total' => tcp_counters[1].to_i,
         
     | 
| 
      
 19 
     | 
    
         
            +
                    'rx_errors' => _statistics_sum('rx_errors'),
         
     | 
| 
      
 20 
     | 
    
         
            +
                    'rx_dropped' => _statistics_sum('rx_dropped'),
         
     | 
| 
      
 21 
     | 
    
         
            +
                    'tx_errors' => _statistics_sum('tx_errors'),
         
     | 
| 
      
 22 
     | 
    
         
            +
                    'tx_dropped' => _statistics_sum('tx_dropped')
         
     | 
| 
      
 23 
     | 
    
         
            +
                  }
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                private
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                # @param [String] check
         
     | 
| 
      
 29 
     | 
    
         
            +
                # @return [Integer] Sum of readings for all interfaces
         
     | 
| 
      
 30 
     | 
    
         
            +
                def _statistics_sum(check)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  _interfaces.reduce(0) do |memo, interface|
         
     | 
| 
      
 32 
     | 
    
         
            +
                    memo + File.read("/sys/class/net/#{interface}/statistics/#{check}".chomp).to_i
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
       13 
35 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
                # @return [Array] List of all network interfaces to monitor
         
     | 
| 
      
 37 
     | 
    
         
            +
                def _interfaces
         
     | 
| 
      
 38 
     | 
    
         
            +
                  interfaces_excluded = config['exclude_interfaces'] || [/lo/, /bond/, /vboxnet/]
         
     | 
| 
      
 39 
     | 
    
         
            +
                  interfaces_found = `ls /sys/class/net/`.split(/\n/)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  interfaces_found.reject { |i| i.match(Regexp.union(interfaces_excluded)) }
         
     | 
| 
       15 
41 
     | 
    
         
             
                end
         
     | 
| 
       16 
42 
     | 
    
         
             
              end
         
     | 
| 
       17 
43 
     | 
    
         
             
            end
         
     | 
    
        data/lib/bipbip/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: bipbip
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.22
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Cargo Media
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2016- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2016-07-11 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: copperegg-revealmetrics
         
     | 
| 
         @@ -314,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       314 
314 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       315 
315 
     | 
    
         
             
            requirements: []
         
     | 
| 
       316 
316 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       317 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 317 
     | 
    
         
            +
            rubygems_version: 2.4.8
         
     | 
| 
       318 
318 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       319 
319 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       320 
320 
     | 
    
         
             
            summary: Gather services data and store in CopperEgg
         
     |