sensu-plugins-megaraid 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 +20 -0
- data/bin/check-megaraid.rb +175 -0
- data/lib/sensu-plugins-megaraid/version.rb +9 -0
- data/lib/sensu-plugins-megaraid.rb +1 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0a2aca836c719a463ae6b59783cdc77a35bba8be
|
4
|
+
data.tar.gz: a06474ccb89ca1156de1a036a951b6b0d155c201
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63c62e3eed4394577d6f77e8ba8617865a06c19e6d81431892dbf821d54a62abd76e02e864601d62737a60a712b0601f8363579e4c9ad0394741cc1725ca01c1
|
7
|
+
data.tar.gz: 10b616dc2f4d25b469ba332137b932b029e26b20cdba196221d77c0bb0d5e1f6a85de6d17f8b4bab8b4df1fef79cfe821c260363b1c53321dda36e4f422461bb
|
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,20 @@
|
|
1
|
+
# Sensu plugin for monitoring LSI MegaRAID devices
|
2
|
+
|
3
|
+
A sensu plugin to monitor LSI MegaRAID devices.
|
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 controllers, enclosures, virtual disks etc.
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
The plugin accepts the following command line options:
|
11
|
+
|
12
|
+
```
|
13
|
+
Usage: check-megaraid.rb (options)
|
14
|
+
-C, --controller-id <ID> Comma separated list of Controller ID(s) (default: all)
|
15
|
+
-c, --storcli-cmd <PATH> Path to StorCLI executable (default: /opt/MegaRAID/storcli/storcli64)
|
16
|
+
-w, --warn Warn instead of throwing a critical failure
|
17
|
+
```
|
18
|
+
|
19
|
+
## Author
|
20
|
+
Matteo Cerutti - <matteo.cerutti@hotmail.co.uk>
|
@@ -0,0 +1,175 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-megaraid.rb
|
4
|
+
#
|
5
|
+
# Author: Matteo Cerutti <matteo.cerutti@hotmail.co.uk>
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'sensu-plugin/check/cli'
|
9
|
+
require 'json'
|
10
|
+
require 'socket'
|
11
|
+
|
12
|
+
class CheckMegaRAID < Sensu::Plugin::Check::CLI
|
13
|
+
option :storcli_cmd,
|
14
|
+
:description => "Path to StorCLI executable (default: /opt/MegaRAID/storcli/storcli64)",
|
15
|
+
:short => "-c <PATH>",
|
16
|
+
:long => "--storcli-cmd <PATH>",
|
17
|
+
:default => "/opt/MegaRAID/storcli/storcli64"
|
18
|
+
|
19
|
+
option :controller_id,
|
20
|
+
:description => "Comma separated list of Controller ID(s) (default: all)",
|
21
|
+
:short => "-C <ID>",
|
22
|
+
:long => "--controller-id <ID>",
|
23
|
+
:proc => proc { |a| a.split(',') },
|
24
|
+
:default => []
|
25
|
+
|
26
|
+
option :warn,
|
27
|
+
:description => "Warn instead of throwing a critical failure",
|
28
|
+
:short => "-w",
|
29
|
+
:long => "--warn",
|
30
|
+
:boolean => false
|
31
|
+
|
32
|
+
def initialize()
|
33
|
+
super
|
34
|
+
|
35
|
+
if config[:controller_id].length > 0
|
36
|
+
controller_id = config[:controller_id]
|
37
|
+
else
|
38
|
+
controller_id = get_controllers()
|
39
|
+
end
|
40
|
+
|
41
|
+
# populate each controller
|
42
|
+
controllers = {}
|
43
|
+
|
44
|
+
controller_id.each do |cid|
|
45
|
+
cdata = JSON.parse(%x[#{config[:storcli_cmd]} /c#{cid} show all J].chomp)
|
46
|
+
edata = JSON.parse(%x[#{config[:storcli_cmd]} /c#{cid}/eall show J].chomp)
|
47
|
+
|
48
|
+
controllers[cid] = {}
|
49
|
+
controllers[cid]['status'] = cdata['Controllers'][0]['Response Data']['Status']
|
50
|
+
controllers[cid]['virtualdisks'] = cdata['Controllers'][0]['Response Data']['VD LIST']
|
51
|
+
controllers[cid]['physicaldisks'] = cdata['Controllers'][0]['Response Data']['PD LIST']
|
52
|
+
controllers[cid]['battery'] = cdata['Controllers'][0]['Response Data']['BBU_Info']
|
53
|
+
controllers[cid]['enclosures'] = edata['Controllers'][0]['Response Data']['Properties']
|
54
|
+
end
|
55
|
+
|
56
|
+
@controllers = controllers
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_controllers()
|
60
|
+
data = JSON.parse(%x[#{config[:storcli_cmd]} show J].chomp)
|
61
|
+
data['Controllers'][0]['Response Data']['System Overview'].map { |i| i['Ctl'] }
|
62
|
+
end
|
63
|
+
|
64
|
+
def send_client_socket(data)
|
65
|
+
sock = UDPSocket.new
|
66
|
+
sock.send(data + "\n", 0, "127.0.0.1", 3030)
|
67
|
+
end
|
68
|
+
|
69
|
+
def send_ok(check_name, msg)
|
70
|
+
event = {"name" => check_name, "status" => 0, "output" => "OK: #{msg}", "handler" => config[:handler]}
|
71
|
+
send_client_socket(event.to_json)
|
72
|
+
end
|
73
|
+
|
74
|
+
def send_warning(check_name, msg)
|
75
|
+
event = {"name" => check_name, "status" => 1, "output" => "WARNING: #{msg}", "handler" => config[:handler]}
|
76
|
+
send_client_socket(event.to_json)
|
77
|
+
end
|
78
|
+
|
79
|
+
def send_critical(check_name, msg)
|
80
|
+
event = {"name" => check_name, "status" => 2, "output" => "CRITICAL: #{msg}", "handler" => config[:handler]}
|
81
|
+
send_client_socket(event.to_json)
|
82
|
+
end
|
83
|
+
|
84
|
+
def send_unknown(check_name, msg)
|
85
|
+
event = {"name" => check_name, "status" => 3, "output" => "UNKNOWN: #{msg}", "handler" => config[:handler]}
|
86
|
+
send_client_socket(event.to_json)
|
87
|
+
end
|
88
|
+
|
89
|
+
def run
|
90
|
+
problems = 0
|
91
|
+
|
92
|
+
@controllers.each do |id, controller|
|
93
|
+
check_name = "megaraid-ctl_#{id}-status"
|
94
|
+
if controller['status']['Controller Status'].downcase != "optimal"
|
95
|
+
msg = "Controller #{id} in not healthy (Status: #{controller['status']['Controller Status']})"
|
96
|
+
if config[:warn]
|
97
|
+
send_warning(check_name, msg)
|
98
|
+
else
|
99
|
+
send_critical(check_name, msg)
|
100
|
+
end
|
101
|
+
problems += 1
|
102
|
+
else
|
103
|
+
send_ok(check_name, "Controller #{id} is healthy")
|
104
|
+
end
|
105
|
+
|
106
|
+
controller['virtualdisks'].each do |vd|
|
107
|
+
check_name = "megaraid-ctl_#{id}-vd_#{vd['DG/VD']}-state"
|
108
|
+
if vd['State'].downcase != "optl"
|
109
|
+
msg = "Controller #{id} VD #{vd['DG/VD']} is not healthy (Status: #{vd['State']})"
|
110
|
+
if config[:warn]
|
111
|
+
send_warning(check_name, msg)
|
112
|
+
else
|
113
|
+
send_critical(check_name, msg)
|
114
|
+
end
|
115
|
+
problems += 1
|
116
|
+
else
|
117
|
+
send_ok(check_name, "Controller #{id} VD #{vd['DG/VD']} is healthy")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
controller['physicaldisks'].each do |pd|
|
122
|
+
check_name = "megaraid-ctl_#{id}-pd_#{pd['EID:Slt']}-state"
|
123
|
+
if pd['State'].downcase != "onln"
|
124
|
+
msg = "Controller #{id} PD #{pd['EID:Slt']} is not healthy (Status: #{pd['State']})"
|
125
|
+
if config[:warn]
|
126
|
+
send_warning(check_name, msg)
|
127
|
+
else
|
128
|
+
send_critical(check_name, msg)
|
129
|
+
end
|
130
|
+
problems += 1
|
131
|
+
else
|
132
|
+
send_ok(check_name, "Controller #{id} PD #{pd['EID:Slt']} is healthy")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
controller['enclosures'].each do |enc|
|
137
|
+
check_name = "megaraid-ctl_#{id}-enc_#{enc['EID']}-state"
|
138
|
+
if enc['State'].downcase != "OK"
|
139
|
+
msg = "Controller #{id} enclosure #{enc['EID']} is not healthy (Status: #{enc['State']})"
|
140
|
+
if config[:warn]
|
141
|
+
send_warning(check_name, msg)
|
142
|
+
else
|
143
|
+
send_critical(check_name, msg)
|
144
|
+
end
|
145
|
+
problems += 1
|
146
|
+
else
|
147
|
+
send_ok(check_name, "Controller #{id} enclosure #{enc['EID']} is healthy")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
controller['battery'].each do |bbu|
|
152
|
+
check_name = "megaraid-ctl_#{id}-bbu_#{bbu['EID']}-state"
|
153
|
+
if bbu['State'].downcase != "optimal"
|
154
|
+
msg = "Controller #{id} BBU #{bbu['Model']} is not healthy (Status: #{bbu['State']})"
|
155
|
+
if config[:warn]
|
156
|
+
send_warning(check_name, msg)
|
157
|
+
else
|
158
|
+
send_critical(check_name, msg)
|
159
|
+
end
|
160
|
+
problems += 1
|
161
|
+
else
|
162
|
+
send_ok(check_name, "Controller #{id} BBU #{bbu['Model']} is healthy")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
if problems > 0
|
168
|
+
message "Found #{problems} problems"
|
169
|
+
warning if config[:warn]
|
170
|
+
critical
|
171
|
+
else
|
172
|
+
ok "All controllers (#{@controllers.join(', ')}) are healthy"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'sensu-plugins-megaraid/version'
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-megaraid
|
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-28 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
|
+
description: This plugin provides facilities for monitoring LSI MegaRAID devices
|
28
|
+
email: "<matteo.cerutti@hotmail.co.uk>"
|
29
|
+
executables:
|
30
|
+
- check-megaraid.rb
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- CHANGELOG.md
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- bin/check-megaraid.rb
|
38
|
+
- lib/sensu-plugins-megaraid.rb
|
39
|
+
- lib/sensu-plugins-megaraid/version.rb
|
40
|
+
homepage: https://github.com/m4ce/sensu-plugins-megaraid
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata:
|
44
|
+
maintainer: "@m4ce"
|
45
|
+
development_status: active
|
46
|
+
production_status: stable
|
47
|
+
release_draft: 'false'
|
48
|
+
release_prerelease: 'false'
|
49
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
50
|
+
in /etc/default/sensu
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.9.3
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.4.5.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Sensu plugins for monitoring LSI MegaRAID devices
|
70
|
+
test_files: []
|