[Nagiosplug-devel] RAID plugin

Subhendu Ghosh sghosh at sghosh.org
Mon Oct 21 07:04:03 CEST 2002


Rewriting in perl or C would make it easier for the users I think. 

Also if you wan tto include some of the standard options support and 
perhaps provide stub support for other raid systems..

-sg

On 21 Oct 2002, Andreas Krennmair wrote:

> Hello!
> 
> I wrote a nagios plugin to check all RAIDs on a system. It is written in
> Ruby, but could be easily rewritten in any other language that supports
> regular expressions (e.g. Perl). Comments, patches, etc. are welcome.
> 
> Regards,
> Andreas Krennmair
> 

-- 

-------------- next part --------------
#!/usr/bin/ruby
# $Id: check_raid.rb,v 1.2 2002/10/21 08:20:52 andreas Exp $
#
# Copyright + Disclaimer:
# (c) 2002 Andreas Krennmair <krennmair at webdynamite.com> + WebDynamite
# Distributed under the terms of the GNU General Public License version 2,
# as published by the Free Software Foundation. This software comes with
# ABSOUTELY NO WARRANTY, to the extent permitted by applicable law.
#
# ad-hoc documentation of the /proc/mdstat file format:
#######################################################
# first line: information about the personalities (i.e. supported RAID types)
# second line: information about read-ahead stuff
# all subsequent lines matching /^md\d :/ plus their successor are
# entries of a RAID. The second line must match /\[U+\]$/ to display that
# the RAID is up.
#######################################################

MDSTAT_FILE="/proc/mdstat"

retval = 0
output = ""

if FileTest.exists?(MDSTAT_FILE)
  mdstatFile = File.open(MDSTAT_FILE)
  while line = mdstatFile.gets do
    if line =~ /^(md\d+) :/ then
      md = $1
      if line2 = mdstatFile.gets then
        if line2 =~ /(\[U+\])$/ then
          output += "#{md}: OK "
        else
          output += "#{md}: FAILURE "
          retval = 2
        end
      else
        output += "#{md}: invalid entry "
        retval = 1 if retval < 1;
      end
    end
  end
else
  output = "No RAID support in kernel."
  retval = 1
end

puts output
Kernel.exit(retval)


More information about the Devel mailing list