sensu-plugins-process-checks 2.7.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 876caee1acc9312011319211530a65c0277ba8827397e5b0efb1855417e95f64
4
- data.tar.gz: 7d353e6e88a47b7d9edb50586f08e4569a2b4ebe578df3a91ececdf5c9cb01fb
3
+ metadata.gz: e5b5afd51c3a410249cf094508d91b7c7c4b78efc436b82fc9997f52922b3928
4
+ data.tar.gz: 0537e6f072b295a549c73621177eca769c95b69c04dfb520003639575364c4b2
5
5
  SHA512:
6
- metadata.gz: e9cb951943643d96a22cd791b742db5dc7c5b1540a966373597149fabd365e5ae3e4fdbcf4a36844def13ce0a6c85106afef2bab9fb302eaba226b717e00743a
7
- data.tar.gz: 8a07af4a8bc3eacb1b8ed6829a08db70cdc392cdc8e25bdf7bcbcf4460d6971ab451fdb048f40ef0cbe8b9308872930822ebb339a19fd9979f3d9ff9ea2691df
6
+ metadata.gz: f1574fa7c4e7a744dd594e7c47041305c73a0663158556f59c898aa4b2eb0afcb2a8a0e9b9000b9c4e4fb7717c4fc92d5cee7d566f2adcfb6555526cd709d35c
7
+ data.tar.gz: ce3d9ecd31545e84f8ad8ca7e891df4d5983833ed4e4ea7f8f1bb1c014a940d041dad3109d9fa9c46cfbf83b69bfc3a0b6beca231ca9ce7a1a230cd89fa93382
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.0.0] - 2018-03-17
10
+ ### Security
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
+ - removed ruby `< 2.1` support (@majormoses)
15
+
16
+ ### Changed
17
+ - appeased the cops (@majormoses)
18
+
9
19
  ## [2.7.0] - 2018-01-06
10
20
  ### Changed
11
21
  - metrics-per-processes.py: Add option to find processes by username (@rthouvenin)
@@ -160,7 +170,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
160
170
  - built against 1.9.3, 2.0, 2.1
161
171
  - cryptographically signed
162
172
 
