sensu-plugins-network-checks 0.0.4 → 0.0.5
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
 - checksums.yaml.gz.sig +0 -0
 - data.tar.gz.sig +0 -0
 - data/CHANGELOG.md +10 -1
 - data/README.md +1 -0
 - data/bin/check-banner.rb +2 -2
 - data/bin/check-mtu.rb +0 -1
 - data/bin/check-multicast-groups.rb +1 -2
 - data/bin/check-netstat-tcp.rb +2 -3
 - data/bin/check-ping.rb +1 -1
 - data/bin/check-ports.rb +3 -3
 - data/bin/check-rbl.rb +1 -1
 - data/bin/check-whois-domain-expiration-multi.rb +98 -0
 - data/bin/check-whois-domain-expiration.rb +2 -1
 - data/bin/metrics-interface.rb +1 -2
 - data/bin/metrics-net.rb +1 -1
 - data/bin/metrics-netif.rb +1 -3
 - data/bin/metrics-netstat-tcp.rb +1 -2
 - data/bin/metrics-ping.rb +104 -0
 - data/bin/metrics-sockstat.rb +1 -1
 - data/lib/sensu-plugins-network-checks/version.rb +1 -1
 - metadata +15 -8
 - metadata.gz.sig +0 -0
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 05befbbb40128bd754c4097cd39c23cc6dcfd3e6
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: eb80907f69c37929fa63574054cf4f75ba5428f6
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 92c7f8a40be0a0d92eff802b9ee6e678e08ee34641beea8571d05f5c4873168d3e556bd20f9431d87fa1098888ec1b2029fc12466133e7d445b671d81b65542a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9400d53919c528945403d2d99312687cecd78b3da19e07c8406b21b2f20540089ed76a15e121139267a90714567b4bdb57c9ed0ed6084829c2b4eefbf3ff8504
         
     | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        data.tar.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -3,7 +3,16 @@ This project adheres to [Semantic Versioning](http://semver.org/). 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            ## Unreleased][unreleased]
         
     | 
| 
      
 6 
     | 
    
         
            +
            ## [Unreleased][unreleased]
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ## [0.0.5] - 2015-08-05
         
     | 
| 
      
 9 
     | 
    
         
            +
            ### Added
         
     | 
| 
      
 10 
     | 
    
         
            +
            - Added new metrics-ping.rb plugin
         
     | 
| 
      
 11 
     | 
    
         
            +
            - Added check-whois-domain-expiration-multi.rb plugin to check multiple domains for expiratino using whois records
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            ### Changed
         
     | 
| 
      
 14 
     | 
    
         
            +
            - general gem cleanup
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       7 
16 
     | 
    
         | 
| 
       8 
17 
     | 
    
         
             
            ## [0.0.4] - 2015-07-14
         
     | 
| 
       9 
18 
     | 
    
         
             
            ### Changed
         
     | 
    
        data/README.md
    CHANGED
    
    
    
        data/bin/check-banner.rb
    CHANGED
    
    | 
         @@ -94,7 +94,7 @@ class CheckBanner < Sensu::Plugin::Check::CLI 
     | 
|
| 
       94 
94 
     | 
    
         
             
                     long: '--critmessage MESSAGE',
         
     | 
| 
       95 
95 
     | 
    
         
             
                     description: 'Custom critical message to send'
         
     | 
| 
       96 
96 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
              def acquire_banner(host) 
     | 
| 
      
 97 
     | 
    
         
            +
              def acquire_banner(host)
         
     | 
| 
       98 
98 
     | 
    
         
             
                timeout(config[:timeout]) do
         
     | 
| 
       99 
99 
     | 
    
         
             
                  sock = TCPSocket.new(host, config[:port])
         
     | 
| 
       100 
100 
     | 
    
         
             
                  sock.puts config[:write] if config[:write]
         
     | 
| 
         @@ -128,7 +128,7 @@ class CheckBanner < Sensu::Plugin::Check::CLI 
     | 
|
| 
       128 
128 
     | 
    
         
             
                  critical 'Connection closed unexpectedly'
         
     | 
| 
       129 
129 
     | 
    
         
             
              end
         
     | 
| 
       130 
130 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
              def run 
     | 
| 
      
 131 
     | 
    
         
            +
              def run
         
     | 
| 
       132 
132 
     | 
    
         
             
                hosts = config[:hosts].split(',')
         
     | 
| 
       133 
133 
     | 
    
         
             
                okarray = []
         
     | 
| 
       134 
134 
     | 
    
         
             
                hosts.each do |host|
         
     | 
    
        data/bin/check-mtu.rb
    CHANGED
    
    
| 
         @@ -18,7 +18,6 @@ 
     | 
|
| 
       18 
18 
     | 
    
         
             
            #
         
     | 
| 
       19 
19 
     | 
    
         
             
            # DEPENDENCIES:
         
     | 
| 
       20 
20 
     | 
    
         
             
            #   gem: sensu-plugin
         
     | 
| 
       21 
     | 
    
         
            -
            #   gem: json
         
     | 
| 
       22 
21 
     | 
    
         
             
            #
         
     | 
| 
       23 
22 
     | 
    
         
             
            # USAGE:
         
     | 
| 
       24 
23 
     | 
    
         
             
            #   example commands
         
     | 
| 
         @@ -49,7 +48,7 @@ class CheckMulticastGroups < Sensu::Plugin::Check::CLI 
     | 
|
| 
       49 
48 
     | 
    
         
             
                     required: true,
         
     | 
| 
       50 
49 
     | 
    
         
             
                     description: 'Path to a config file'
         
     | 
| 
       51 
50 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
              def run 
     | 
| 
      
 51 
     | 
    
         
            +
              def run
         
     | 
| 
       53 
52 
     | 
    
         
             
                targets = settings['check-multicast-groups'] ||= []
         
     | 
| 
       54 
53 
     | 
    
         
             
                extras = load_config(config[:config])['check-multicast-groups'] || []
         
     | 
| 
       55 
54 
     | 
    
         
             
                targets.deep_merge(extras)
         
     | 
    
        data/bin/check-netstat-tcp.rb
    CHANGED
    
    | 
         @@ -78,12 +78,11 @@ class CheckNetstatTCP < Sensu::Plugin::Check::CLI 
     | 
|
| 
       78 
78 
     | 
    
         
             
                     long: '--port PORT',
         
     | 
| 
       79 
79 
     | 
    
         
             
                     proc: proc(&:to_i)
         
     | 
| 
       80 
80 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
              def netstat(protocols = ['tcp']) 
     | 
| 
      
 81 
     | 
    
         
            +
              def netstat(protocols = ['tcp'])
         
     | 
| 
       82 
82 
     | 
    
         
             
                state_counts = Hash.new(0)
         
     | 
| 
       83 
83 
     | 
    
         
             
                TCP_STATES.each_pair { |_hex, name| state_counts[name] = 0 }
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
85 
     | 
    
         
             
                protocols.select { |p| File.exist?('/proc/net/' + p) }.each do |protocol|
         
     | 
| 
       86 
     | 
    
         
            -
                  # #YELLOW
         
     | 
| 
       87 
86 
     | 
    
         
             
                  File.open('/proc/net/' + protocol).each do |line| # rubocop:disable Style/Next
         
     | 
| 
       88 
87 
     | 
    
         
             
                    line.strip!
         
     | 
| 
       89 
88 
     | 
    
         
             
                    if m = line.match(/^\s*\d+:\s+(.{8}|.{32}):(.{4})\s+(.{8}|.{32}):(.{4})\s+(.{2})/) # rubocop:disable AssignmentInCondition
         
     | 
| 
         @@ -102,7 +101,7 @@ class CheckNetstatTCP < Sensu::Plugin::Check::CLI 
     | 
|
| 
       102 
101 
     | 
    
         
             
                state_counts
         
     | 
| 
       103 
102 
     | 
    
         
             
              end
         
     | 
| 
       104 
103 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
              def run 
     | 
| 
      
 104 
     | 
    
         
            +
              def run
         
     | 
| 
       106 
105 
     | 
    
         
             
                state_counts = netstat(%w(tcp tcp6))
         
     | 
| 
       107 
106 
     | 
    
         
             
                is_critical = false
         
     | 
| 
       108 
107 
     | 
    
         
             
                is_warning = false
         
     | 
    
        data/bin/check-ping.rb
    CHANGED
    
    | 
         @@ -72,7 +72,7 @@ class CheckPING < Sensu::Plugin::Check::CLI 
     | 
|
| 
       72 
72 
     | 
    
         
             
                     description: 'Attach MTR report if ping is failed',
         
     | 
| 
       73 
73 
     | 
    
         
             
                     default: false
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
              def run 
     | 
| 
      
 75 
     | 
    
         
            +
              def run
         
     | 
| 
       76 
76 
     | 
    
         
             
                result = []
         
     | 
| 
       77 
77 
     | 
    
         
             
                pt = Net::Ping::External.new(config[:host], nil, config[:timeout])
         
     | 
| 
       78 
78 
     | 
    
         
             
                config[:count].times do |i|
         
     | 
    
        data/bin/check-ports.rb
    CHANGED
    
    | 
         @@ -52,10 +52,10 @@ class CheckPorts < Sensu::Plugin::Check::CLI 
     | 
|
| 
       52 
52 
     | 
    
         
             
                     long: '--level crit|warn',
         
     | 
| 
       53 
53 
     | 
    
         
             
                     default: 'WARN'
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
              def run 
     | 
| 
      
 55 
     | 
    
         
            +
              def run
         
     | 
| 
       56 
56 
     | 
    
         
             
                stdout, stderr = Open3.capture3(
         
     | 
| 
       57 
57 
     | 
    
         
             
                  ENV,
         
     | 
| 
       58 
     | 
    
         
            -
                  "nmap -P0 -p #{ 
     | 
| 
      
 58 
     | 
    
         
            +
                  "nmap -P0 -p #{config[:ports]} #{config[:host]}"
         
     | 
| 
       59 
59 
     | 
    
         
             
                )
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
61 
     | 
    
         
             
                case stderr
         
     | 
| 
         @@ -74,7 +74,7 @@ class CheckPorts < Sensu::Plugin::Check::CLI 
     | 
|
| 
       74 
74 
     | 
    
         
             
                  end
         
     | 
| 
       75 
75 
     | 
    
         
             
                end
         
     | 
| 
       76 
76 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
                result = port_checks.map { |state, ports| "#{ 
     | 
| 
      
 77 
     | 
    
         
            +
                result = port_checks.map { |state, ports| "#{state}:#{ports.join(',')}" }.join(' ')
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
       79 
79 
     | 
    
         
             
                if check_pass
         
     | 
| 
       80 
80 
     | 
    
         
             
                  ok result
         
     | 
    
        data/bin/check-rbl.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,98 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 3 
     | 
    
         
            +
            #
         
     | 
| 
      
 4 
     | 
    
         
            +
            #   check-whois-domain-expiration-multi
         
     | 
| 
      
 5 
     | 
    
         
            +
            #
         
     | 
| 
      
 6 
     | 
    
         
            +
            # DESCRIPTION:
         
     | 
| 
      
 7 
     | 
    
         
            +
            #   This plugin checks domain expiration dates using the 'whois' gem.
         
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            # OUTPUT:
         
     | 
| 
      
 10 
     | 
    
         
            +
            #   plain text
         
     | 
| 
      
 11 
     | 
    
         
            +
            #
         
     | 
| 
      
 12 
     | 
    
         
            +
            # PLATFORMS:
         
     | 
| 
      
 13 
     | 
    
         
            +
            #   *nix systems
         
     | 
| 
      
 14 
     | 
    
         
            +
            #
         
     | 
| 
      
 15 
     | 
    
         
            +
            # DEPENDENCIES:
         
     | 
| 
      
 16 
     | 
    
         
            +
            #   gem: sensu-plugin
         
     | 
| 
      
 17 
     | 
    
         
            +
            #   gem: whois
         
     | 
| 
      
 18 
     | 
    
         
            +
            #
         
     | 
| 
      
 19 
     | 
    
         
            +
            # USAGE:
         
     | 
| 
      
 20 
     | 
    
         
            +
            #   ./check-whois-domain-expiration-multi.rb -d therealtimsmith.com,mightyoakspreschool.com
         
     | 
| 
      
 21 
     | 
    
         
            +
            #   WhoisDomainExpirationCheck WARNING: mightyoakspreschool.com: 30 days
         
     | 
| 
      
 22 
     | 
    
         
            +
            #
         
     | 
| 
      
 23 
     | 
    
         
            +
            # LICENSE:
         
     | 
| 
      
 24 
     | 
    
         
            +
            #   Copyright 2015 Tim Smith (tim@cozy.co) - Cozy Services Ltd.
         
     | 
| 
      
 25 
     | 
    
         
            +
            #   Based on check-whois-domain-expiration, Copyright 2015 michael j talarczyk <mjt@mijit.com>
         
     | 
| 
      
 26 
     | 
    
         
            +
            #    and contributors.
         
     | 
| 
      
 27 
     | 
    
         
            +
            #   Released under the same terms as Sensu (the MIT license); see LICENSE
         
     | 
| 
      
 28 
     | 
    
         
            +
            #   for details.
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            require 'sensu-plugin/check/cli'
         
     | 
| 
      
 31 
     | 
    
         
            +
            require 'whois'
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            #
         
     | 
| 
      
 34 
     | 
    
         
            +
            # Check Whois domain expiration
         
     | 
| 
      
 35 
     | 
    
         
            +
            #
         
     | 
| 
      
 36 
     | 
    
         
            +
            class WhoisDomainExpirationCheck < Sensu::Plugin::Check::CLI
         
     | 
| 
      
 37 
     | 
    
         
            +
              option :domain,
         
     | 
| 
      
 38 
     | 
    
         
            +
                     short: '-d DOMAINS',
         
     | 
| 
      
 39 
     | 
    
         
            +
                     long: '--domains DOMAIN',
         
     | 
| 
      
 40 
     | 
    
         
            +
                     required: true,
         
     | 
| 
      
 41 
     | 
    
         
            +
                     description: 'Domain(s) to check. Separate by commas for 2+'
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              option :warning,
         
     | 
| 
      
 44 
     | 
    
         
            +
                     short: '-w DAYS',
         
     | 
| 
      
 45 
     | 
    
         
            +
                     long: '--warn DAYS',
         
     | 
| 
      
 46 
     | 
    
         
            +
                     default: 30,
         
     | 
| 
      
 47 
     | 
    
         
            +
                     description: 'Warn if fewer than DAYS away'
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              option :critical,
         
     | 
| 
      
 50 
     | 
    
         
            +
                     short: '-c DAYS',
         
     | 
| 
      
 51 
     | 
    
         
            +
                     long: '--critical DAYS',
         
     | 
| 
      
 52 
     | 
    
         
            +
                     default: 7,
         
     | 
| 
      
 53 
     | 
    
         
            +
                     description: 'Critical if fewer than DAYS away'
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              option :help,
         
     | 
| 
      
 56 
     | 
    
         
            +
                     short: '-h',
         
     | 
| 
      
 57 
     | 
    
         
            +
                     long: '--help',
         
     | 
| 
      
 58 
     | 
    
         
            +
                     description: 'Show this message',
         
     | 
| 
      
 59 
     | 
    
         
            +
                     on: :tail,
         
     | 
| 
      
 60 
     | 
    
         
            +
                     boolean: true,
         
     | 
| 
      
 61 
     | 
    
         
            +
                     show_options: true,
         
     | 
| 
      
 62 
     | 
    
         
            +
                     exit: 0
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              # split the provided domain list and perform whois lookups on each
         
     | 
| 
      
 65 
     | 
    
         
            +
              # return a hash with domains grouped by their status level
         
     | 
| 
      
 66 
     | 
    
         
            +
              def expiration_results
         
     | 
| 
      
 67 
     | 
    
         
            +
                domains = config[:domain].split(',')
         
     | 
| 
      
 68 
     | 
    
         
            +
                warning_days = config[:warning].to_i
         
     | 
| 
      
 69 
     | 
    
         
            +
                critical_days = config[:critical].to_i
         
     | 
| 
      
 70 
     | 
    
         
            +
                results = {}
         
     | 
| 
      
 71 
     | 
    
         
            +
                results['critical'] = {}
         
     | 
| 
      
 72 
     | 
    
         
            +
                results['warning'] = {}
         
     | 
| 
      
 73 
     | 
    
         
            +
                results['ok'] = {}
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                domains.each do |domain|
         
     | 
| 
      
 76 
     | 
    
         
            +
                  whois = Whois.whois(domain)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  domain_result =  (DateTime.parse(whois.expires_on.to_s) - DateTime.now).to_i
         
     | 
| 
      
 78 
     | 
    
         
            +
                  if domain_result <= critical_days
         
     | 
| 
      
 79 
     | 
    
         
            +
                    results['critical'][domain] = domain_result
         
     | 
| 
      
 80 
     | 
    
         
            +
                  elsif domain_result <= warning_days
         
     | 
| 
      
 81 
     | 
    
         
            +
                    results['warning'][domain] = domain_result
         
     | 
| 
      
 82 
     | 
    
         
            +
                  else
         
     | 
| 
      
 83 
     | 
    
         
            +
                    results['ok'] = domain_result
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
                results
         
     | 
| 
      
 87 
     | 
    
         
            +
              end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
              def run
         
     | 
| 
      
 90 
     | 
    
         
            +
                status = expiration_results
         
     | 
| 
      
 91 
     | 
    
         
            +
                if !status['critical'].empty?
         
     | 
| 
      
 92 
     | 
    
         
            +
                  critical status['critical'].map { |u, v| "#{u} days left:#{v}" }.join(',')
         
     | 
| 
      
 93 
     | 
    
         
            +
                elsif !status['warning'].empty?
         
     | 
| 
      
 94 
     | 
    
         
            +
                else
         
     | 
| 
      
 95 
     | 
    
         
            +
                  ok 'No domains expire in the near term'
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -13,6 +13,7 @@ 
     | 
|
| 
       13 
13 
     | 
    
         
             
            #   Tested on Mac OS X
         
     | 
| 
       14 
14 
     | 
    
         
             
            #
         
     | 
| 
       15 
15 
     | 
    
         
             
            # DEPENDENCIES:
         
     | 
| 
      
 16 
     | 
    
         
            +
            #   gem: sensu-plugin
         
     | 
| 
       16 
17 
     | 
    
         
             
            #   gem: whois
         
     | 
| 
       17 
18 
     | 
    
         
             
            #
         
     | 
| 
       18 
19 
     | 
    
         
             
            # USAGE:
         
     | 
| 
         @@ -79,7 +80,7 @@ class WhoisDomainExpirationCheck < Sensu::Plugin::Check::CLI 
     | 
|
| 
       79 
80 
     | 
    
         
             
              end
         
     | 
| 
       80 
81 
     | 
    
         | 
| 
       81 
82 
     | 
    
         
             
              def run
         
     | 
| 
       82 
     | 
    
         
            -
                message "#{ 
     | 
| 
      
 83 
     | 
    
         
            +
                message "#{config[:domain]} expires on #{@expires_on.strftime('%m-%d-%Y')} (#{@num_days} days away)"
         
     | 
| 
       83 
84 
     | 
    
         
             
                check_days @num_days
         
     | 
| 
       84 
85 
     | 
    
         
             
              end
         
     | 
| 
       85 
86 
     | 
    
         
             
            end
         
     | 
    
        data/bin/metrics-interface.rb
    CHANGED
    
    | 
         @@ -13,7 +13,6 @@ 
     | 
|
| 
       13 
13 
     | 
    
         
             
            #
         
     | 
| 
       14 
14 
     | 
    
         
             
            # DEPENDENCIES:
         
     | 
| 
       15 
15 
     | 
    
         
             
            #   gem: sensu-plugin
         
     | 
| 
       16 
     | 
    
         
            -
            #   gem: socket
         
     | 
| 
       17 
16 
     | 
    
         
             
            #
         
     | 
| 
       18 
17 
     | 
    
         
             
            # USAGE:
         
     | 
| 
       19 
18 
     | 
    
         
             
            #
         
     | 
| 
         @@ -44,7 +43,7 @@ class InterfaceGraphite < Sensu::Plugin::Metric::CLI::Graphite 
     | 
|
| 
       44 
43 
     | 
    
         
             
                     long: '--exclude-interface',
         
     | 
| 
       45 
44 
     | 
    
         
             
                     proc: proc { |a| a.split(',') }
         
     | 
| 
       46 
45 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
              def run 
     | 
| 
      
 46 
     | 
    
         
            +
              def run
         
     | 
| 
       48 
47 
     | 
    
         
             
                # Metrics borrowed from hoardd: https://github.com/coredump/hoardd
         
     | 
| 
       49 
48 
     | 
    
         | 
| 
       50 
49 
     | 
    
         
             
                metrics = %w(rxBytes
         
     | 
    
        data/bin/metrics-net.rb
    CHANGED
    
    | 
         @@ -57,7 +57,7 @@ class LinuxPacketMetrics < Sensu::Plugin::Metric::CLI::Graphite 
     | 
|
| 
       57 
57 
     | 
    
         
             
                     long: '--scheme SCHEME',
         
     | 
| 
       58 
58 
     | 
    
         
             
                     default: "#{Socket.gethostname}.net"
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
              def run 
     | 
| 
      
 60 
     | 
    
         
            +
              def run
         
     | 
| 
       61 
61 
     | 
    
         
             
                timestamp = Time.now.to_i
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                Dir.glob('/sys/class/net/*').each do |iface_path|
         
     | 
    
        data/bin/metrics-netif.rb
    CHANGED
    
    | 
         @@ -13,7 +13,6 @@ 
     | 
|
| 
       13 
13 
     | 
    
         
             
            #
         
     | 
| 
       14 
14 
     | 
    
         
             
            # DEPENDENCIES:
         
     | 
| 
       15 
15 
     | 
    
         
             
            #   gem: sensu-plugin
         
     | 
| 
       16 
     | 
    
         
            -
            #   gem: socket
         
     | 
| 
       17 
16 
     | 
    
         
             
            #
         
     | 
| 
       18 
17 
     | 
    
         
             
            # USAGE:
         
     | 
| 
       19 
18 
     | 
    
         
             
            #   #YELLOW
         
     | 
| 
         @@ -38,8 +37,7 @@ class NetIFMetrics < Sensu::Plugin::Metric::CLI::Graphite 
     | 
|
| 
       38 
37 
     | 
    
         
             
                     long: '--scheme SCHEME',
         
     | 
| 
       39 
38 
     | 
    
         
             
                     default: "#{Socket.gethostname}"
         
     | 
| 
       40 
39 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
              def run 
     | 
| 
       42 
     | 
    
         
            -
                # #YELLOW
         
     | 
| 
      
 40 
     | 
    
         
            +
              def run
         
     | 
| 
       43 
41 
     | 
    
         
             
                `sar -n DEV 1 1 | grep Average | grep -v IFACE`.each_line do |line|  # rubocop:disable Style/Next
         
     | 
| 
       44 
42 
     | 
    
         
             
                  stats = line.split(/\s+/)
         
     | 
| 
       45 
43 
     | 
    
         
             
                  unless stats.empty?
         
     | 
    
        data/bin/metrics-netstat-tcp.rb
    CHANGED
    
    | 
         @@ -76,11 +76,10 @@ class NetstatTCPMetrics < Sensu::Plugin::Metric::CLI::Graphite 
     | 
|
| 
       76 
76 
     | 
    
         
             
                     long: '--port PORT',
         
     | 
| 
       77 
77 
     | 
    
         
             
                     proc: proc(&:to_i)
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
              def netstat(protocol = 'tcp') 
     | 
| 
      
 79 
     | 
    
         
            +
              def netstat(protocol = 'tcp')
         
     | 
| 
       80 
80 
     | 
    
         
             
                state_counts = Hash.new(0)
         
     | 
| 
       81 
81 
     | 
    
         
             
                TCP_STATES.each_pair { |_hex, name| state_counts[name] = 0 }
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
                # #YELLOW
         
     | 
| 
       84 
83 
     | 
    
         
             
                File.open('/proc/net/' + protocol).each do |line| # rubocop:disable Style/Next
         
     | 
| 
       85 
84 
     | 
    
         
             
                  line.strip!
         
     | 
| 
       86 
85 
     | 
    
         
             
                  if m = line.match(/^\s*\d+:\s+(.{8}):(.{4})\s+(.{8}):(.{4})\s+(.{2})/) # rubocop:disable AssignmentInCondition
         
     | 
    
        data/bin/metrics-ping.rb
    ADDED
    
    | 
         @@ -0,0 +1,104 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #! /usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # metrics-ping
         
     | 
| 
      
 4 
     | 
    
         
            +
            #
         
     | 
| 
      
 5 
     | 
    
         
            +
            # DESCRIPTION:
         
     | 
| 
      
 6 
     | 
    
         
            +
            #  This plugin pings a host and outputs ping statistics
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            # OUTPUT:
         
     | 
| 
      
 9 
     | 
    
         
            +
            #  <scheme>.packets_transmitted 5 1437137076
         
     | 
| 
      
 10 
     | 
    
         
            +
            #  <scheme>.packets_received 5 1437137076
         
     | 
| 
      
 11 
     | 
    
         
            +
            #  <scheme>.packet_loss 0 1437137076
         
     | 
| 
      
 12 
     | 
    
         
            +
            #  <scheme>.time 3996 1437137076
         
     | 
| 
      
 13 
     | 
    
         
            +
            #  <scheme>.min 0.016 1437137076
         
     | 
| 
      
 14 
     | 
    
         
            +
            #  <scheme>.max 0.017 1437137076
         
     | 
| 
      
 15 
     | 
    
         
            +
            #  <scheme>.avg 0.019 1437137076
         
     | 
| 
      
 16 
     | 
    
         
            +
            #  <scheme>.mdev 0.004 1437137076
         
     | 
| 
      
 17 
     | 
    
         
            +
            #
         
     | 
| 
      
 18 
     | 
    
         
            +
            # PLATFORMS:
         
     | 
| 
      
 19 
     | 
    
         
            +
            #   Linux
         
     | 
| 
      
 20 
     | 
    
         
            +
            #
         
     | 
| 
      
 21 
     | 
    
         
            +
            # DEPENDENCIES:
         
     | 
| 
      
 22 
     | 
    
         
            +
            #   gem: sensu-plugin
         
     | 
| 
      
 23 
     | 
    
         
            +
            #   gem: open3
         
     | 
| 
      
 24 
     | 
    
         
            +
            #
         
     | 
| 
      
 25 
     | 
    
         
            +
            # USAGE:
         
     | 
| 
      
 26 
     | 
    
         
            +
            #   ./metric-ping --host <host> --count <count> \
         
     | 
| 
      
 27 
     | 
    
         
            +
            #                 --timeout <timeout> --scheme <scheme>
         
     | 
| 
      
 28 
     | 
    
         
            +
            #
         
     | 
| 
      
 29 
     | 
    
         
            +
            # NOTES:
         
     | 
| 
      
 30 
     | 
    
         
            +
            #
         
     | 
| 
      
 31 
     | 
    
         
            +
            # LICENSE:
         
     | 
| 
      
 32 
     | 
    
         
            +
            #   Copyright 2015 Rob Wilson <roobert@gmail.com>
         
     | 
| 
      
 33 
     | 
    
         
            +
            #   Released under the same terms as Sensu (the MIT license); see LICENSE
         
     | 
| 
      
 34 
     | 
    
         
            +
            #   for details.
         
     | 
| 
      
 35 
     | 
    
         
            +
            #
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            require 'sensu-plugin/check/cli'
         
     | 
| 
      
 38 
     | 
    
         
            +
            require 'socket'
         
     | 
| 
      
 39 
     | 
    
         
            +
            require 'open3'
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            class PingMetrics < Sensu::Plugin::Check::CLI
         
     | 
| 
      
 42 
     | 
    
         
            +
              option :scheme,
         
     | 
| 
      
 43 
     | 
    
         
            +
                     description: 'Metric naming scheme, text to prepend to metric',
         
     | 
| 
      
 44 
     | 
    
         
            +
                     short: '-s SCHEME',
         
     | 
| 
      
 45 
     | 
    
         
            +
                     long: '--scheme SCHEME',
         
     | 
| 
      
 46 
     | 
    
         
            +
                     default: "#{Socket.gethostname}.ping"
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              option :host,
         
     | 
| 
      
 49 
     | 
    
         
            +
                     description: 'Host to ping',
         
     | 
| 
      
 50 
     | 
    
         
            +
                     short: '-h HOST',
         
     | 
| 
      
 51 
     | 
    
         
            +
                     long: '--host HOST',
         
     | 
| 
      
 52 
     | 
    
         
            +
                     default: 'localhost'
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              option :count,
         
     | 
| 
      
 55 
     | 
    
         
            +
                     description: 'Ping count',
         
     | 
| 
      
 56 
     | 
    
         
            +
                     short: '-c COUNT',
         
     | 
| 
      
 57 
     | 
    
         
            +
                     long: '--count COUNT',
         
     | 
| 
      
 58 
     | 
    
         
            +
                     default: 5
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              option :timeout,
         
     | 
| 
      
 61 
     | 
    
         
            +
                     description: 'Timeout',
         
     | 
| 
      
 62 
     | 
    
         
            +
                     short: '-t TIMEOUT',
         
     | 
| 
      
 63 
     | 
    
         
            +
                     long: '--timeout TIMEOUT',
         
     | 
| 
      
 64 
     | 
    
         
            +
                     default: 5
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
              OVERVIEW_METRICS = [:packets_transmitted, :packets_received, :packet_loss, :time]
         
     | 
| 
      
 67 
     | 
    
         
            +
              STATISTIC_METRICS = [:min, :max, :avg, :mdev]
         
     | 
| 
      
 68 
     | 
    
         
            +
              FLOAT = '(\d+\.\d+)'
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
              def overview
         
     | 
| 
      
 71 
     | 
    
         
            +
                @ping.split("\n")[-2].scan(/^(\d+) packets transmitted, (\d+) received, (\d+)% packet loss, time (\d+)ms/)[0]
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              def statistics
         
     | 
| 
      
 75 
     | 
    
         
            +
                @ping.split("\n")[-1].scan(/^rtt min\/avg\/max\/mdev = #{FLOAT}\/#{FLOAT}\/#{FLOAT}\/#{FLOAT} ms/)[0]
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              def results
         
     | 
| 
      
 79 
     | 
    
         
            +
                Hash[OVERVIEW_METRICS.zip(overview)].merge Hash[STATISTIC_METRICS.zip(statistics)]
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
              def timestamp
         
     | 
| 
      
 83 
     | 
    
         
            +
                @timestamp ||= Time.now.to_i
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              def output
         
     | 
| 
      
 87 
     | 
    
         
            +
                results.each { |metric, value| puts "#{config[:scheme]}.#{metric} #{value} #{timestamp}" }
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              def ping
         
     | 
| 
      
 91 
     | 
    
         
            +
                @ping, @status = Open3.capture2e("ping -W#{config[:timeout]} -c#{config[:count]} #{config[:host]}")
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              def validate
         
     | 
| 
      
 95 
     | 
    
         
            +
                critical "ping error: (#{status}): #{@ping}" if @status != 0
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              def run
         
     | 
| 
      
 99 
     | 
    
         
            +
                ping
         
     | 
| 
      
 100 
     | 
    
         
            +
                validate
         
     | 
| 
      
 101 
     | 
    
         
            +
                output
         
     | 
| 
      
 102 
     | 
    
         
            +
                exit 0
         
     | 
| 
      
 103 
     | 
    
         
            +
              end
         
     | 
| 
      
 104 
     | 
    
         
            +
            end
         
     | 
    
        data/bin/metrics-sockstat.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: sensu-plugins-network-checks
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Sensu-Plugins and contributors
         
     | 
| 
         @@ -30,7 +30,7 @@ cert_chain: 
     | 
|
| 
       30 
30 
     | 
    
         
             
              8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
         
     | 
| 
       31 
31 
     | 
    
         
             
              HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
         
     | 
| 
       32 
32 
     | 
    
         
             
              -----END CERTIFICATE-----
         
     | 
| 
       33 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 33 
     | 
    
         
            +
            date: 2015-08-05 00:00:00.000000000 Z
         
     | 
| 
       34 
34 
     | 
    
         
             
            dependencies:
         
     | 
| 
       35 
35 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       36 
36 
     | 
    
         
             
              name: dnsbl-client
         
     | 
| 
         @@ -80,14 +80,14 @@ dependencies: 
     | 
|
| 
       80 
80 
     | 
    
         
             
                requirements:
         
     | 
| 
       81 
81 
     | 
    
         
             
                - - '='
         
     | 
| 
       82 
82 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       83 
     | 
    
         
            -
                    version: 3. 
     | 
| 
      
 83 
     | 
    
         
            +
                    version: 3.6.0
         
     | 
| 
       84 
84 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       85 
85 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       86 
86 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       87 
87 
     | 
    
         
             
                requirements:
         
     | 
| 
       88 
88 
     | 
    
         
             
                - - '='
         
     | 
| 
       89 
89 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       90 
     | 
    
         
            -
                    version: 3. 
     | 
| 
      
 90 
     | 
    
         
            +
                    version: 3.6.0
         
     | 
| 
       91 
91 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       92 
92 
     | 
    
         
             
              name: bundler
         
     | 
| 
       93 
93 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -178,14 +178,14 @@ dependencies: 
     | 
|
| 
       178 
178 
     | 
    
         
             
                requirements:
         
     | 
| 
       179 
179 
     | 
    
         
             
                - - '='
         
     | 
| 
       180 
180 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       181 
     | 
    
         
            -
                    version:  
     | 
| 
      
 181 
     | 
    
         
            +
                    version: 0.32.1
         
     | 
| 
       182 
182 
     | 
    
         
             
              type: :development
         
     | 
| 
       183 
183 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       184 
184 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       185 
185 
     | 
    
         
             
                requirements:
         
     | 
| 
       186 
186 
     | 
    
         
             
                - - '='
         
     | 
| 
       187 
187 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       188 
     | 
    
         
            -
                    version:  
     | 
| 
      
 188 
     | 
    
         
            +
                    version: 0.32.1
         
     | 
| 
       189 
189 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       190 
190 
     | 
    
         
             
              name: redcarpet
         
     | 
| 
       191 
191 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -214,15 +214,20 @@ dependencies: 
     | 
|
| 
       214 
214 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       215 
215 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       216 
216 
     | 
    
         
             
                    version: '0.8'
         
     | 
| 
       217 
     | 
    
         
            -
            description:  
     | 
| 
      
 217 
     | 
    
         
            +
            description: |-
         
     | 
| 
      
 218 
     | 
    
         
            +
              This plugin provides native network instrumentation
         
     | 
| 
      
 219 
     | 
    
         
            +
                                            for monitoring and metrics collection, including:
         
     | 
| 
      
 220 
     | 
    
         
            +
                                            hardware, TCP response, RBLs, whois, port status, and more
         
     | 
| 
       218 
221 
     | 
    
         
             
            email: "<sensu-users@googlegroups.com>"
         
     | 
| 
       219 
222 
     | 
    
         
             
            executables:
         
     | 
| 
       220 
223 
     | 
    
         
             
            - metrics-sockstat.rb
         
     | 
| 
      
 224 
     | 
    
         
            +
            - metrics-ping.rb
         
     | 
| 
       221 
225 
     | 
    
         
             
            - metrics-netstat-tcp.rb
         
     | 
| 
       222 
226 
     | 
    
         
             
            - metrics-netif.rb
         
     | 
| 
       223 
227 
     | 
    
         
             
            - metrics-net.rb
         
     | 
| 
       224 
228 
     | 
    
         
             
            - metrics-interface.rb
         
     | 
| 
       225 
229 
     | 
    
         
             
            - check-whois-domain-expiration.rb
         
     | 
| 
      
 230 
     | 
    
         
            +
            - check-whois-domain-expiration-multi.rb
         
     | 
| 
       226 
231 
     | 
    
         
             
            - check-rbl.rb
         
     | 
| 
       227 
232 
     | 
    
         
             
            - check-ports.rb
         
     | 
| 
       228 
233 
     | 
    
         
             
            - check-ping.rb
         
     | 
| 
         @@ -243,11 +248,13 @@ files: 
     | 
|
| 
       243 
248 
     | 
    
         
             
            - bin/check-ping.rb
         
     | 
| 
       244 
249 
     | 
    
         
             
            - bin/check-ports.rb
         
     | 
| 
       245 
250 
     | 
    
         
             
            - bin/check-rbl.rb
         
     | 
| 
      
 251 
     | 
    
         
            +
            - bin/check-whois-domain-expiration-multi.rb
         
     | 
| 
       246 
252 
     | 
    
         
             
            - bin/check-whois-domain-expiration.rb
         
     | 
| 
       247 
253 
     | 
    
         
             
            - bin/metrics-interface.rb
         
     | 
| 
       248 
254 
     | 
    
         
             
            - bin/metrics-net.rb
         
     | 
| 
       249 
255 
     | 
    
         
             
            - bin/metrics-netif.rb
         
     | 
| 
       250 
256 
     | 
    
         
             
            - bin/metrics-netstat-tcp.rb
         
     | 
| 
      
 257 
     | 
    
         
            +
            - bin/metrics-ping.rb
         
     | 
| 
       251 
258 
     | 
    
         
             
            - bin/metrics-sockstat.rb
         
     | 
| 
       252 
259 
     | 
    
         
             
            - lib/sensu-plugins-network-checks.rb
         
     | 
| 
       253 
260 
     | 
    
         
             
            - lib/sensu-plugins-network-checks/version.rb
         
     | 
| 
         @@ -277,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       277 
284 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       278 
285 
     | 
    
         
             
            requirements: []
         
     | 
| 
       279 
286 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       280 
     | 
    
         
            -
            rubygems_version: 2.4. 
     | 
| 
      
 287 
     | 
    
         
            +
            rubygems_version: 2.4.8
         
     | 
| 
       281 
288 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       282 
289 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       283 
290 
     | 
    
         
             
            summary: Sensu plugins for checking network hardware, connections, and data
         
     | 
    
        metadata.gz.sig
    CHANGED
    
    | 
         Binary file 
     |