sensu-plugins-cpu-checks 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1cb13bff39fee1b707508ac08fddfd3724e6893
4
- data.tar.gz: b9dbf16aed23205077bd3888d9c7d4671c563d28
3
+ metadata.gz: a074d040a240dead20971944d166b6e3b7505284
4
+ data.tar.gz: e671bc4985a80ebb41d2c9b53be24d1ddcf34244
5
5
  SHA512:
6
- metadata.gz: 676e5fe84e82f170c01ae9801c5ee4b3b117eb078888ca96e520933ade0a1acb64c2007a77fdd1773c783704a737a140207a9ec938620b95f1361c55bd33dc11
7
- data.tar.gz: c70ff013c9f503304f562c6b12e1c27fcc6e8d17afa4f20203c10a0608b305c1d88ca65484ebda354839adfb0945d7880effdfe8408c91dbfc7ca4d0f1d3da79
6
+ metadata.gz: 9d4ad55878708411784d6450da44a9bfadde539bffb07f71d9963e33882e1a7362a272e01846be521e06650228cdff64d4e0d74d3317d5a1e128a77190fd4433
7
+ data.tar.gz: 1937bbd262e78d1b56670c083fdbf113a82400fa113ceea3800bfba5d0d192153844358159ffc05f06d27415d846b71b72b7a8a9891eeeb45947e56fd03fd013
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -3,7 +3,12 @@ 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
7
+
8
+ ## [0.0.4] - 2015-09-29
9
+ ### Changed
10
+ - Fix getopts syntax in check-cpu.sh
11
+ - Improvements to system/metrics-user-pct-usage.rb (option to use uid instead of username)
7
12
 
8
13
  ## [0.0.3] - 2015-07-14
9
14
  ### Changed
@@ -20,4 +25,4 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
20
25
  - added binstubs
21
26
 
22
27
  ### Changed
23
- - removed cruft from /lib
28
+ - removed cruft from /lib
data/README.md CHANGED
@@ -20,6 +20,6 @@
20
20
 
21
21
  ## Installation
22
22
 
23
- [Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
23
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
24
24
 
25
25
  ## Notes
data/bin/check-cpu.rb CHANGED
@@ -62,7 +62,7 @@ class CheckCPU < Sensu::Plugin::Check::CLI
62
62
  end
63
63
  end
64
64
 
65
- def run # rubocop:disable all
65
+ def run
66
66
  metrics = [:user, :nice, :system, :idle, :iowait, :irq, :softirq, :steal, :guest]
67
67
 
68
68
  cpu_stats_before = acquire_cpu_stats
data/bin/check-cpu.sh CHANGED
@@ -15,7 +15,7 @@
15
15
  # for details.
16
16
 
17
17
  # get arguments
18
- while getopts 'w:c:h' OPT; do
18
+ while getopts ':w:c:h' OPT; do
19
19
  case $OPT in
20
20
  w) WARN=$OPTARG;;
21
21
  c) CRIT=$OPTARG;;
@@ -57,7 +57,7 @@ class CpuGraphite < Sensu::Plugin::Metric::CLI::Graphite
57
57
  metrics.values.reduce { |sum, metric| sum + metric } # rubocop:disable SingleLineBlockParams
58
58
  end
59
59
 
60
- def run # rubocop:disable all
60
+ def run
61
61
  cpu_sample1 = acquire_proc_stats
62
62
  sleep(1)
63
63
  cpu_sample2 = acquire_proc_stats
@@ -72,7 +72,7 @@ class CpuGraphite < Sensu::Plugin::Metric::CLI::Graphite
72
72
  cpu_sample_diff = Hash[cpu_sample2.map { |k, v| [k, v - cpu_sample1[k]] }]
73
73
 
74
74
  cpu_metrics.each do |metric|