163
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/2.7.0...HEAD
173
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/3.0.0...HEAD
174
+ [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/2.7.0...3.0.0
164
175
  [2.7.0]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/2.6.0...2.7.0
165
176
  [2.6.0]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/2.5.0...2.6.0
166
177
  [2.5.0]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/2.4.0...2.5.0
@@ -1,5 +1,4 @@
1
1
  #! /usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-process-restart
5
4
  #
data/bin/check-process.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  #! /usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # check-process
5
4
  #
@@ -209,7 +208,7 @@ class CheckProcess < Sensu::Plugin::Check::CLI
209
208
  #
210
209
  def on_cygwin?
211
210
  # #YELLOW
212
- `ps -W 2>&1`; $CHILD_STATUS.exitstatus == 0 # rubocop:disable Semicolon
211
+ `ps -W 2>&1`; $CHILD_STATUS.zero? # rubocop:disable Semicolon
213
212
  end
214
213
 
215
214
  # Acquire all the proceeses on a system for further analysis
@@ -253,13 +252,13 @@ class CheckProcess < Sensu::Plugin::Check::CLI
253
252
  procs = acquire_procs
254
253
 
255
254
  if config[:file_pid] && (file_pid = read_pid(config[:file_pid]))
256
- procs.reject! { |p| p[:pid].to_i != file_pid }
255
+ procs.select! { |p| p[:pid].to_i == file_pid }
257
256
  end
258
257
 
259
258
  procs.reject! { |p| p[:pid].to_i == $PROCESS_ID } unless config[:match_self]
260
259
  procs.reject! { |p| p[:pid].to_i == Process.ppid } unless config[:match_parent]
261
260
  procs.reject! { |p| p[:command] =~ /#{config[:exclude_pat]}/ } if config[:exclude_pat]
262
- procs.reject! { |p| p[:command] !~ /#{config[:cmd_pat]}/ } if config[:cmd_pat]
261
+ procs.select! { |p| p[:command] =~ /#{config[:cmd_pat]}/ } if config[:cmd_pat]
263
262
  procs.select! { |p| p[:vsz].to_f > config[:vsz] } if config[:vsz]
264
263
  procs.select! { |p| p[:rss].to_f > config[:rss] } if config[:rss]
265
264
  procs.select! { |p| p[:cpu].to_f > config[:cpu_utilization] } if config[:cpu_utilization]
@@ -268,8 +267,8 @@ class CheckProcess < Sensu::Plugin::Check::CLI
268
267
  procs.reject! { |p| etime_to_esec(p[:etime]) <= config[:esec_over] } if config[:esec_over]
269
268
  procs.reject! { |p| cputime_to_csec(p[:time]) >= config[:cpu_under] } if config[:cpu_under]
270
269
  procs.reject! { |p| cputime_to_csec(p[:time]) <= config[:cpu_over] } if config[:cpu_over]
271
- procs.reject! { |p| !config[:state].include?(p[:state]) } if config[:state]
272
- procs.reject! { |p| !config[:user].include?(p[:user]) } if config[:user]
270
+ procs.select! { |p| config[:state].include?(p[:state]) } if config[:state]
271
+ procs.select! { |p| config[:user].include?(p[:user]) } if config[:user]
273
272
 
274
273
  msg = "Found #{procs.size} matching processes"
275
274
  msg += "; cmd /#{config[:cmd_pat]}/" if config[:cmd_pat]
@@ -287,7 +286,7 @@ class CheckProcess < Sensu::Plugin::Check::CLI
287
286
 
288
287
  if config[:metric]
289
288
  # #YELLOW
290
- count = procs.map { |p| p[config[:metric]].to_i }.reduce { |a, b| a + b } # rubocop:disable SingleLineBlockParams
289
+ count = procs.map { |p| p[config[:metric]].to_i }.reduce { |a, b| a + b }
291
290
  msg += "; #{config[:metric]} == #{count}"
292
291
  else
293
292
  count = procs.size
@@ -51,9 +51,13 @@ class ThreadsCount < Sensu::Plugin::Check::CLI
51
51
  # Takes a value to be tested as an integer. If a new Integer instance cannot be created from it, return 1.
52
52
  # See the comments on get_process_threads() for why 1 is returned.
53
53
  def test_int(i)
54
- return Integer(i)
55
- rescue
56
- return 1
54
+ Integer(i)
55
+ rescue TypeError
56
+ 1
57
+ rescue ArgumentError
58
+ 1
59
+ rescue StandardError
60
+ 1
57
61
  end
58
62
 
59
63
  # Takes a process struct from Sys::ProcTable.ps() as an argument
@@ -61,12 +65,12 @@ class ThreadsCount < Sensu::Plugin::Check::CLI
61
65
  # Returns the number of processes in those fields.
62
66
  # Otherwise, returns 1 as all processes are assumed to have at least one thread.
63
67
  def get_process_threads(p)
64
- if p.respond_to?(:nlwp) # rubocop:disable Style/GuardClause
65
- return test_int(p.nlwp)
68
+ if p.respond_to?(:nlwp)
69
+ test_int(p.nlwp)
66
70
  elsif p.respond_to?(:thread_count)
67
- return test_int(p.thread_count)
71
+ test_int(p.thread_count)
68
72
  else
69
- return 1
73
+ 1
70
74
  end
71
75
  end
72
76
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- bin_dir = File.expand_path(File.dirname(__FILE__))
3
+ bin_dir = File.expand_path(__dir__)
4
4
  shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.py')
5
5
 
6
6
  exec shell_script_path, *ARGV
@@ -1,5 +1,4 @@
1
1
  #! /usr/bin/env ruby
2
- # encoding: UTF-8
3
2
  #
4
3
  # proc-status-metrics
5
4
  #
@@ -92,7 +91,7 @@ class ProcStatus < Sensu::Plugin::Metric::CLI::Graphite
92
91
  #
93
92
  def acquire_valid_pids(pgrep_output)
94
93
  res = pgrep_output.split("\n").map(&:strip)
95
- pids = res.reject { |x| !x.integer? }
94
+ pids = res.select(&:integer?)
96
95
  pids
97
96
  end
98
97
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- bin_dir = File.expand_path(File.dirname(__FILE__))
3
+ bin_dir = File.expand_path(__dir__)
4
4
  shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.sh')
5
5
 
6
6
  exec shell_script_path, *ARGV
@@ -3,7 +3,7 @@
3
3
  #Author: Abhishek Jain<abhi111jain@gmail.com
4
4
 
5
5
  #This script greps for a process if the process name is specified or looks for the pid file in case the path to the pid file is specified.
6
- #If the grep is successful in the former case or the pid file is present with a valid running state in the latter case, a value of 1 is
6
+ #If the grep is successful in the former case or the pid file is present with a valid running state in the latter case, a value of 1 is
7
7
  #associated with the metric (<metric_name> <metric value> <timestamp>) format and outputted otherwise a value of 0 is emitted with the same format.
8
8
  #The metric name is constructed based on the scheme prefix specified. If not specified, the hostname is picked as the metric scheme and the metric
9
9
  #name is <hostname>.<process_name>.<uptime>
@@ -62,7 +62,7 @@ class ProcessesThreadsCount < Sensu::Plugin::Metric::CLI::Graphite
62
62
  # See the comments on get_process_threads() for why 1 is returned.
63
63
  def test_int(i)
64
64
  return Integer(i)
65
- rescue
65
+ rescue StandardError
66
66
  return 1
67
67
  end
68
68
 
@@ -71,12 +71,12 @@ class ProcessesThreadsCount < Sensu::Plugin::Metric::CLI::Graphite
71
71
  # Returns the number of processes in those fields.
72
72
  # Otherwise, returns 1 as all processes are assumed to have at least one thread.
73
73
  def get_process_threads(p)
74
- if p.respond_to?(:nlwp) # rubocop:disable Style/GuardClause
75
- return test_int(p.nlwp)
74
+ if p.respond_to?(:nlwp)
75
+ test_int(p.nlwp)
76
76
  elsif p.respond_to?(:thread_count)
77
- return test_int(p.thread_count)
77
+ test_int(p.thread_count)
78
78
  else
79
- return 1
79
+ 1
80
80
  end
81
81
  end
82
82
 
@@ -92,7 +92,7 @@ class ProcessesThreadsCount < Sensu::Plugin::Metric::CLI::Graphite
92
92
  # Counts the processes by status and returns the hash
93
93
  def count_processes_by_status(ps_table)
94
94
  list_proc = {}
95
- %w(S R D T t X Z).each do |v|
95
+ %w[S R D T t X Z].each do |v|
96
96
  list_proc[v] = 0
97
97
  end
98
98
  if ps_table.first.respond_to?(:state)
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsProcessChecks
2
2
  module Version
3
- MAJOR = 2
4
- MINOR = 7
3
+ MAJOR = 3
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-process-checks
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-07 00:00:00.000000000 Z
11
+ date: 2018-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: english
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.40.0
159
+ version: 0.51.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.40.0
166
+ version: 0.51.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: yard
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -228,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  requirements:
229
229
  - - ">="
230
230
  - !ruby/object:Gem::Version
231
- version: 2.0.0
231
+ version: 2.1.0
232
232
  required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - ">="
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  version: '0'
237
237
  requirements: []
238
238
  rubyforge_project:
239
- rubygems_version: 2.7.4
239
+ rubygems_version: 2.7.6
240
240
  signing_key:
241
241
  specification_version: 4
242
242
  summary: Sensu plugins for checking running processes