sensu-plugins-environmental-checks 1.0.0 → 1.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 +5 -1
- data/README.md +6 -0
- data/bin/check-temperature.rb +88 -0
- data/lib/sensu-plugins-environmental-checks/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8daf34425dcb66a605ba5a480d3e8b761f2e1c76
|
4
|
+
data.tar.gz: 44c120575ecfe122db0e580d467021509d5ffb19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8156bf488b89a740124a320304550074ca1dbaf6d5f316774780700180bcafceadb8dbb7745d8815dad351f4dd392f210d3fafc960b923b0820bb0a33f3d9974
|
7
|
+
data.tar.gz: 36f19f586fd14cc8f77eaadbcf159d1836b530303d614287ffd5f33b22cb2aef699a7edcd67ffe0c40550631e406ed3a38780ffefab0628d3d9aac2e40a81e86
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,9 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [1.1.0] - 2017-05-17
|
9
|
+
- add temperature check (@holygits)
|
10
|
+
|
8
11
|
## [1.0.0] - 2017-03-15
|
9
12
|
### Added
|
10
13
|
- made metrics aware of multiple chips (@GhostLyrics)
|
@@ -33,7 +36,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
33
36
|
### Added
|
34
37
|
- initial release
|
35
38
|
|
36
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-environmental-checks/compare/1.
|
39
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-environmental-checks/compare/1.1.0...HEAD
|
40
|
+
[1.1.0]: https://github.com/sensu-plugins/sensu-plugins-environmental-checks/compare/1.0.0...1.1.0
|
37
41
|
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-environmental-checks/compare/0.0.3...1.0.0
|
38
42
|
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-environmental-checks/compare/0.0.2...0.0.3
|
39
43
|
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-environmental-checks/compare/0.0.1...0.0.2
|
data/README.md
CHANGED
@@ -27,6 +27,12 @@ Multiple chips are supported and labelled by the chip name (e.g. `sensors.corete
|
|
27
27
|
|
28
28
|
*If you do not get all of the listed values, your mainboard probably does not support the features. To check, you can query it yourself by running* `sensors` *or* `sensors -A` *respectively.*
|
29
29
|
|
30
|
+
### check-temperature.rb
|
31
|
+
|
32
|
+
#### checks
|
33
|
+
|
34
|
+
Maps *high* and *crit* values as reported by `lm-sensors` to warning and critical status respectivley.
|
35
|
+
|
30
36
|
## Usage
|
31
37
|
|
32
38
|
To collect metrics with the scheme of your choice:
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-temperature
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
#
|
7
|
+
# OUTPUT:
|
8
|
+
# plain text
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-plugin
|
15
|
+
# gem: socket
|
16
|
+
# lm-sensors
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
# NOTES:
|
21
|
+
#
|
22
|
+
# LICENSE:
|
23
|
+
# Jordan Beauchamp beauchjord@gmail.com
|
24
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
25
|
+
# for details.
|
26
|
+
#
|
27
|
+
|
28
|
+
require 'sensu-plugin/check/cli'
|
29
|
+
require 'socket'
|
30
|
+
|
31
|
+
#
|
32
|
+
# Sensors
|
33
|
+
#
|
34
|
+
class CheckTemperature < Sensu::Plugin::Check::CLI
|
35
|
+
#
|
36
|
+
# Setup variables
|
37
|
+
#
|
38
|
+
def initialize
|
39
|
+
super
|
40
|
+
@crit_temp = []
|
41
|
+
@warn_temp = []
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Generate output
|
46
|
+
#
|
47
|
+
|
48
|
+
def usage_summary
|
49
|
+
(@crit_temp + @warn_temp).join(', ')
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Main function
|
54
|
+
#
|
55
|
+
def run
|
56
|
+
raw = `sensors`
|
57
|
+
sections = raw.split("\n\n")
|
58
|
+
metrics = {}
|
59
|
+
sections.each do |section|
|
60
|
+
section.split("\n").drop(1).each do |line|
|
61
|
+
begin
|
62
|
+
key, value = line.split(':')
|
63
|
+
key = key.downcase.gsub(/\s/, '')
|
64
|
+
if key.start_with?('temp', 'core', 'loc', 'physical')
|
65
|
+
current, high, critical = value.scan(/\+(\d+\.\d+)/i)
|
66
|
+
metrics[key] = [current[0], high[0], critical[0]].map(&:to_f)
|
67
|
+
end
|
68
|
+
rescue
|
69
|
+
print "malformed section from sensors: #{line}" + "\n"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
metrics.each do |k, v|
|
74
|
+
print(v)
|
75
|
+
current, high, critical = v
|
76
|
+
if current > critical
|
77
|
+
@crit_temp << "#{k} has exceeded CRITICAL temperature @ #{current}°C"
|
78
|
+
elsif current > high
|
79
|
+
@warn_temp << "#{k} has exceeded WARNING temperature @ #{current}°C"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
critical usage_summary unless @crit_temp.empty?
|
84
|
+
warning usage_summary unless @warn_temp.empty?
|
85
|
+
|
86
|
+
ok 'All sensors are reporting safe temperature readings.'
|
87
|
+
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-environmental-checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.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: 2017-
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -155,6 +155,7 @@ description: |-
|
|
155
155
|
for metrics collection, including: temperature via `sensors`
|
156
156
|
email: "<sensu-users@googlegroups.com>"
|
157
157
|
executables:
|
158
|
+
- check-temperature.rb
|
158
159
|
- metrics-temperature.rb
|
159
160
|
extensions: []
|
160
161
|
extra_rdoc_files: []
|
@@ -162,6 +163,7 @@ files:
|
|
162
163
|
- CHANGELOG.md
|
163
164
|
- LICENSE
|
164
165
|
- README.md
|
166
|
+
- bin/check-temperature.rb
|
165
167
|
- bin/metrics-temperature.rb
|
166
168
|
- lib/sensu-plugins-environmental-checks.rb
|
167
169
|
- lib/sensu-plugins-environmental-checks/version.rb
|