[Logwatch-Devel] Fwd: Patch to add Software RAID support

Kirk Bauer kirk at kaybee.org
Tue Jun 19 08:57:46 MST 2007


---------- Forwarded message ----------
From: Pat Riehecky <prieheck at iwu.edu>
Date: Tue, 19 Jun 2007 10:24:22 -0500
Subject: Patch to add Software RAID support
To: logwatch-patches at logwatch.org

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 <kirk at kaybee.org>
http://linux.kaybee.org | www.autorpm.org | www.logwatch.org


More information about the Logwatch-Devel mailing list