sensu-plugins-cpu-checks 4.0.0 → 4.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 +14 -1
- data/README.md +167 -12
- data/bin/metrics-cpu-pcnt-usage.rb +3 -2
- data/bin/metrics-cpu.rb +1 -0
- data/bin/metrics-numastat.rb +4 -2
- data/lib/sensu-plugins-cpu-checks/version.rb +1 -1
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3de401f119f265175eadcd17be54da8bd9dbd2cb300ac2dd112a90d8207a27e0
|
4
|
+
data.tar.gz: e9ae22e6480f9a9aeb09583e84a1441e6083c5b05dd403b2ef08126bde211391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88985e2035917837efaca1a7118da0c1b4ee813fc95c7650b3953a48db2b54c6af646330f6e643584b0a8c1e146562107da20ad1a2e96569837bfe8aa6ad70fc
|
7
|
+
data.tar.gz: 9aedb47ab380f2aaa2a703f2cfd20b7eedeb579eda41d02d7c4fa8acb0df1625199c4b8c78be409039f2696c1002cfb57b10a8837ec8533a3bf5e000159a195d
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,18 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [4.1.0] - 2019-12-17
|
9
|
+
### Changed
|
10
|
+
- Updated linux-kstat runtime dependancy to "= 0.2.3"
|
11
|
+
- Updated bundler development depedency to '~> 2.1'
|
12
|
+
- Updated rubocop development dependency to '~> 0.77.0'
|
13
|
+
- Updated rake development dependancy to '~> 13.0'
|
14
|
+
- Updated codeclimate-test-reporter development dependancy to '~> 1.0'
|
15
|
+
- Updated README to conform with standardization guidelines (sensu-plugins/community#134)
|
16
|
+
|
17
|
+
### Added
|
18
|
+
- Updated asset build targets to support centos6
|
19
|
+
|
8
20
|
## [4.0.0] - 2019-04-18
|
9
21
|
### Breaking Changes
|
10
22
|
- Update minimum required ruby version to 2.3. Drop unsupported ruby versions.
|
@@ -102,7 +114,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
102
114
|
- initial release
|
103
115
|
|
104
116
|
|
105
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/4.
|
117
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/4.1.0...HEAD
|
118
|
+
[4.1.0]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/4.0.0...4.1.0
|
106
119
|
[4.0.0]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/3.0.0...4.0.0
|
107
120
|
[3.0.0]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/2.1.0...3.0.0
|
108
121
|
[2.1.0]: https://github.com/sensu-plugins/sensu-plugins-cpu-checks/compare/2.0.1...2.1.0
|
data/README.md
CHANGED
@@ -1,30 +1,185 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-cpu-checks)
|
3
2
|
[ ![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-cpu-checks.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-cpu-checks)
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-cpu-checks.svg)](http://badge.fury.io/rb/sensu-plugins-cpu-checks)
|
5
4
|
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-cpu-checks/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-cpu-checks)
|
6
5
|
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-cpu-checks/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-cpu-checks)
|
7
6
|
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-cpu-checks.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-cpu-checks)
|
8
|
-
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-cpu-checks)
|
9
7
|
|
10
|
-
## Sensu
|
11
|
-
|
8
|
+
## Sensu Plugins CPU Checks Plugin
|
9
|
+
|
10
|
+
- [Overview](#overview)
|
11
|
+
- [Files](#files)
|
12
|
+
- [Usage examples](#usage-examples)
|
13
|
+
- [Configuration](#configuration)
|
14
|
+
- [Sensu Go](#sensu-go)
|
15
|
+
- [Asset registration](#asset-registration)
|
16
|
+
- [Asset definition](#asset-definition)
|
17
|
+
- [Check definition](#check-definition)
|
18
|
+
- [Sensu Core](#sensu-core)
|
19
|
+
- [Check definition](#check-definition)
|
20
|
+
- [Installation from source](#installation-from-source)
|
21
|
+
- [Additional notes](#additional-notes)
|
22
|
+
- [Contributing](#contributing)
|
23
|
+
|
24
|
+
### Overview
|
12
25
|
|
13
|
-
|
26
|
+
This plugin provides native CPU instrumentation for monitoring and metrics collection, including CPU usage and metrics for user, nice, system, idle, iowait, irq, softirq, steal, and guest.
|
14
27
|
|
15
|
-
|
28
|
+
### Files
|
16
29
|
* bin/check-cpu.rb
|
17
|
-
* bin/
|
30
|
+
* bin/metrics-cpu-interrupts.rb
|
18
31
|
* bin/metrics-cpu-mpstat.rb
|
19
32
|
* bin/metrics-cpu-pcnt-usage.rb
|
33
|
+
* bin/metrics-cpu-softirqs.rb
|
34
|
+
* bin/metrics-cpu.rb
|
20
35
|
* bin/metrics-numastat.rb
|
36
|
+
* bin/metrics-softnet-stat.rb
|
21
37
|
* bin/metrics-user-pct-usage.rb
|
22
38
|
|
23
|
-
|
39
|
+
Added cpu interrupts, softirqs, softnet-stat 2 years ago
|
40
|
+
metrics-user-pct-usage.rb
|
41
|
+
|
42
|
+
**check-cpu**
|
43
|
+
Checks CPU usage.
|
44
|
+
|
45
|
+
**metrics-cpu-interrupts**
|
46
|
+
Provides metrics for CPU interrupts.
|
47
|
+
|
48
|
+
**metrics-cpu-mpstat**
|
49
|
+
Provides metrics for individual CPU and overall CPU usage.
|
50
|
+
|
51
|
+
**metrics-cpu-pcnt-usage**
|
52
|
+
Provides metrics for CPU percent usage.
|
53
|
+
|
54
|
+
**metrics-cpu-softirqs**
|
55
|
+
Provides metrics for CPU softirqs.
|
56
|
+
|
57
|
+
**metrics-cpu**
|
58
|
+
Provides CPU metrics.
|
59
|
+
|
60
|
+
**metrics-numastat**
|
61
|
+
Provides a simple wrapper around `numastat` for getting per-NUMA-node memory stats.
|
62
|
+
|
63
|
+
**metrics-softnet-stat**
|
64
|
+
Provides softnet stats.
|
65
|
+
|
66
|
+
**metrics-user-pct-usage**
|
67
|
+
Produces Graphite output of sum of %CPU over all processes by user. For example, if user Joe is running two processes, each using 10% CPU, and user Jane is running one process using 50% CPU, output will be:
|
68
|
+
|
69
|
+
* Joe 20.0 (timestamp)
|
70
|
+
* Jane 50.0 (timestamp)
|
71
|
+
|
72
|
+
## Usage examples
|
73
|
+
|
74
|
+
### Help
|
75
|
+
|
76
|
+
**check-cpu.rb**
|
77
|
+
```
|
78
|
+
Usage: check-cpu.rb (options)
|
79
|
+
--cache-file CACHEFILE
|
80
|
+
-c CRIT
|
81
|
+
--guest Check cpu guest instead of total cpu usage
|
82
|
+
--guest_nice Check cpu guest_nice instead of total cpu usage
|
83
|
+
--idle Check cpu idle instead of total cpu usage
|
84
|
+
--idle-metrics METRICS Treat the specified metrics as idle. Defaults to idle,iowait,steal,guest,guest_nice
|
85
|
+
--iowait Check cpu iowait instead of total cpu usage
|
86
|
+
--irq Check cpu irq instead of total cpu usage
|
87
|
+
-l, --less_than Change whether value is less than check
|
88
|
+
--nice Check cpu nice instead of total cpu usage
|
89
|
+
--proc-path /proc
|
90
|
+
--sleep SLEEP This sleep controls the interval between the initial poll for cpu utilization and the next data point, the longer the interval is the more accurate your data will be
|
91
|
+
--softirq Check cpu softirq instead of total cpu usage
|
92
|
+
--steal Check cpu steal instead of total cpu usage
|
93
|
+
--system Check cpu system instead of total cpu usage
|
94
|
+
--user Check cpu user instead of total cpu usage
|
95
|
+
-w WARN
|
96
|
+
```
|
97
|
+
|
98
|
+
**metrics-numastat.rb**
|
99
|
+
```
|
100
|
+
Usage: metrics-numastat.rb (options)
|
101
|
+
-s, --scheme SCHEME Metric naming scheme, text to prepend to metric
|
102
|
+
```
|
103
|
+
|
104
|
+
## Configuration
|
105
|
+
### Sensu Go
|
106
|
+
#### Asset registration
|
24
107
|
|
25
|
-
|
108
|
+
Assets are the best way to make use of this plugin. If you're not using an asset, please consider doing so! If you're using sensuctl 5.13 or later, you can use the following command to add the asset:
|
26
109
|
|
27
|
-
|
110
|
+
`sensuctl asset add sensu-plugins/sensu-plugins-cpu-checks`
|
111
|
+
|
112
|
+
If you're using an earlier version of sensuctl, you can download the asset definition from [this project's Bonsai asset index page](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-cpu-checks).
|
113
|
+
|
114
|
+
#### Asset definition
|
115
|
+
|
116
|
+
```yaml
|
117
|
+
---
|
118
|
+
type: Asset
|
119
|
+
api_version: core/v2
|
120
|
+
metadata:
|
121
|
+
name: sensu-plugins-cpu-checks
|
122
|
+
spec:
|
123
|
+
url: https://assets.bonsai.sensu.io/68546e739d96fd695655b77b35b5aabfbabeb056/sensu-plugins-cpu-checks_4.0.0_centos_linux_amd64.tar.gz
|
124
|
+
sha512: 518e7c17cf670393045bff4af318e1d35955bfde166e9ceec2b469109252f79043ed133241c4dc96501b6636a1ec5e008ea9ce055d1609865635d4f004d7187b
|
125
|
+
```
|
126
|
+
|
127
|
+
#### Check definition
|
128
|
+
|
129
|
+
```yaml
|
130
|
+
---
|
131
|
+
type: CheckConfig
|
132
|
+
spec:
|
133
|
+
command: "check-cpu.rb"
|
134
|
+
handlers: []
|
135
|
+
high_flap_threshold: 0
|
136
|
+
interval: 10
|
137
|
+
low_flap_threshold: 0
|
138
|
+
publish: true
|
139
|
+
runtime_assets:
|
140
|
+
- sensu-plugins/sensu-plugins-cpu-checks
|
141
|
+
- sensu/sensu-ruby-runtime
|
142
|
+
subscriptions:
|
143
|
+
- linux
|
144
|
+
```
|
145
|
+
|
146
|
+
### Sensu Core
|
147
|
+
|
148
|
+
#### Check definition
|
149
|
+
```json
|
150
|
+
{
|
151
|
+
"checks": {
|
152
|
+
"check-cpu": {
|
153
|
+
"command": "check-cpu.rb",
|
154
|
+
"subscribers": ["linux"],
|
155
|
+
"interval": 10,
|
156
|
+
"refresh": 10,
|
157
|
+
"handlers": ["influxdb"]
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
```
|
162
|
+
|
163
|
+
## Installation from source
|
164
|
+
|
165
|
+
### Sensu Go
|
166
|
+
|
167
|
+
See the instructions above for [asset registration](#asset-registration).
|
168
|
+
|
169
|
+
### Sensu Core
|
170
|
+
|
171
|
+
Install and setup plugins on [Sensu Core](https://docs.sensu.io/sensu-core/latest/installation/installing-plugins/).
|
172
|
+
|
173
|
+
## Additional notes
|
174
|
+
|
175
|
+
### Sensu Go Ruby Runtime Assets
|
176
|
+
|
177
|
+
The Sensu assets packaged from this repository are built against the Sensu Ruby runtime environment. When using these assets as part of a Sensu Go resource (check, mutator, or handler), make sure to include the corresponding [Sensu Ruby Runtime Asset](https://bonsai.sensu.io/assets/sensu/sensu-ruby-runtime) in the list of assets needed by the resource.
|
178
|
+
|
179
|
+
### Required `bc` utility
|
28
180
|
|
29
|
-
## Notes
|
30
181
|
The `check-cpu.sh` shell script in this repository requires the `bc` utility to be installed and available in the executable path. This shell script is not installed when using the Ruby gem or Sensu asset derived from this repository.
|
182
|
+
|
183
|
+
## Contributing
|
184
|
+
|
185
|
+
See [CONTRIBUTING.md](https://github.com/sensu-plugins/sensu-plugins-cpu-checks/blob/master/CONTRIBUTING.md) for information about contributing to this plugin.
|
@@ -45,6 +45,7 @@ class CpuGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
45
45
|
File.open("#{config[:proc_path]}/stat", 'r').each_line do |line|
|
46
46
|
info = line.split(/\s+/)
|
47
47
|
next if info.empty?
|
48
|
+
|
48
49
|
name = info.shift
|
49
50
|
|
50
51
|
# we are matching TOTAL stats and returning a hash of values
|
@@ -71,12 +72,12 @@ class CpuGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
71
72
|
cpu_total1 = sum_cpu_metrics(cpu_sample1)
|
72
73
|
cpu_total2 = sum_cpu_metrics(cpu_sample2)
|
73
74
|
# total cpu usage in last second in CPU jiffs (1/100 s)
|
74
|
-
cpu_total_diff
|
75
|
+
cpu_total_diff = cpu_total2 - cpu_total1
|
75
76
|
# per CPU metric diff
|
76
77
|
cpu_sample_diff = Hash[cpu_sample2.map { |k, v| [k, v - cpu_sample1[k]] }]
|
77
78
|
|
78
79
|
cpu_metrics.each do |metric|
|
79
|
-
metric_val = sprintf('
|
80
|
+
metric_val = sprintf('%<value>.02f', value: (cpu_sample_diff[metric] / cpu_total_diff.to_f) * 100)
|
80
81
|
output "#{config[:scheme]}.#{metric}", metric_val
|
81
82
|
end
|
82
83
|
ok
|
data/bin/metrics-cpu.rb
CHANGED
data/bin/metrics-numastat.rb
CHANGED
@@ -37,17 +37,19 @@ class NumastatMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
37
37
|
def run
|
38
38
|
begin
|
39
39
|
output = `/usr/bin/numastat`
|
40
|
-
rescue Errno::ENOENT =>
|
41
|
-
unknown
|
40
|
+
rescue Errno::ENOENT => e
|
41
|
+
unknown e
|
42
42
|
end
|
43
43
|
|
44
44
|
nodes = []
|
45
45
|
output.each_line do |line|
|
46
46
|
nodes = line.split(' ') if nodes.empty?
|
47
47
|
next unless /^([^\s]+)\s+(.+)$/ =~ line
|
48
|
+
|
48
49
|
key = Regexp.last_match[1]
|
49
50
|
vals = Regexp.last_match[2]
|
50
51
|
next if key.nil? || vals.nil?
|
52
|
+
|
51
53
|
nodes.zip(vals.split(' ')).each do |node, val|
|
52
54
|
output "#{config[:scheme]}.#{node}.#{key}", val
|
53
55
|
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: 4.
|
4
|
+
version: 4.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: 2019-
|
11
|
+
date: 2019-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -30,42 +30,42 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.2.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.2.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '2.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: codeclimate-test-reporter
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '1.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '1.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: github-markup
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '13.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '13.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: redcarpet
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
145
|
+
version: 0.77.0
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
152
|
+
version: 0.77.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: yard
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,15 +170,15 @@ description: |-
|
|
170
170
|
CPU usage and metrics
|
171
171
|
email: "<sensu-users@googlegroups.com>"
|
172
172
|
executables:
|
173
|
-
- metrics-cpu-mpstat.rb
|
174
|
-
- metrics-cpu.rb
|
175
173
|
- metrics-user-pct-usage.rb
|
174
|
+
- metrics-cpu-mpstat.rb
|
175
|
+
- metrics-numastat.rb
|
176
176
|
- metrics-cpu-pcnt-usage.rb
|
177
|
-
- metrics-cpu
|
177
|
+
- metrics-cpu.rb
|
178
178
|
- metrics-softnet-stat.rb
|
179
179
|
- metrics-cpu-interrupts.rb
|
180
180
|
- check-cpu.rb
|
181
|
-
- metrics-
|
181
|
+
- metrics-cpu-softirqs.rb
|
182
182
|
extensions: []
|
183
183
|
extra_rdoc_files: []
|
184
184
|
files:
|
@@ -223,7 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
- !ruby/object:Gem::Version
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
|
-
|
226
|
+
rubyforge_project:
|
227
|
+
rubygems_version: 2.7.7
|
227
228
|
signing_key:
|
228
229
|
specification_version: 4
|
229
230
|
summary: Sensu plugins for cpu checks and metrics
|