Skip to content

Commit 1c184dd

Browse files
committed
much needed cleanup
This includes: - dropping EOL ruby versions - bumping dependencies (some address CVEs) - appeasing or disabling new cops - removed codelimate dep as its not used anymore - removed some old badges For a more complete/detailed list see the changelog. Signed-off-by: Ben Abrams <[email protected]>
1 parent 18236bf commit 1c184dd

26 files changed

+90
-38
lines changed

.rubocop.yml

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Support all non EOL rubies
2+
AllCops:
3+
TargetRubyVersion: 2.3
14

25
MethodLength:
36
Max: 200
@@ -32,3 +35,7 @@ Style/Documentation:
3235
Style/BlockLength:
3336
Exclude:
3437
- 'test/**/*.rb'
38+
- 'sensu-plugins-windows.gemspec'
39+
40+
Style/SafeNavigation:
41+
Enabled: false

.travis.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
language: ruby
22
cache:
33
- bundler
4+
before_install:
5+
- gem install bundler -v 2.0
46
install:
57
- bundle install
68
rvm:
7-
- 2.0
8-
- 2.1
9-
- 2.2
109
- 2.3.0
1110
- 2.4.1
1211
notifications:
@@ -28,9 +27,6 @@ deploy:
2827
on:
2928
tags: true
3029
all_branches: true
31-
rvm: 2.0
32-
rvm: 2.1
33-
rvm: 2.2
3430
rvm: 2.3.0
3531
rvm: 2.4.1
3632
repo: sensu-plugins/sensu-plugins-windows

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
66

77
## [Unreleased]
88

