From 422fc90f78500f5c2f68443f393ec877b5f20f25 Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Thu, 11 Jul 2013 00:31:32 +0300 Subject: [PATCH] nagios: Added support for checking Linux md arrays to nrpe --- custom/lib/facter/mdarrays.rb | 15 +++++++++++++++ nagios/manifests/target.pp | 11 +++++++++++ 2 files changed, 26 insertions(+) create mode 100644 custom/lib/facter/mdarrays.rb diff --git a/custom/lib/facter/mdarrays.rb b/custom/lib/facter/mdarrays.rb new file mode 100644 index 0000000..31ae6a5 --- /dev/null +++ b/custom/lib/facter/mdarrays.rb @@ -0,0 +1,15 @@ +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/nagios/manifests/target.pp b/nagios/manifests/target.pp index 7d5e679..f620b0a 100644 --- a/nagios/manifests/target.pp +++ b/nagios/manifests/target.pp @@ -291,6 +291,17 @@ class nagios::target::nrpe inherits nagios::target { } } + if $::kernel == "Linux" and $::mdarrays { + nagios::target::nrpe::service { "check_linux_raid": + description => "RAID", + package => $::operatingsystem ? { + "debian" => "nagios-plugins-standard", + "ubuntu" => "nagios-plugins-standard", + default => "nagios-plugins-linux_raid", + } + } + } + }