diff --git a/custom/lib/facter/mdarrays.rb b/custom/lib/facter/mdarrays.rb deleted file mode 100644 index 31ae6a5..0000000 --- a/custom/lib/facter/mdarrays.rb +++ /dev/null @@ -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 diff --git a/custom/lib/facter/raid.rb b/custom/lib/facter/raid.rb new file mode 100644 index 0000000..7b3809c --- /dev/null +++ b/custom/lib/facter/raid.rb @@ -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 diff --git a/nagios/manifests/target.pp b/nagios/manifests/target.pp index f620b0a..d0f32f0 100644 --- a/nagios/manifests/target.pp +++ b/nagios/manifests/target.pp @@ -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": description => "RAID", package => $::operatingsystem ? {