75
- metric_val = sprintf('%.02f', (cpu_sample_diff[metric] / cpu_total_diff.to_f) * 100) # rubocop:disable all
75
+ metric_val = sprintf('%.02f', (cpu_sample_diff[metric] / cpu_total_diff.to_f) * 100)
76
76
  output "#{config[:scheme]}.#{metric}", metric_val
77
77
  end
78
78
  ok
data/bin/metrics-cpu.rb CHANGED
@@ -36,7 +36,7 @@ class CpuGraphite < Sensu::Plugin::Metric::CLI::Graphite
36
36
  long: '--scheme SCHEME',
37
37
  default: "#{Socket.gethostname}.cpu"
38
38
 
39
- def run # rubocop:disable all
39
+ def run
40
40
  cpu_metrics = %w(user nice system idle iowait irq softirq steal guest)
41
41
  other_metrics = %w(ctxt processes procs_running procs_blocked btime intr)
42
42
  cpu_count = 0
@@ -47,23 +47,32 @@ class UserPercent < Sensu::Plugin::Metric::CLI::Graphite
47
47
  long: '--ignore_inactive',
48
48
  default: true
49
49
 
50
- def run # rubocop:disable all
50
+ option :uid,
51
+ description: 'Boolean. If true, uses uid instead of username',
52
+ long: '--uid',
53
+ default: false
54
+
55
+ def run
51
56
  timestamp = Time.now.to_i
52
- pslist = `ps -A -o user= -o %cpu=`
57
+ usertype = config[:uid] ? 'uid' : 'user'
58
+ pslist = `ps -A -o #{usertype}= -o %cpu= -o %mem=`
53
59
 
54
60
  users = {}
55
61
  pslist.lines.each do |line|
56
- user, value = line.split
57
- h = { user => value.to_f }
58
- users = users.merge(h) { |_key, oldval, newval| newval + oldval }
62
+ user, cpu, mem = line.split
63
+ users[user] = {} unless users[user]
64
+ h = { 'cpu' => cpu.to_f, 'mem' => mem.to_f }
65
+ users[user] = users[user].merge(h) { |_key, oldval, newval| newval + oldval }
59
66
  end
60
67
 
61
68
  if config[:ignore_inactive]
62
- users.delete_if { |_key, value| value == 0 }
69
+ users.delete_if { |_key, value| value['cpu'] == 0 }
63
70
  end
64
71
 
65
- users.each do |key, value|
66
- output [config[:scheme], key].join('.'), value, timestamp
72
+ users.each do |user, h|
73
+ h.each do |key, value|
74
+ output [config[:scheme], user].join(".#{key}."), value, timestamp
75
+ end
67
76
  end
68
77
  ok
69
78
  end
@@ -2,7 +2,7 @@ module SensuPluginsCpuChecks
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 3
5
+ PATCH = 4
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-cpu-checks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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-07-14 00:00:00.000000000 Z
33
+ date: 2015-09-29 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sensu-plugin
@@ -80,14 +80,14 @@ dependencies:
80
80
  requirements:
81
81
  - - '='
82
82
  - !ruby/object:Gem::Version
83
- version: '0.30'
83
+ version: 0.32.1
84
84
  type: :development
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: '0.30'
90
+ version: 0.32.1
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
93
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +186,10 @@ dependencies:
186
186
  - - "~>"
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0.10'
189
- description: Sensu plugins for cpu checks and metrics
189
+ description: |-
190
+ This plugin provides native CPU instrumentation
191
+ for monitoring and metrics collection, including:
192
+ CPU usage and metrics
190
193
  email: "<sensu-users@googlegroups.com>"
191
194
  executables:
192
195
  - metrics-user-pct-usage.rb
@@ -235,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
238
  version: '0'
236
239
  requirements: []
237
240
  rubyforge_project:
238
- rubygems_version: 2.4.6
241
+ rubygems_version: 2.4.8
239
242
  signing_key:
240
243
  specification_version: 4
241
244
  summary: Sensu plugins for cpu checks and metrics
metadata.gz.sig CHANGED
Binary file