sensu-plugins-ipmi-sensors 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE +23 -0
- data/README.md +28 -0
- data/bin/check-ipmi-sensors.rb +177 -0
- data/lib/sensu-plugins-ipmi-sensors.rb +1 -0
- data/lib/sensu-plugins-ipmi-sensors/version.rb +9 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6cd50e5f6e1100f3316e5b8182704137a989d146
|
4
|
+
data.tar.gz: 3e96ff9b07019093aa6b3700482d6aef7474f742
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0d11309b9f857a456ab1275efd6758703feea73130ed5f43d3ab30a56492cfc35063756cfac2ffe379717d956420e6b0d515daa6e0eaf4a808f2e1e46c997fd7
|
7
|
+
data.tar.gz: 0fb17887d5f10c129338dfcfe49a5bb477713fad41ef6bcbabaf246746521eb6bfd192652d7dc7f8cb8dce3f7c8ce13f9cf2170e1e2ed071e4929a9bab90ba37
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2015 Matteo Cerutti
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Sensu plugin for monitoring IPMI sensors
|
2
|
+
|
3
|
+
A sensu plugin to monitor IPMI sensors.
|
4
|
+
|
5
|
+
The plugin generates multiple OK/WARN/CRIT/UNKNOWN events via the sensu client socket (https://sensuapp.org/docs/latest/clients#client-socket-input)
|
6
|
+
so that you do not miss state changes when monitoring multiple sensors.
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
The plugin accepts the following command line options:
|
11
|
+
|
12
|
+
```
|
13
|
+
Usage: check-ipmi-sensors.rb (options)
|
14
|
+
--driver <driver> IPMI driver (default: auto)
|
15
|
+
-H, --host <HOST> IPMI host (default: localhost)
|
16
|
+
--ignore-sensor <SENSOR> Comma separated list of IPMI sensors to ignore
|
17
|
+
--ignore-sensor-regex <SENSOR>
|
18
|
+
Comma separated list of IPMI sensors to ignore (regex)
|
19
|
+
-p, --password <PASSWORD> IPMI password (required)
|
20
|
+
--provider <PROVIDER> IPMI provider (default: auto)
|
21
|
+
--sensor <SENSOR> Comma separated list of IPMI sensors (default: ALL)
|
22
|
+
--sensor-regex <SENSOR> Comma separated list of IPMI sensors (regex)
|
23
|
+
-u, --user <USER> IPMI username (required)
|
24
|
+
-w, --warn Warn instead of throwing a critical failure
|
25
|
+
```
|
26
|
+
|
27
|
+
## Author
|
28
|
+
Matteo Cerutti - <matteo.cerutti@hotmail.co.uk>
|
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-ipmi-sensors.rb
|
4
|
+
#
|
5
|
+
# Author: Matteo Cerutti <matteo.cerutti@hotmail.co.uk>
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'sensu-plugin/check/cli'
|
9
|
+
require 'rubyipmi'
|
10
|
+
require 'json'
|
11
|
+
require 'socket'
|
12
|
+
|
13
|
+
class CheckIPMISensors < Sensu::Plugin::Check::CLI
|
14
|
+
option :user,
|
15
|
+
:description => "IPMI username",
|
16
|
+
:short => "-u <USER>",
|
17
|
+
:long => "--user <USER>",
|
18
|
+
:required => true
|
19
|
+
|
20
|
+
option :password,
|
21
|
+
:description => "IPMI password",
|
22
|
+
:short => "-p <PASSWORD>",
|
23
|
+
:long => "--password <PASSWORD>",
|
24
|
+
:required => true
|
25
|
+
|
26
|
+
option :host,
|
27
|
+
:description => "IPMI host (default: localhost)",
|
28
|
+
:short => "-H <HOST>",
|
29
|
+
:long => "--host <HOST>",
|
30
|
+
:default => "localhost"
|
31
|
+
|
32
|
+
option :provider,
|
33
|
+
:description => "IPMI provider (default: auto)",
|
34
|
+
:long => "--provider <PROVIDER>",
|
35
|
+
:in => ["any", "freeipmi", "openipmi"],
|
36
|
+
:default => "any"
|
37
|
+
|
38
|
+
option :driver,
|
39
|
+
:description => "IPMI driver (default: auto)",
|
40
|
+
:long => "--driver <driver>",
|
41
|
+
:in => ["auto", "lan15", "lan20", "open"],
|
42
|
+
:default => "auto"
|
43
|
+
|
44
|
+
option :sensor,
|
45
|
+
:description => "Comma separated list of IPMI sensors (default: ALL)",
|
46
|
+
:long => "--sensor <SENSOR>",
|
47
|
+
:proc => proc { |a| a.split(',') },
|
48
|
+
:default => []
|
49
|
+
|
50
|
+
option :sensor_regex,
|
51
|
+
:description => "Comma separated list of IPMI sensors (regex)",
|
52
|
+
:long => "--sensor-regex <SENSOR>",
|
53
|
+
:proc => proc { |a| a.split(',') },
|
54
|
+
:default => []
|
55
|
+
|
56
|
+
option :ignore_sensor,
|
57
|
+
:description => "Comma separated list of IPMI sensors to ignore",
|
58
|
+
:long => "--ignore-sensor <SENSOR>",
|
59
|
+
:proc => proc { |a| a.split(',') },
|
60
|
+
:default => []
|
61
|
+
|
62
|
+
option :ignore_sensor_regex,
|
63
|
+
:description => "Comma separated list of IPMI sensors to ignore (regex)",
|
64
|
+
:long => "--ignore-sensor-regex <SENSOR>",
|
65
|
+
:proc => proc { |a| a.split(',') },
|
66
|
+
:default => []
|
67
|
+
|
68
|
+
option :warn,
|
69
|
+
:description => "Warn instead of throwing a critical failure",
|
70
|
+
:short => "-w",
|
71
|
+
:long => "--warn",
|
72
|
+
:boolean => false
|
73
|
+
|
74
|
+
def initialize()
|
75
|
+
super
|
76
|
+
@ipmi = Rubyipmi.connect(config[:user], config[:password], config[:host], config[:provider], {:driver => config[:driver]})
|
77
|
+
end
|
78
|
+
|
79
|
+
def send_client_socket(data)
|
80
|
+
sock = UDPSocket.new
|
81
|
+
sock.send(data + "\n", 0, "127.0.0.1", 3030)
|
82
|
+
end
|
83
|
+
|
84
|
+
def send_ok(check_name, msg)
|
85
|
+
event = {"name" => check_name, "status" => 0, "output" => "OK: #{msg}", "handler" => config[:handler]}
|
86
|
+
send_client_socket(event.to_json)
|
87
|
+
end
|
88
|
+
|
89
|
+
def send_warning(check_name, msg)
|
90
|
+
event = {"name" => check_name, "status" => 1, "output" => "WARNING: #{msg}", "handler" => config[:handler]}
|
91
|
+
send_client_socket(event.to_json)
|
92
|
+
end
|
93
|
+
|
94
|
+
def send_critical(check_name, msg)
|
95
|
+
event = {"name" => check_name, "status" => 2, "output" => "CRITICAL: #{msg}", "handler" => config[:handler]}
|
96
|
+
send_client_socket(event.to_json)
|
97
|
+
end
|
98
|
+
|
99
|
+
def send_unknown(check_name, msg)
|
100
|
+
event = {"name" => check_name, "status" => 3, "output" => "UNKNOWN: #{msg}", "handler" => config[:handler]}
|
101
|
+
send_client_socket(event.to_json)
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_ipmi_sensors()
|
105
|
+
sensors = {}
|
106
|
+
|
107
|
+
@ipmi.sensors.list.each do |name, sensor|
|
108
|
+
if config[:ignore_sensor].size > 0
|
109
|
+
next if config[:ignore_sensor].include?(name)
|
110
|
+
end
|
111
|
+
|
112
|
+
if config[:ignore_sensor_regex].size > 0
|
113
|
+
b = false
|
114
|
+
config[:ignore_sensor_regex].each do |sensor|
|
115
|
+
if name =~ Regexp.new(sensor)
|
116
|
+
b = true
|
117
|
+
break
|
118
|
+
end
|
119
|
+
end
|
120
|
+
next if b
|
121
|
+
end
|
122
|
+
|
123
|
+
if config[:sensor].size > 0
|
124
|
+
next unless config[:sensor].include?(name)
|
125
|
+
end
|
126
|
+
|
127
|
+
if config[:sensor_regex].size > 0
|
128
|
+
b = true
|
129
|
+
config[:sensor_regex].each do |sensor|
|
130
|
+
if name =~ Regexp.new(sensor)
|
131
|
+
b = false
|
132
|
+
break
|
133
|
+
end
|
134
|
+
end
|
135
|
+
next if b
|
136
|
+
end
|
137
|
+
|
138
|
+
sensors[name] = sensor
|
139
|
+
end
|
140
|
+
|
141
|
+
sensors
|
142
|
+
end
|
143
|
+
|
144
|
+
def run
|
145
|
+
problems = 0
|
146
|
+
|
147
|
+
ipmi_sensors = get_ipmi_sensors()
|
148
|
+
ipmi_sensors.each do |name, sensor|
|
149
|
+
check_name = "ipmi-sensor-#{name}"
|
150
|
+
case sensor[:unit].downcase
|
151
|
+
when "n/a", "nominal"
|
152
|
+
# life's good
|
153
|
+
next
|
154
|
+
|
155
|
+
when "warning"
|
156
|
+
send_critical(check_name, "IPMI sensor #{name} is not healthy (State: #{sensor[:state]})")
|
157
|
+
problems += 1
|
158
|
+
|
159
|
+
when "critical"
|
160
|
+
send_critical(check_name, "IPMI sensor #{name} is not healthy (State: #{sensor[:state]})")
|
161
|
+
problems += 1
|
162
|
+
|
163
|
+
else
|
164
|
+
send_ok(check_name, "IPMI sensor #{name} is healthy (State: #{sensor[:state]})")
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
if problems > 0
|
170
|
+
message "Found #{problems} problems"
|
171
|
+
warning if config[:warn]
|
172
|
+
critical
|
173
|
+
else
|
174
|
+
ok "All IPMI sensors (#{ipmi_sensors.keys.join(', ')}) are OK"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'sensu-plugins-ipmi-sensors/version'
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-ipmi-sensors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matteo Cerutti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sensu-plugin
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubyipmi
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.10.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.10.0
|
41
|
+
description: This plugin provides facilities for monitoring IPMI sensors
|
42
|
+
email: "<matteo.cerutti@hotmail.co.uk>"
|
43
|
+
executables:
|
44
|
+
- check-ipmi-sensors.rb
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- CHANGELOG.md
|
49
|
+
- LICENSE
|
50
|
+
- README.md
|
51
|
+
- bin/check-ipmi-sensors.rb
|
52
|
+
- lib/sensu-plugins-ipmi-sensors.rb
|
53
|
+
- lib/sensu-plugins-ipmi-sensors/version.rb
|
54
|
+
homepage: https://github.com/m4ce/sensu-plugins-ipmi-sensors
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata:
|
58
|
+
maintainer: "@m4ce"
|
59
|
+
development_status: active
|
60
|
+
production_status: stable
|
61
|
+
release_draft: 'false'
|
62
|
+
release_prerelease: 'false'
|
63
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
64
|
+
in /etc/default/sensu
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.9.3
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.4.5.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Sensu plugins for monitoring IPMI sensors
|
84
|
+
test_files: []
|