9+
### Security
10+
- updated yard dependency to `~> 0.9.11` per: https://nvd.nist.gov/vuln/detail/CVE-2017-17042 (@majormoses)
11+
- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@majormoses)
12+
13+
### Breaking Changes
14+
- drop EOL rubies `< 2.3` (@majormoses)
15+
- bump `sensu-plugin` dependency from `~> 1.2` to `~> 4.0` you can read the changelog entries for [4.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#400---2018-02-17), [3.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#300---2018-12-04), and [2.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#v200---2017-03-29) (@majormoses)
16+
17+
### Changed
18+
- update `bundler` dependency (@majormoses)
19+
- appeased the cops (@majormoses)
20+
21+
### Removed
22+
- `codeclimate` (@majormoses)
23+
924
## [2.9.1] - 2019-02-17
1025
### Fixed
1126
- check-windows-disk.rb: use the full path for CSV file path due to a bug in `wmic` (@jasiek191)

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in sensu-plugins-windows.gemspec

README.md

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-windows.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-windows)
44
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-windows.svg)](http://badge.fury.io/rb/sensu-plugins-windows)
5-
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-windows/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-windows)
6-
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-windows/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-windows)
7-
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-windows.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-windows)
85
[![Appveyor status](https://ci.appveyor.com/api/projects/status/j6cg9tmxs6ivscrd/branch/master?svg=true)](https://ci.appveyor.com/project/majormoses/sensu-plugins-windows/branch/master)
96
[![Community Slack](https://slack.sensu.io/badge.svg)](https://slack.sensu.io/badge)
107

Rakefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'bundler/gem_tasks'
24
require 'github/markup'
35
require 'redcarpet'
@@ -7,9 +9,9 @@ require 'yard'
79
require 'yard/rake/yardoc_task'
810

911
YARD::Rake::YardocTask.new do |t|
10-
OTHER_PATHS = %w().freeze
12+
OTHER_PATHS = %w[].freeze
1113
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS]
12-
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md)
14+
t.options = %w[--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md]
1315
end
1416

1517
RuboCop::RakeTask.new
@@ -35,4 +37,4 @@ task :check_binstubs do
3537
end
3638
end
3739

38-
task default: [:spec, :make_bin_executable, :yard, :rubocop, :check_binstubs]
40+
task default: %i[spec make_bin_executable yard rubocop check_binstubs]

appveyor.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ environment:
99

1010
install:
1111
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
12-
# appveyor does not seem to have a way to cleanup the env and does not actually start from scratch each time
13-
- gem uninstall bundler --executables || true
14-
- gem install bundler -v 1.7
12+
- gem install bundler -v 2.0
1513
- bundle install
1614

1715
build: off

bin/check-windows-cpu-load.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# check-windows-cpu-load.rb
46
#

bin/check-windows-disk.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# check-windows-disk.rb
46
#
@@ -79,7 +81,7 @@ def read_wmic
7981
next if config[:ignoretype] && config[:ignoretype].include?(type)
8082
next if config[:ignoremnt] && config[:ignoremnt].include?(mnt)
8183
next if config[:ignorelabel] && config[:ignorelabel].match(label)
82-
rescue
84+
rescue StandardError
8385
unknown "malformed line from df: #{line}"
8486
end
8587
# If label value is not set, the drive letter will end up in that column. Set mnt to label in that case.

bin/check-windows-process.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# check-windows-process.rb
46
#
@@ -27,6 +29,7 @@
2729
require 'optparse'
2830
require 'time'
2931
require 'win32ole'
32+
require 'date'
3033

3134
options = {}
3235
parser = OptionParser.new do |opts|
@@ -70,7 +73,7 @@
7073
wmi.ExecQuery('select * from win32_process').each do |process|
7174
next unless process.Name.downcase.include? options[:procname].downcase
7275
if !options[:warn].nil?
73-
delta_days = DateTime.now - DateTime.parse(process.CreationDate)
76+
delta_days = DateTime.now - DateTime.parse(process.CreationDate) # rubocop:disable Style/DateTime
7477
delta_secs = (delta_days * 24 * 60 * 60).to_i
7578
if delta_secs > options[:warn]
7679
puts "OK: #{process.Name} running more than #{options[:warn]} seconds."

bin/check-windows-processor-queue-length.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# check-windows-processor-queue-length.rb
46
#

bin/check-windows-ram.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# check-windows-ram.rb
46
#
@@ -38,13 +40,13 @@ class CheckWindowsRAMLoad < Sensu::Plugin::Check::CLI
3840
proc: proc(&:to_i)
3941

4042
def acquire_ram_usage
41-
temp_arr_1 = []
42-
temp_arr_2 = []
43-
IO.popen('typeperf -sc 1 "Memory\\Available bytes" ') { |io| io.each { |line| temp_arr_1.push(line) } }
44-
temp = temp_arr_1[2].split(',')[1]
43+
temp_arr1 = []
44+
temp_arr2 = []
45+
IO.popen('typeperf -sc 1 "Memory\\Available bytes" ') { |io| io.each { |line| temp_arr1.push(line) } }
46+
temp = temp_arr1[2].split(',')[1]
4547
ram_available_in_bytes = temp[1, temp.length - 3].to_f
46-
IO.popen('wmic OS get TotalVisibleMemorySize /Value') { |io| io.each { |line| temp_arr_2.push(line) } }
47-
total_ram = temp_arr_2[4].split('=')[1].to_f
48+
IO.popen('wmic OS get TotalVisibleMemorySize /Value') { |io| io.each { |line| temp_arr2.push(line) } }
49+
total_ram = temp_arr2[4].split('=')[1].to_f
4850
total_ram_in_bytes = total_ram * 1000.0
4951
ram_use_percent = (total_ram_in_bytes - ram_available_in_bytes) * 100.0 / total_ram_in_bytes
5052
ram_use_percent.round(2)

bin/check-windows-service.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# check-windows-service.rb
46
#

bin/metric-windows-cpu-load.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# metric-windows-cpu-load.rb
46
#

bin/metric-windows-disk-usage.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# metric-windows-disk-usage.rb
46
#

bin/metric-windows-network.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# metric-windows-network.rb
46
#

bin/metric-windows-processor-queue-length.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# metric-windows-processor-queue-length.rb
46
#

bin/metric-windows-ram-usage.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# metric-windows-ram-usage.rb
46
#
@@ -36,14 +38,14 @@ class RamMetric < Sensu::Plugin::Metric::CLI::Graphite
3638
default: Socket.gethostname.to_s
3739

3840
def acquire_ram_usage
39-
temp_arr_1 = []
40-
temp_arr_2 = []
41+
temp_arr1 = []
42+
temp_arr2 = []
4143
timestamp = Time.now.utc.to_i
42-
IO.popen('typeperf -sc 1 "Memory\\Available bytes" ') { |io| io.each { |line| temp_arr_1.push(line) } }
43-
temp = temp_arr_1[2].split(',')[1]
44+
IO.popen('typeperf -sc 1 "Memory\\Available bytes" ') { |io| io.each { |line| temp_arr1.push(line) } }
45+
temp = temp_arr1[2].split(',')[1]
4446
ram_available_in_bytes = temp[1, temp.length - 3].to_f
45-
IO.popen('wmic OS get TotalVisibleMemorySize /Value') { |io| io.each { |line| temp_arr_2.push(line) } }
46-
total_ram = temp_arr_2[4].split('=')[1].to_f
47+
IO.popen('wmic OS get TotalVisibleMemorySize /Value') { |io| io.each { |line| temp_arr2.push(line) } }
48+
total_ram = temp_arr2[4].split('=')[1].to_f
4749
total_ram_in_bytes = total_ram * 1000.0
4850
ram_use_percent = (total_ram_in_bytes - ram_available_in_bytes) * 100.0 / total_ram_in_bytes
4951
[ram_use_percent.round(2), timestamp]

bin/metric-windows-uptime.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# metric-windows-uptime.rb
46
#

bin/powershell_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# powershell_helper.rb
46
#

lib/sensu-plugins-windows.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# frozen_string_literal: true
2+
13
require 'sensu-plugins-windows/version'

lib/sensu-plugins-windows/version.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SensuPluginsWindows
24
module Version
35
MAJOR = 2

sensu-plugins-windows.gemspec

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
lib = File.expand_path('../lib', __FILE__)
24
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
35

@@ -10,7 +12,7 @@ Gem::Specification.new do |s|
1012
s.description = 'Sensu plugins for Windows'
1113
s.email = '<[email protected]>'
1214
s.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) }
13-
s.files = Dir.glob('{bin,lib}/**/*') + %w(LICENSE README.md CHANGELOG.md)
15+
s.files = Dir.glob('{bin,lib}/**/*') + %w[LICENSE README.md CHANGELOG.md]
1416
s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-windows'
1517
s.license = 'MIT'
1618
s.metadata = { 'maintainer' => 'sensu-plugin',
@@ -22,20 +24,19 @@ Gem::Specification.new do |s|
2224
s.platform = Gem::Platform::RUBY
2325
s.post_install_message = 'You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu'
2426
s.require_paths = ['lib']
25-
s.required_ruby_version = '>= 2.0.0'
27+
s.required_ruby_version = '>= 2.3.0'
2628
s.summary = 'Sensu plugins for Windows'
2729
s.test_files = s.files.grep(%r{^(test|spec|features)/})
2830
s.version = SensuPluginsWindows::Version::VER_STRING
2931

30-
s.add_runtime_dependency 'sensu-plugin', '~> 1.2'
32+
s.add_runtime_dependency 'sensu-plugin', '~> 4.0'
3133

32-
s.add_development_dependency 'bundler', '~> 1.7'
33-
s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
34+
s.add_development_dependency 'bundler', '~> 2.0'
3435
s.add_development_dependency 'github-markup', '~> 3.0'
3536
s.add_development_dependency 'pry', '~> 0.10'
3637
s.add_development_dependency 'rake', '~> 12.3'
3738
s.add_development_dependency 'redcarpet', '~> 3.2'
38-
s.add_development_dependency 'rubocop', '~> 0.40.0'
3939
s.add_development_dependency 'rspec', '~> 3.1'
40-
s.add_development_dependency 'yard', '~> 0.8'
40+
s.add_development_dependency 'rubocop', '~> 0.51.0'
41+
s.add_development_dependency 'yard', '~> 0.9.11'
4142
end

test/check-windows-disk.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative '../bin/check-windows-disk.rb'
24

35
describe CheckDisk do

test/check-windows-service_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require_relative '../bin/check-windows-service.rb'
24

35
describe CheckWinService do

test/spec_helper.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
require 'codeclimate-test-reporter'
2-
CodeClimate::TestReporter.start
1+
# frozen_string_literal: true

0 commit comments

Comments
 (0)