#!/usr/bin/perl -w use POSIX qw(strftime); my $raid_admin = "root@foo.bar"; my $raid_host = `/bin/hostname`; @ARGV = qw(/proc/mdstat); my @mdstat = <>; ## UNTESTED exit if not grep m{ \[(\d)/(\d)\] } && $1 ne $2, @mdstat; open( my $mail, "|/bin/mail -s 'RAID disk failure on $raid_host (". strftime('%Y.%m.%d-%H:%M'). ")' $raid_admin" ) or die "Couldn't spawn /bin/mail: $!\n"; print $mail @mdstat; close $mail;