sensu-plugins-cpu-checks 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/bin/metrics-cpu-interrupts.rb +49 -0
- data/bin/metrics-cpu-softirqs.rb +49 -0
- data/bin/metrics-cpu.rb +1 -1
- data/bin/metrics-softnet-stat.rb +55 -0
- data/lib/sensu-plugins-cpu-checks.rb +1 -0
- data/lib/sensu-plugins-cpu-checks/common_interrupts.rb +31 -0
- data/lib/sensu-plugins-cpu-checks/version.rb +2 -2
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c35d99b197f2c02882d0ed2f782386437368deea7bce60099a52efb41648e7c
|
4
|
+
data.tar.gz: d96d35dfff48d9cf6606c4b060176bbcd91f271c52b216255c3b181704766028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364bc2203e9f747e33c34621bec7a2e1b6d61535fd7730b9933e3f119130d1fc5abeb0f859358c32250d0794b0f537729c7f070503104dce6d45841af1f3dd7d
|
7
|
+
data.tar.gz: 32b8cd8665438156b8d06ae7f34f7e521fca4a83b9a0e65012bd76865835242c027bc78068ceaa0076034119895c0d4d0886b0ede3462db9b656caa827c185d1
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [2.1.0] - 2018-04-2018
|
9
|
+
### Added
|
10
|
+
- Added metrics-cpu-interrupts.rb (@yuri-zubov sponsored by Actility, https://www.actility.com)
|
11
|
+
- Added metrics-cpu-softirqs.rb (@yuri-zubov sponsored by Actility, https://www.actility.com)
|
12
|
+
- Added metrics-softnet-stat.rb (@yuri-zubov sponsored by Actility, https://www.actility.com)
|
13
|
+
|
8
14
|
## [2.0.1] - 2018-03-27
|
9
15
|
### Security
|
10
16
|
- updated yard dependency to `~> 0.9.11` per: https://nvd.nist.gov/vuln/detail/CVE-2017-17042 (@majormoses)
|
@@ -83,7 +89,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
83
89
|
- initial release
|
84
90
|
|
85
91
|
|
86
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/2.0
|
92
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/2.1.0...HEAD
|
93
|
+
[2.1.0]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/2.0.1...2.1.0
|
87
94
|
[2.0.1]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/2.0.0...2.0.1
|
88
95
|
[2.0.0]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/1.1.3...2.0.0
|
89
96
|
[1.1.3]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/1.1.2...1.1.3
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# metrics-cpu-interrupts
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
#
|
7
|
+
# OUTPUT:
|
8
|
+
# metric data
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-plugin
|
15
|
+
#
|
16
|
+
# USAGE:
|
17
|
+
#
|
18
|
+
# NOTES:
|
19
|
+
#
|
20
|
+
# LICENSE:
|
21
|
+
# Zubov Yuri <yury.zubau@gmail.com> sponsored by Actility, https://www.actility.com
|
22
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
23
|
+
# for details.
|
24
|
+
#
|
25
|
+
require 'sensu-plugin/metric/cli'
|
26
|
+
require 'sensu-plugins-cpu-checks'
|
27
|
+
require 'socket'
|
28
|
+
|
29
|
+
#
|
30
|
+
# CPU Graphite
|
31
|
+
#
|
32
|
+
class MetricsCPUInterrupts < Sensu::Plugin::Metric::CLI::Graphite
|
33
|
+
include SensuPluginsCpuChecks::CommonInterrupts
|
34
|
+
option :scheme,
|
35
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
36
|
+
short: '-s SCHEME',
|
37
|
+
long: '--scheme SCHEME',
|
38
|
+
default: "#{Socket.gethostname}.interrupts"
|
39
|
+
|
40
|
+
option :proc_path,
|
41
|
+
long: '--proc-path /proc',
|
42
|
+
proc: proc(&:to_s),
|
43
|
+
default: '/proc'
|
44
|
+
|
45
|
+
def run
|
46
|
+
output_metrics('interrupts')
|
47
|
+
ok
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# metrics-cpu-softirqs
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
#
|
7
|
+
# OUTPUT:
|
8
|
+
# metric data
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-plugin
|
15
|
+
#
|
16
|
+
# USAGE:
|
17
|
+
#
|
18
|
+
# NOTES:
|
19
|
+
#
|
20
|
+
# LICENSE:
|
21
|
+
# Zubov Yuri <yury.zubau@gmail.com> sponsored by Actility, https://www.actility.com
|
22
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
23
|
+
# for details.
|
24
|
+
#
|
25
|
+
require 'sensu-plugin/metric/cli'
|
26
|
+
require 'sensu-plugins-cpu-checks'
|
27
|
+
require 'socket'
|
28
|
+
|
29
|
+
#
|
30
|
+
# CPU Graphite
|
31
|
+
#
|
32
|
+
class MetricsCPUSoftirqs < Sensu::Plugin::Metric::CLI::Graphite
|
33
|
+
include SensuPluginsCpuChecks::CommonInterrupts
|
34
|
+
option :scheme,
|
35
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
36
|
+
short: '-s SCHEME',
|
37
|
+
long: '--scheme SCHEME',
|
38
|
+
default: "#{Socket.gethostname}.softirqs"
|
39
|
+
|
40
|
+
option :proc_path,
|
41
|
+
long: '--proc-path /proc',
|
42
|
+
proc: proc(&:to_s),
|
43
|
+
default: '/proc'
|
44
|
+
|
45
|
+
def run
|
46
|
+
output_metrics('softirqs')
|
47
|
+
ok
|
48
|
+
end
|
49
|
+
end
|
data/bin/metrics-cpu.rb
CHANGED
@@ -59,7 +59,7 @@ class CpuGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
59
59
|
|
60
60
|
output "#{config[:scheme]}.#{name}", info.first if other_metrics.include? name
|
61
61
|
end
|
62
|
-
if cpu_count
|
62
|
+
if cpu_count.positive?
|
63
63
|
# writes the number of cpus, the minus 1 is because /proc/stat/
|
64
64
|
# first line is a "cpu" which is stats for total cpus
|
65
65
|
output "#{config[:scheme]}.cpu_count", cpu_count - 1
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# metrics-softnet-stat
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
#
|
7
|
+
# OUTPUT:
|
8
|
+
# metric data
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-plugin
|
15
|
+
#
|
16
|
+
# USAGE:
|
17
|
+
#
|
18
|
+
# NOTES:
|
19
|
+
#
|
20
|
+
# LICENSE:
|
21
|
+
# Zubov Yuri <yury.zubau@gmail.com> sponsored by Actility, https://www.actility.com
|
22
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
23
|
+
# for details.
|
24
|
+
#
|
25
|
+
require 'sensu-plugin/metric/cli'
|
26
|
+
require 'socket'
|
27
|
+
|
28
|
+
#
|
29
|
+
# CPU Graphite
|
30
|
+
#
|
31
|
+
class MetricsSoftnetStat < Sensu::Plugin::Metric::CLI::Graphite
|
32
|
+
option :scheme,
|
33
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
34
|
+
short: '-s SCHEME',
|
35
|
+
long: '--scheme SCHEME',
|
36
|
+
default: "#{Socket.gethostname}.softnet-stat"
|
37
|
+
|
38
|
+
option :proc_path,
|
39
|
+
long: '--proc-path /proc',
|
40
|
+
proc: proc(&:to_s),
|
41
|
+
default: '/proc'
|
42
|
+
|
43
|
+
def run
|
44
|
+
name_metrics = %w[processed dropped time_squeeze cpu_collision received_rps flow_limit_count]
|
45
|
+
|
46
|
+
File.open("#{config[:proc_path]}/net/softnet_stat", 'r').each_line.with_index do |line, cpu_index|
|
47
|
+
result = line.split(' ')
|
48
|
+
array = result[0..2] + result[-3..-1]
|
49
|
+
array.each_with_index do |value, index|
|
50
|
+
output "#{config[:scheme]}.CPU#{cpu_index}.#{name_metrics[index]}", value.to_i(16)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
ok
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module SensuPluginsCpuChecks
|
2
|
+
module CommonInterrupts
|
3
|
+
def build_regexp(line)
|
4
|
+
regexp_string = '[[:space:]]*(?<irq_number>.+):'
|
5
|
+
cpu_list = line.scan(/CPU\d+/)
|
6
|
+
cpu_list.each do |name|
|
7
|
+
regexp_string += "[[:space:]]*(?<#{name}>\\d+)"
|
8
|
+
end
|
9
|
+
regexp_string += '[[:space:]]*(?<irq_type>.*)'
|
10
|
+
[Regexp.new(regexp_string), cpu_list]
|
11
|
+
end
|
12
|
+
|
13
|
+
def output_metrics(filename)
|
14
|
+
regexp = nil
|
15
|
+
cpu_list = []
|
16
|
+
File.open("#{config[:proc_path]}/#{filename}", 'r').each_line.with_index do |line, index|
|
17
|
+
if index.zero?
|
18
|
+
regexp, cpu_list = build_regexp(line)
|
19
|
+
else
|
20
|
+
result = line.match(regexp)
|
21
|
+
if result
|
22
|
+
cpu_list.each do |name|
|
23
|
+
key = [config[:scheme], name, result[:irq_type].split.join('-'), result[:irq_number]].reject(&:empty?)
|
24
|
+
output key.join('.').to_s, result[name]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-cpu-checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.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-
|
11
|
+
date: 2018-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -171,10 +171,13 @@ description: |-
|
|
171
171
|
email: "<sensu-users@googlegroups.com>"
|
172
172
|
executables:
|
173
173
|
- check-cpu.rb
|
174
|
+
- metrics-cpu-interrupts.rb
|
174
175
|
- metrics-cpu-mpstat.rb
|
175
176
|
- metrics-cpu-pcnt-usage.rb
|
177
|
+
- metrics-cpu-softirqs.rb
|
176
178
|
- metrics-cpu.rb
|
177
179
|
- metrics-numastat.rb
|
180
|
+
- metrics-softnet-stat.rb
|
178
181
|
- metrics-user-pct-usage.rb
|
179
182
|
extensions: []
|
180
183
|
extra_rdoc_files: []
|
@@ -184,12 +187,16 @@ files:
|
|
184
187
|
- README.md
|
185
188
|
- bin/check-cpu.rb
|
186
189
|
- bin/check-cpu.sh
|
190
|
+
- bin/metrics-cpu-interrupts.rb
|
187
191
|
- bin/metrics-cpu-mpstat.rb
|
188
192
|
- bin/metrics-cpu-pcnt-usage.rb
|
193
|
+
- bin/metrics-cpu-softirqs.rb
|
189
194
|
- bin/metrics-cpu.rb
|
190
195
|
- bin/metrics-numastat.rb
|
196
|
+
- bin/metrics-softnet-stat.rb
|
191
197
|
- bin/metrics-user-pct-usage.rb
|
192
198
|
- lib/sensu-plugins-cpu-checks.rb
|
199
|
+
- lib/sensu-plugins-cpu-checks/common_interrupts.rb
|
193
200
|
- lib/sensu-plugins-cpu-checks/version.rb
|
194
201
|
homepage: https://github.com/sensu-plugins/sensu-plugins-cpu-checks
|
195
202
|
licenses:
|