sensu-plugins-raid-checks 0.0.1.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +20 -0
- data/LICENSE +22 -0
- data/README.md +41 -0
- data/bin/check-3ware-status.rb +137 -0
- data/bin/check-megaraid-sas-status.rb +70 -0
- data/bin/check-raid.rb +136 -0
- data/bin/check-smart-array-status.rb +125 -0
- data/lib/sensu-plugins-raid-checks.rb +7 -0
- metadata +204 -0
- metadata.gz.sig +4 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6675b3ea6701485842c1987987f995a3ffb03bfc
|
4
|
+
data.tar.gz: 45df531fd24cd8741f20ebd3fcb3faeb4129f0e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c207af3d091e37897e34744d162bf19da2628c197e890a78f3aa5857a49e3ef248777abde2de5564d7d39fa8abe19585fdd852e8ebabcc55f9868b4ff2844ff8
|
7
|
+
data.tar.gz: 2da67b5f76ed7b584e7cc39f0741dba779217be351cc1923bb539921743d6b428858826850d97be584d7740e349fe89af69c8dc67528c0c05bd16f3f3ae18e02
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#### 0.0.1-alpha.1
|
2
|
+
|
3
|
+
* baseline release identical to **sensu-community-plugins** repo
|
4
|
+
* change name of check-megaraid_sas-status.rb to check-megaraid-sas-status.rb
|
5
|
+
* change name of check-smartarray-status.rb to check-smart-array-status.rb
|
6
|
+
* basic yard coverage
|
7
|
+
* pinned dependencies
|
8
|
+
* built against 1.9.3, 2.0, 2.1
|
9
|
+
* cryptographically signed
|
10
|
+
|
11
|
+
#### 0.0.1-alpha.2
|
12
|
+
|
13
|
+
* bump Vagrant box to Cent 6.6
|
14
|
+
* removed git dependence in gemspec
|
15
|
+
* remove contributing.md from gem build
|
16
|
+
* updated gem author and licence info
|
17
|
+
* updated contributing.ms to reflect new documentation style
|
18
|
+
* updated yard documentation
|
19
|
+
* added test/spec_helper.rb
|
20
|
+
* change gem name to sensu-plugins-raid-checksß
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 devops@yieldbot.com
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
## Sensu-Plugins-raid-checks-Checks
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-raid-checks.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-raid-checks)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-raid-checks.svg)](http://badge.fury.io/rb/sensu-plugins-raid-checks)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-raid-checks/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-raid-checks)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-raid-checks/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-raid-checks)
|
7
|
+
|
8
|
+
## Functionality
|
9
|
+
|
10
|
+
**check-3ware-status.rb**
|
11
|
+
|
12
|
+
**check-megaraid-sas-status.rb**
|
13
|
+
|
14
|
+
**check-raid-checks**
|
15
|
+
|
16
|
+
**check-smart-array-status.rb**
|
17
|
+
|
18
|
+
## Files
|
19
|
+
|
20
|
+
* bin/check-3ware-status.rb
|
21
|
+
* bin/check-megaraid-sas-status.rb
|
22
|
+
* bin/check-raid-checks
|
23
|
+
* bin/check-smart-array-status.rb
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
|
28
|
+
Add the public key (if you haven’t already) as a trusted certificate
|
29
|
+
|
30
|
+
```
|
31
|
+
gem cert --add <(curl -Ls https://raw.githubusercontent.com/sensu-plugins/sensu-plugins.github.io/master/certs/sensu-plugins.pem)
|
32
|
+
gem install <gem> -P MediumSecurity
|
33
|
+
```
|
34
|
+
|
35
|
+
You can also download the key from /certs/ within each repository.
|
36
|
+
|
37
|
+
`gem install sensu-plugins-raid-checks`
|
38
|
+
|
39
|
+
Add *sensu-plugins-raid-checks* to your Gemfile, manifest, cookbook, etc
|
40
|
+
|
41
|
+
## Notes
|
@@ -0,0 +1,137 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-raid
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Check 3ware Status Plugin
|
7
|
+
#
|
8
|
+
# MegaCli/MegaCli64 requires root access
|
9
|
+
#
|
10
|
+
# OUTPUT:
|
11
|
+
# plain text
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: sensu-plugin
|
18
|
+
# gem: english
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
# Checks status for all HDDs in all 3ware controllers.
|
24
|
+
#
|
25
|
+
# tw-cli requires root permissions.
|
26
|
+
#
|
27
|
+
# Create a file named /etc/sudoers.d/tw-cli with this line inside :
|
28
|
+
# sensu ALL=(ALL) NOPASSWD: /usr/sbin/tw-cli
|
29
|
+
#
|
30
|
+
# You can get Debian/Ubuntu tw-cli packages here - http://hwraid.le-vert.net/
|
31
|
+
#
|
32
|
+
# LICENSE:
|
33
|
+
# Copyright 2014 Alexander Bulimov <lazywolf0@gmail.com>
|
34
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE for details.
|
35
|
+
#
|
36
|
+
|
37
|
+
require 'sensu-plugin/check/cli'
|
38
|
+
require 'open3'
|
39
|
+
|
40
|
+
#
|
41
|
+
# Check 3ware Status
|
42
|
+
#
|
43
|
+
class Check3wareStatus < Sensu::Plugin::Check::CLI
|
44
|
+
# Setup variables
|
45
|
+
#
|
46
|
+
def initialize
|
47
|
+
super
|
48
|
+
@binary = 'sudo -n -k tw-cli'
|
49
|
+
@controllers = []
|
50
|
+
@good_disks = []
|
51
|
+
@bad_disks = []
|
52
|
+
end
|
53
|
+
|
54
|
+
# Execute a specific command to acquire the exit code
|
55
|
+
# stderr, and raw data
|
56
|
+
#
|
57
|
+
# @param [String] command to run
|
58
|
+
#
|
59
|
+
def execute(cmd)
|
60
|
+
captured_stdout = ''
|
61
|
+
captured_stderr = ''
|
62
|
+
exit_status = Open3.popen3(ENV, cmd) do |stdin, stdout, stderr, wait_thr|
|
63
|
+
stdin.close
|
64
|
+
captured_stdout = stdout.read
|
65
|
+
captured_stderr = stderr.read
|
66
|
+
wait_thr.value
|
67
|
+
end
|
68
|
+
[exit_status, captured_stdout, captured_stderr]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Parse controller data
|
72
|
+
#
|
73
|
+
# @param data [String]
|
74
|
+
#
|
75
|
+
def parse_controllers!(data)
|
76
|
+
data.lines.each do |line|
|
77
|
+
unless line.empty?
|
78
|
+
controller = line.split[0]
|
79
|
+
@controllers << controller if /^c[0-9]+$/ =~ controller
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Parse disk data
|
85
|
+
#
|
86
|
+
# @param data [String]
|
87
|
+
# @param controller [String]
|
88
|
+
#
|
89
|
+
def parse_disks!(data, controller)
|
90
|
+
# #YELLOW
|
91
|
+
data.lines.each do |line| # rubocop:disable Style/Next
|
92
|
+
unless line.empty?
|
93
|
+
splitted = line.split
|
94
|
+
if /^[p][0-9]+$/ =~ splitted[0]
|
95
|
+
# '-' means the drive doesn't belong to any array
|
96
|
+
# If is NOT PRESENT too, it just means this is an empty port
|
97
|
+
status = splitted[1]
|
98
|
+
name = splitted[0]
|
99
|
+
unit = splitted[2]
|
100
|
+
if unit != '-' && unit != 'NOT-PRESENT'
|
101
|
+
# #YELLOW
|
102
|
+
if status == 'OK' # rubocop:disable BlockNesting
|
103
|
+
@good_disks << controller + unit + name + ': ' + status
|
104
|
+
else
|
105
|
+
@bad_disks << controller + unit + name + ': ' + status
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Main function
|
114
|
+
#
|
115
|
+
def run
|
116
|
+
exit_status, raw_data, err = execute "#{@binary} info"
|
117
|
+
unknown "tw-cli command failed - #{err}" unless exit_status.success?
|
118
|
+
parse_controllers! raw_data
|
119
|
+
|
120
|
+
@controllers.each do |controller|
|
121
|
+
exit_status, raw_data, err = execute "#{@binary} info #{controller}"
|
122
|
+
unknown "tw-cli command failed - #{err}" unless exit_status.success?
|
123
|
+
parse_disks! raw_data, controller
|
124
|
+
end
|
125
|
+
|
126
|
+
if @bad_disks.empty?
|
127
|
+
data = @good_disks.length
|
128
|
+
ok "All #{data} found disks are OK"
|
129
|
+
else
|
130
|
+
data = @bad_disks.join(', ')
|
131
|
+
bad_count = @bad_disks.length
|
132
|
+
good_count = @good_disks.length
|
133
|
+
total_count = bad_count + good_count
|
134
|
+
critical "#{bad_count} of #{total_count} disks are in bad state - #{data}"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-raid
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Checks the status of all virtual drives of a particular controller
|
7
|
+
#
|
8
|
+
# MegaCli/MegaCli64 requires root access
|
9
|
+
#
|
10
|
+
# OUTPUT:
|
11
|
+
# plain text
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: sensu-plugin
|
18
|
+
# gem: english
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright 2014 Magnus Hagdorn <magnus.hagdorn@ed.ac.uk>
|
26
|
+
# The University of Edinburgh
|
27
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'sensu-plugin/check/cli'
|
31
|
+
require 'English'
|
32
|
+
#
|
33
|
+
# Check MegaRAID
|
34
|
+
#
|
35
|
+
class CheckMegraRAID < Sensu::Plugin::Check::CLI
|
36
|
+
option :megaraidcmd,
|
37
|
+
description: 'the MegaCli executable',
|
38
|
+
short: '-c CMD',
|
39
|
+
long: '--command CMD',
|
40
|
+
default: '/opt/MegaRAID/MegaCli/MegaCli64'
|
41
|
+
|
42
|
+
option :controller,
|
43
|
+
description: 'the controller to query',
|
44
|
+
short: '-C ID',
|
45
|
+
long: '--controller ID',
|
46
|
+
proc: proc(&:to_i),
|
47
|
+
default: 0
|
48
|
+
# Main function
|
49
|
+
#
|
50
|
+
def run
|
51
|
+
have_error = false
|
52
|
+
error = ''
|
53
|
+
# get number of virtual drives
|
54
|
+
`#{config[:megaraidcmd]} -LDGetNum -a#{config[:controller]} `
|
55
|
+
(0..$CHILD_STATUS.exitstatus - 1).each do |i|
|
56
|
+
# and check them in turn
|
57
|
+
stdout = `#{config[:megaraidcmd]} -LDInfo -L#{i} -a#{config[:controller]} `
|
58
|
+
unless Regexp.new('State\s*:\s*Optimal').match(stdout)
|
59
|
+
error = sprintf '%svirtual drive %d: %s ', error, i, stdout[/State\s*:\s*.*/].split(':')[1]
|
60
|
+
have_error = true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if have_error
|
65
|
+
critical error
|
66
|
+
else
|
67
|
+
ok
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/bin/check-raid.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-raid
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Generic raid check
|
7
|
+
# Supports HP, Adaptec, and MegaRAID controllers. Also supports software RAID.
|
8
|
+
#
|
9
|
+
# OUTPUT:
|
10
|
+
# plain text
|
11
|
+
#
|
12
|
+
# PLATFORMS:
|
13
|
+
# Linux
|
14
|
+
#
|
15
|
+
# DEPENDENCIES:
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
# NOTES:
|
21
|
+
#
|
22
|
+
# LICENSE:
|
23
|
+
# Originally by Shane Feek, modified by Alan Smith. Date: 07/14/2014#
|
24
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE for details.
|
25
|
+
#
|
26
|
+
|
27
|
+
require 'sensu-plugin/check/cli'
|
28
|
+
|
29
|
+
#
|
30
|
+
# Check Raid
|
31
|
+
#
|
32
|
+
class CheckRaid < Sensu::Plugin::Check::CLI
|
33
|
+
# Check software raid
|
34
|
+
#
|
35
|
+
def check_software
|
36
|
+
# #YELLOW
|
37
|
+
if File.exist?('/proc/mdstat') # rubocop:disable GuardClause
|
38
|
+
contents = File.read('/proc/mdstat')
|
39
|
+
mg = contents.lines.grep(/active/)
|
40
|
+
unless mg.empty?
|
41
|
+
sg = mg.to_s.lines.grep(/\]\(F\)/)
|
42
|
+
# #YELLOW
|
43
|
+
unless sg.empty? # rubocop:disable UnlessElse
|
44
|
+
warning 'Software RAID warning'
|
45
|
+
else
|
46
|
+
ok 'Software RAID OK'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Check HP raid
|
53
|
+
#
|
54
|
+
def check_hp
|
55
|
+
# #YELLOW
|
56
|
+
if File.exist?('/usr/bin/cciss_vol_status') # rubocop:disable GuardClause
|
57
|
+
contents = `/usr/bin/cciss_vol_status /dev/sg0`
|
58
|
+
c = contents.lines.grep(/status\: OK\./)
|
59
|
+
# #YELLOW
|
60
|
+
unless c.empty? # rubocop:disable UnlessElse
|
61
|
+
ok 'HP RAID OK'
|
62
|
+
else
|
63
|
+
warning 'HP RAID warning'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check Adaptec raid controllers
|
69
|
+
#
|
70
|
+
def check_adaptec
|
71
|
+
# #YELLOW
|
72
|
+
if File.exist?('/usr/StorMan/arcconf') # rubocop:disable GuardClause
|
73
|
+
contents = `/usr/StorMan/arcconf GETCONFIG 1 AL`
|
74
|
+
|
75
|
+
mg = contents.lines.grep(/Controller Status/)
|
76
|
+
# #YELLOW
|
77
|
+
unless mg.empty? # rubocop:disable UnlessElse
|
78
|
+
sg = mg.to_s.lines.grep(/Optimal/)
|
79
|
+
warning 'Adaptec Physical RAID Controller Failure' if sg.empty?
|
80
|
+
else
|
81
|
+
warning 'Adaptec Physical RAID Controller Status Read Failure'
|
82
|
+
end
|
83
|
+
|
84
|
+
mg = contents.lines.grep(/Status of logical device/)
|
85
|
+
# #YELLOW
|
86
|
+
unless mg.empty? # rubocop:disable UnlessElse
|
87
|
+
sg = mg.to_s.lines.grep(/Optimal/)
|
88
|
+
warning 'Adaptec Logical RAID Controller Failure' if sg.empty?
|
89
|
+
else
|
90
|
+
warning 'Adaptec Logical RAID Controller Status Read Failure'
|
91
|
+
end
|
92
|
+
|
93
|
+
mg = contents.lines.grep(/S\.M\.A\.R\.T\. /)
|
94
|
+
# #YELLOW
|
95
|
+
unless mg.empty? # rubocop:disable UnlessElse
|
96
|
+
sg = mg.to_s.lines.grep(/No/)
|
97
|
+
warning 'Adaptec S.M.A.R.T. Disk Failed' if sg.empty?
|
98
|
+
else
|
99
|
+
warning 'Adaptec S.M.A.R.T. Status Read Failure'
|
100
|
+
end
|
101
|
+
|
102
|
+
ok 'Adaptec RAID OK'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Check Megaraid
|
107
|
+
#
|
108
|
+
def check_mega_raid
|
109
|
+
# #YELLOW
|
110
|
+
if File.exist?('/usr/sbin/megacli') # rubocop:disable GuardClause
|
111
|
+
contents = `/usr/sbin/megacli -AdpAllInfo -aALL`
|
112
|
+
c = contents.lines.grep(/(Critical|Failed) Disks\s+\: 0/)
|
113
|
+
# #YELLOW
|
114
|
+
unless c.empty? # rubocop:disable UnlessElse
|
115
|
+
ok 'MegaRaid RAID OK'
|
116
|
+
else
|
117
|
+
warning 'MegaRaid RAID warning'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Main function
|
123
|
+
#
|
124
|
+
def run
|
125
|
+
unless `lspci`.lines.grep(/RAID/).empty?
|
126
|
+
check_software
|
127
|
+
check_hp
|
128
|
+
check_adaptec
|
129
|
+
check_mega_raid
|
130
|
+
|
131
|
+
unknown 'Missing software for RAID controller'
|
132
|
+
end
|
133
|
+
|
134
|
+
ok 'No RAID present'
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-smart-array-status
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Check HP SmartArray Status Plugin
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
# gem: open3
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
# NOTES:
|
21
|
+
# You can get Debian/Ubuntu hpacucli packages here - http://hwraid.le-vert.net/
|
22
|
+
# Checks status for all HDDs in all SmartArray controllers.
|
23
|
+
#
|
24
|
+
# hpacucli requires root permissions.
|
25
|
+
# Create a file named /etc/sudoers.d/hpacucli with this line inside :
|
26
|
+
# sensu ALL=(ALL) NOPASSWD: /usr/sbin/hpacucli
|
27
|
+
#
|
28
|
+
# LICENSE:
|
29
|
+
# Copyright 2014 Alexander Bulimov <lazywolf0@gmail.com>
|
30
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
31
|
+
# for details.
|
32
|
+
#
|
33
|
+
|
34
|
+
require 'sensu-plugin/check/cli'
|
35
|
+
require 'open3'
|
36
|
+
|
37
|
+
#
|
38
|
+
# Check Smart Array Status
|
39
|
+
#
|
40
|
+
class CheckSmartArrayStatus < Sensu::Plugin::Check::CLI
|
41
|
+
# Setup variables
|
42
|
+
#
|
43
|
+
def initialize
|
44
|
+
super
|
45
|
+
@binary = 'sudo -n -k hpacucli'
|
46
|
+
@controllers = []
|
47
|
+
@good_disks = []
|
48
|
+
@bad_disks = []
|
49
|
+
end
|
50
|
+
|
51
|
+
# Execute hpacucli and capture the exit status ans stdout
|
52
|
+
#
|
53
|
+
# @param cmd [String] The command to check the HP array
|
54
|
+
def execute(cmd)
|
55
|
+
captured_stdout = ''
|
56
|
+
# we use popen2e because hpacucli does not use stderr for errors
|
57
|
+
exit_status = Open3.popen2e(ENV, cmd) do |stdin, stdout, wait_thr|
|
58
|
+
stdin.close
|
59
|
+
captured_stdout = stdout.read
|
60
|
+
wait_thr.value
|
61
|
+
end
|
62
|
+
[exit_status, captured_stdout]
|
63
|
+
end
|
64
|
+
|
65
|
+
# Parse controller data
|
66
|
+
#
|
67
|
+
# @param data [String]
|
68
|
+
#
|
69
|
+
def parse_controllers!(data)
|
70
|
+
data.lines.each do |line|
|
71
|
+
unless line.empty?
|
72
|
+
captures = line.match(/Slot\s+([0-9]+)/)
|
73
|
+
@controllers << captures[1] if !captures.nil? && captures.length > 1
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Parse disk data
|
79
|
+
#
|
80
|
+
# @param data [String]
|
81
|
+
# @param controller [String]
|
82
|
+
#
|
83
|
+
def parse_disks!(data, controller)
|
84
|
+
# #YELLOW
|
85
|
+
data.lines.each do |line| # rubocop:disable Style/Next
|
86
|
+
unless line.empty?
|
87
|
+
splitted = line.split
|
88
|
+
if /^physicaldrive$/ =~ splitted[0]
|
89
|
+
status = splitted[-1]
|
90
|
+
disk = 'ctrl ' + controller + ' ' + line.strip
|
91
|
+
if status == 'OK'
|
92
|
+
@good_disks << disk
|
93
|
+
else
|
94
|
+
@bad_disks << disk
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Main function
|
102
|
+
#
|
103
|
+
def run
|
104
|
+
exit_status, raw_data = execute "#{@binary} ctrl all show status"
|
105
|
+
unknown "hpacucli command failed - #{raw_data}" unless exit_status.success?
|
106
|
+
parse_controllers! raw_data
|
107
|
+
|
108
|
+
@controllers.each do |controller|
|
109
|
+
exit_status, raw_data = execute "#{@binary} ctrl slot=#{controller} pd all show status"
|
110
|
+
unknown "hpacucli command failed - #{raw_data}" unless exit_status.success?
|
111
|
+
parse_disks! raw_data, controller
|
112
|
+
end
|
113
|
+
|
114
|
+
if @bad_disks.empty?
|
115
|
+
data = @good_disks.length
|
116
|
+
ok "All #{data} found disks are OK"
|
117
|
+
else
|
118
|
+
data = @bad_disks.join(', ')
|
119
|
+
bad_count = @bad_disks.length
|
120
|
+
good_count = @good_disks.length
|
121
|
+
total_count = bad_count + good_count
|
122
|
+
critical "#{bad_count} of #{total_count} disks are in bad state - #{data}"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
metadata
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-raid-checks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yieldbot, Inc and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
14
|
+
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
15
|
+
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
16
|
+
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
17
|
+
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
18
|
+
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
19
|
+
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
20
|
+
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
21
|
+
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
22
|
+
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
23
|
+
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
+
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
25
|
+
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
26
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
27
|
+
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
28
|
+
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
+
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
+
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
+
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-02-01 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: sensu-plugin
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.1.0
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.1.0
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: codeclimate-test-reporter
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rubocop
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.17.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.17.0
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rspec
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.1'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.1'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: bundler
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ~>
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.7'
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.7'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rake
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '10.0'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '10.0'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: github-markup
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: redcarpet
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: yard
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
description: Sensu nginx checks
|
162
|
+
email: <sensu-users@googlegroups.com>
|
163
|
+
executables:
|
164
|
+
- check-3ware-status.rb
|
165
|
+
- check-megaraid-sas-status.rb
|
166
|
+
- check-raid.rb
|
167
|
+
- check-smart-array-status.rb
|
168
|
+
extensions: []
|
169
|
+
extra_rdoc_files: []
|
170
|
+
files:
|
171
|
+
- bin/check-3ware-status.rb
|
172
|
+
- bin/check-megaraid-sas-status.rb
|
173
|
+
- bin/check-raid.rb
|
174
|
+
- bin/check-smart-array-status.rb
|
175
|
+
- lib/sensu-plugins-raid-checks.rb
|
176
|
+
- LICENSE
|
177
|
+
- README.md
|
178
|
+
- CHANGELOG.md
|
179
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-raid-checks
|
180
|
+
licenses:
|
181
|
+
- MIT
|
182
|
+
metadata: {}
|
183
|
+
post_install_message:
|
184
|
+
rdoc_options: []
|
185
|
+
require_paths:
|
186
|
+
- lib
|
187
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: 1.9.3
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - '>'
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 1.3.1
|
197
|
+
requirements: []
|
198
|
+
rubyforge_project:
|
199
|
+
rubygems_version: 2.0.14
|
200
|
+
signing_key:
|
201
|
+
specification_version: 4
|
202
|
+
summary: Sensu nginx checks
|
203
|
+
test_files: []
|
204
|
+
has_rdoc:
|
metadata.gz.sig
ADDED