sensu-plugins-process-checks 1.0.0 → 2.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
  SHA1:
3
- metadata.gz: 5f15fc531214b09f781c533578d443bb4365b6da
4
- data.tar.gz: c10670a3beb7f91a1f3eb4e8b08c673a47d497c1
3
+ metadata.gz: cac4dabc14637107d249a25b6433d181aced85ba
4
+ data.tar.gz: 0b4518cc291f7353a0e6df9f922c3be91d7ffcb2
5
5
  SHA512:
6
- metadata.gz: bfaac1db94ea36f55d45a4cbc085e5db88e9268cee70fd163521c959cc241a8120b9403d03e0fe018cfe1cb9724c8e5494516df38ce21b4dfea8365f9608ffd5
7
- data.tar.gz: e96f93533cf597ea4bbb6cfa4b3ba2b320f207a8efefa0e47bba8c3ecc5755eb01ad2b3b4191f816356ebf8703068de8bde0a61778ebf3a4e101326cf6e6c86e
6
+ metadata.gz: b2cae1dbced906dbf167e698d22f8c1ef12742624452eca8aec5e0a31a0122854902e5dedcd1332bfd0295f7d453af48f115856b43026ba9bee28abcdc6e499a
7
+ data.tar.gz: b9d48b6ed2e4e354551537eb0288ab81c9803897190e2ad3f4793eb068e872edf2d17a4b45fe437477d4cf1af76777d26540b95cf83ad13afb6e56aae1657ed7
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+ ## [2.0.0] 2017-05-18
8
+ ### Breaking Changes
9
+ - check-process.rb: renamed `--propotional-set-size` to `--cpu-utilization` as that's really what it was. (@majormoses)
10
+ - check-process.rb: Flip the meaning of `-z`, `-r`, `-P` and `-T` to match what the help messages say they do. (@maoe)
11
+
12
+ ### Changed
13
+ - check-process.rb: Added `-F` option to trigger a critical if pid file is specified but non-existent. (@swibowo)
14
+
15
+ ### Added
16
+ - check-process-restart.rb: Allow additional arguments to be passed to the underlying tool using `-a`. (@tomduckering)
7
17
 
8
18
  ## [1.0.0] - 2016-06-21
9
19
  ### Fixed
@@ -103,7 +113,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
103
113
  - built against 1.9.3, 2.0, 2.1
104
114
  - cryptographically signed
105
115
 
