Fwd: Patch to add Software RAID support

"Kirk Bauer" <[email protected]>
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
---------- Forwarded message ----------
From: Pat Riehecky <[email protected]>
Date: Tue, 19 Jun 2007 10:24:22 -0500
Subject: Patch to add Software RAID support
To: [email protected]

It is rather rough, but this is a working bit of code to check and see
if there is anything interesting in /proc/mdadm on a linux system.



#!/usr/bin/perl -w
use strict;
$|++;

my $mdstat_file='/proc/mdstat';
my @lines;

if ( $^O eq 'linux')
 {
  if ( -r $mdstat_file)
   {
    open (MDSTAT, $mdstat_file) or die "Unable to read $mdstat_file
\nRAID data will not be reported?";
    @lines=<MDSTAT>;
    close(MDSTAT);

    if (@lines > 2)
     {
      print "-------------------- RAID Status Begin
------------------------\n\n";
      print @lines;
      print "\n-------------------- RAID Status End
--------------------------\n";
     }
    elsif (@lines == 2)
     {
      foreach (@lines)
       {
        if ($_ =~ /unused devices: (.*)/)
         {
          # If there are unused RAID devices, this is worth displaying
          if ($1 ne '<none>')
           {
            print "-------------------- RAID Status Begin
------------------------\n\n";
            print @lines;
            print "\n-------------------- RAID Status End
--------------------------\n";
           }
         }
       }
     }
   }
 }

exit 0;




-- 
Kirk Bauer <[email protected]>
http://linux.kaybee.org | www.autorpm.org | www.logwatch.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.