[Nagiosplug-devel] RAID plugin
Andreas Krennmair
krennmair at webdynamite.com
Mon Oct 21 01:27:02 CEST 2002
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
--
________________________________________
Andreas Krennmair (Development)
WebDynamite IT Solutions GmbH
Landstraße 49, A-4020 Linz, Austria
http://www.webdynamite.com/
+43 / 732 / 777 810 - 0 (fixed)
+43 / 732 / 777 810 - 50 (fax)
________________________________________
-------------- 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