106
- [unreleased]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/1.0.0...HEAD
116
+ [unreleased]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/2.0.0...HEAD
117
+ [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/1.0.0...2.0.0
107
118
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/0.0.6...1.0.0
108
119
  [0.0.6]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/0.0.5...0.0.6
109
120
  [0.0.5]: https://github.com/sensu-plugins/sensu-plugins-process-checks/compare/0.0.4...0.0.5
@@ -53,6 +53,11 @@ class CheckProcessRestart < Sensu::Plugin::Check::CLI
53
53
  description: 'the number of processes to need restart before critical',
54
54
  default: 2
55
55
 
56
+ option :args,
57
+ short: '-a ARGS',
58
+ description: 'arguments to pass to the checkrestart or needs-restarting tool. Quote flags like this: -a \'-p\'',
59
+ default: ''
60
+
56
61
  # Debian command to run
57
62
  CHECK_RESTART = '/usr/sbin/checkrestart'.freeze
58
63
 
@@ -84,8 +89,8 @@ class CheckProcessRestart < Sensu::Plugin::Check::CLI
84
89
  def run_checkrestart
85
90
  checkrestart_hash = { found: '', pids: [] }
86
91
 
87
- out = `sudo #{CHECK_RESTART} 2>&1`
88
- if $CHILD_STATUS.to_i != 0
92
+ out = `sudo #{CHECK_RESTART} #{config[:args]} 2>&1`
93
+ if $CHILD_STATUS.to_i.nonzero?
89
94
  checkrestart_hash[:found] = "Failed to run checkrestart: #{out}"
90
95
  else
91
96
  out.lines do |l|
@@ -108,11 +113,11 @@ class CheckProcessRestart < Sensu::Plugin::Check::CLI
108
113
  def run_needs_restarting
109
114
  needs_restarting_hash = { found: '', pids: [] }
110
115
 
111
- out = `sudo #{NEEDS_RESTARTING} 2>&1`
112
- if $CHILD_STATUS.to_i != 0
116
+ out = `sudo #{NEEDS_RESTARTING} #{config[:args]} 2>&1`
117
+ if $CHILD_STATUS.to_i.nonzero?
113
118
  needs_restarting_hash[:found] = "Failed to run needs-restarting: #{out}"
114
119
  else
115
- needs_restarting_hash[:found] = `sudo #{NEEDS_RESTARTING} | wc -l | tr -d "\n"`
120
+ needs_restarting_hash[:found] = `sudo #{NEEDS_RESTARTING} #{config[:args]} | wc -l | tr -d "\n"`
116
121
 
117
122
  out.lines do |l|
118
123
  m = /(\d+)\s:\s(.*)$/.match(l)
data/bin/check-process.rb CHANGED
@@ -106,6 +106,11 @@ class CheckProcess < Sensu::Plugin::Check::CLI
106
106
  long: '--file-pid PID',
107
107
  description: 'Check against a specific PID'
108
108
 
109
+ option :file_pid_crit,
110
+ short: '-F',
111
+ long: '--file-pid-crit',
112
+ description: 'Trigger a critical if pid file is specified but non-existent'
113
+
109
114
  option :vsz,
110
115
  short: '-z VSZ',
111
116
  long: '--virtual-memory-size VSZ',
@@ -118,9 +123,9 @@ class CheckProcess < Sensu::Plugin::Check::CLI
118
123
  description: 'Trigger on a Resident Set size is bigger than this',
119
124
  proc: proc(&:to_i)
120
125
 
121
- option :pcpu,
122
- short: '-P PCPU',
123
- long: '--proportional-set-size PCPU',
126
+ option :cpu_utilization,
127
+ short: '-P xx',
128
+ long: '--cpu-utilization xx',
124
129
  description: 'Trigger on a Proportional Set Size is bigger than this',
125
130
  proc: proc(&:to_f)
126
131
 
@@ -146,7 +151,7 @@ class CheckProcess < Sensu::Plugin::Check::CLI
146
151
  short: '-e SECONDS',
147
152
  long: '--esec-over SECONDS',
148
153
  proc: proc(&:to_i),
149
- description: 'Match processes that older that this, in SECONDS'
154
+ description: 'Match processes that are older than this, in SECONDS'
150
155
 
151
156
  option :esec_under,
152
157
  short: '-E SECONDS',
@@ -176,8 +181,10 @@ class CheckProcess < Sensu::Plugin::Check::CLI
176
181
  def read_pid(path)
177
182
  if File.exist?(path)
178
183
  File.read(path).strip.to_i
179
- else
184
+ elsif config[:file_pid_crit].nil?
180
185
  unknown "Could not read pid file #{path}"
186
+ else
187
+ critical "Could not read pid file #{path}"
181
188
  end
182
189
  end
183
190
 
@@ -221,7 +228,7 @@ class CheckProcess < Sensu::Plugin::Check::CLI
221
228
  end
222
229
  else
223
230
  read_lines('ps axwwo user,pid,vsz,rss,pcpu,nlwp,state,etime,time,command').drop(1).map do |line|
224
- line_to_hash(line, :user, :pid, :vsz, :rss, :pcpu, :thcount, :state, :etime, :time, :command)
231
+ line_to_hash(line, :user, :pid, :vsz, :rss, :cpu, :thcount, :state, :etime, :time, :command)
225
232
  end
226
233
  end
227
234
  end
@@ -248,14 +255,15 @@ class CheckProcess < Sensu::Plugin::Check::CLI
248
255
  if config[:file_pid] && (file_pid = read_pid(config[:file_pid]))
249
256
  procs.reject! { |p| p[:pid].to_i != file_pid }
250
257
  end
258
+
251
259
  procs.reject! { |p| p[:pid].to_i == $PROCESS_ID } unless config[:match_self]
252
260
  procs.reject! { |p| p[:pid].to_i == Process.ppid } unless config[:match_parent]
253
261
  procs.reject! { |p| p[:command] =~ /#{config[:exclude_pat]}/ } if config[:exclude_pat]
254
262
  procs.reject! { |p| p[:command] !~ /#{config[:cmd_pat]}/ } if config[:cmd_pat]
255
- procs.reject! { |p| p[:vsz].to_f > config[:vsz] } if config[:vsz]
256
- procs.reject! { |p| p[:rss].to_f > config[:rss] } if config[:rss]
257
- procs.reject! { |p| p[:pcpu].to_f > config[:pcpu] } if config[:pcpu]
258
- procs.reject! { |p| p[:thcount].to_i > config[:thcount] } if config[:thcount]
263
+ procs.select! { |p| p[:vsz].to_f > config[:vsz] } if config[:vsz]
264
+ procs.select! { |p| p[:rss].to_f > config[:rss] } if config[:rss]
265
+ procs.select! { |p| p[:cpu].to_f > config[:cpu_utilization] } if config[:cpu_utilization]
266
+ procs.select! { |p| p[:thcount].to_i > config[:thcount] } if config[:thcount]
259
267
  procs.reject! { |p| etime_to_esec(p[:etime]) >= config[:esec_under] } if config[:esec_under]
260
268
  procs.reject! { |p| etime_to_esec(p[:etime]) <= config[:esec_over] } if config[:esec_over]
261
269
  procs.reject! { |p| cputime_to_csec(p[:time]) >= config[:cpu_under] } if config[:cpu_under]
@@ -267,10 +275,10 @@ class CheckProcess < Sensu::Plugin::Check::CLI
267
275
  msg += "; cmd /#{config[:cmd_pat]}/" if config[:cmd_pat]
268
276
  msg += "; state #{config[:state].join(',')}" if config[:state]
269
277
  msg += "; user #{config[:user].join(',')}" if config[:user]
270
- msg += "; vsz < #{config[:vsz]}" if config[:vsz]
271
- msg += "; rss < #{config[:rss]}" if config[:rss]
272
- msg += "; pcpu < #{config[:pcpu]}" if config[:pcpu]
273
- msg += "; thcount < #{config[:thcount]}" if config[:thcount]
278
+ msg += "; vsz > #{config[:vsz]}" if config[:vsz]
279
+ msg += "; rss > #{config[:rss]}" if config[:rss]
280
+ msg += "; cpu > #{config[:cpu_utilization]}" if config[:cpu_utilization]
281
+ msg += "; thcount > #{config[:thcount]}" if config[:thcount]
274
282
  msg += "; esec < #{config[:esec_under]}" if config[:esec_under]
275
283
  msg += "; esec > #{config[:esec_over]}" if config[:esec_over]
276
284
  msg += "; csec < #{config[:cpu_under]}" if config[:cpu_under]
@@ -1,6 +1,6 @@
1
1
  module SensuPluginsProcessChecks
2
2
  module Version
3
- MAJOR = 1
3
+ MAJOR = 2
4
4
  MINOR = 0
5
5
  PATCH = 0
6
6
 
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: 1.0.0
4
+ version: 2.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: 2016-06-21 00:00:00.000000000 Z
11
+ date: 2017-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: english
@@ -232,9 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.5.1
235
+ rubygems_version: 2.4.5
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Sensu plugins for checking running processes
239
239
  test_files: []
240
- has_rdoc: