Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (49 sloc) 1.59 KB
#!/usr/bin/env ruby
EXIT_OK = 0
EXIT_WARNING = 1
EXIT_CRITICAL = 2
EXIT_UNKNOWN = 3
raid_state=""
module Kernel
alias :original_exit :exit
def exit(value)
original_exit(value)
end
end
raid_model = `/sbin/lspci`[/Symbios Logic (.*) \(rev/,1]
if raid_model =~ /Fusion-MPT/
if raid_model =~ /SAS2008/
raid_info = `sudo /usr/local/bin/sas2ircu 0 DISPLAY`
raid_state = "Status of volume: " + raid_info[/Status of volume(.*): (.*)\(/,2]
for i in (0..raid_info.split('Device is a Hard disk').length-1)
if raid_info.split('Device is a Hard disk')[i] =~ /State/
state = "Slot" + raid_info.split('Device is a Hard disk')[i][/Slot(.*) : ([\d])/,2] + ": "
raid_state << state + raid_info.split('Device is a Hard disk')[i][/State(.*) : (.*)/,2] + " "
end
end
elsif raid_model =~ /SAS1068E/
raid_info = `sudo /usr/sbin/mpt-status`
raid_state << raid_info.split.join(' ')
end
else
raid_info = `sudo /opt/MegaRAID/MegaCli/MegaCli* -LDInfo -LAll -aAll`
for i in (0..raid_info.split('Virtual Drive').length-1)
if raid_info.split('Virtual Drive')[i] =~ /State/
state = "Virtual_Drive" + raid_info.split('Virtual Drive')[i][/Target Id: ([\d])/,1] + ": "
raid_state << state + raid_info.split('Virtual Drive')[i].[/State(.*) : (.*)/,2] + " "
end
end
end
if raid_state =~ /Degraded/
puts "Warning: #{raid_state}"
exit(EXIT_WARNING)
elsif raid_state =~ /Optimal/
puts "OK: #{raid_state}"
exit(EXIT_OK)
elsif raid_state.nil?
puts "Unknown: Cos poszlo nie tak"
exit(EXIT_UNKNOWN)
else
puts "Critical: #{raid_state}"
exit(EXIT_CRITICAL)
end