Renamed mdarrays fact to raid, added support for hardware controllers
This commit is contained in:
parent
422fc90f78
commit
027ecc1fce
3 changed files with 30 additions and 16 deletions
|
@ -1,15 +0,0 @@
|
||||||
Facter.add(:mdarrays) do
|
|
||||||
confine :kernel => :linux
|
|
||||||
setcode do
|
|
||||||
arrays = []
|
|
||||||
mdstat = "/proc/mdstat"
|
|
||||||
if File.exists?(mdstat)
|
|
||||||
File.readlines(mdstat).each do |line|
|
|
||||||
if m = line.match(/^md[0-9]+/)
|
|
||||||
arrays << m[0]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
arrays.sort.join(',')
|
|
||||||
end
|
|
||||||
end
|
|
29
custom/lib/facter/raid.rb
Normal file
29
custom/lib/facter/raid.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
require 'set'
|
||||||
|
|
||||||
|
Facter.add(:raid) do
|
||||||
|
confine :kernel => :linux
|
||||||
|
setcode do
|
||||||
|
raid = Set.new
|
||||||
|
mdstat = "/proc/mdstat"
|
||||||
|
if File.exists?(mdstat)
|
||||||
|
File.readlines(mdstat).each do |line|
|
||||||
|
if line =~ /^md[0-9]+/
|
||||||
|
raid << "linux-md"
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
modules = "/proc/modules"
|
||||||
|
if File.exists?(modules)
|
||||||
|
File.readlines(modules).each do |line|
|
||||||
|
case line
|
||||||
|
when /^cciss\s/,/^hpsa\s/
|
||||||
|
raid << "smartarray"
|
||||||
|
when /^megaraid_sas\s/
|
||||||
|
raid << "megaraid"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
raid.sort.join(',')
|
||||||
|
end
|
||||||
|
end
|
|
@ -291,7 +291,7 @@ class nagios::target::nrpe inherits nagios::target {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if $::kernel == "Linux" and $::mdarrays {
|
if $::raid and "linux-md" in split($::raid, ',') {
|
||||||
nagios::target::nrpe::service { "check_linux_raid":
|
nagios::target::nrpe::service { "check_linux_raid":
|
||||||
description => "RAID",
|
description => "RAID",
|
||||||
package => $::operatingsystem ? {
|
package => $::operatingsystem ? {
|
||||||
|
|
Loading…
Add table
Reference in a new issue