forked from cbartlett/nagios-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_dell_amcli.rb
executable file
·36 lines (26 loc) · 943 Bytes
/
check_dell_amcli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby
require 'ostruct'
require 'pp'
AMCLI="C:/Program Files/Dell/OpenManage/Array Manager/amcli.exe"
class String
def methodize; downcase.gsub(/\s+/,'_').gsub('.',''); end
def carve_into_fields; split(/\t|\s{3,}/).map { |v| v.gsub('.','') }; end
end
def volumes
content = IO.popen("#{AMCLI} /dv").readlines.map { |v| v.strip }.reject { |v| v == "" }[3..-1]
fields = content.shift.carve_into_fields.map { |v| v.methodize }
content.map { |v| OpenStruct.new(Hash[ *(fields.zip(v.carve_into_fields).flatten) ]) }
end
status = 0
msgs = []
volumes.each do |volume|
status = 2 unless volume.state == 'READY' && volume.redundant == 'Yes'
msgs << "#{volume.name} [state: #{volume.state}, redundant: #{volume.redundant}]"
end
if msgs.length > 0
puts "#{ %w/OK WARN CRIT UNKNOSN/[status] }: #{msgs.join(', ')}"
exit(status)
else
puts "UNKNOWN: no raid volumes found using amcli"
exit(2)
end