summaryrefslogtreecommitdiff
path: root/nagios-check-raid.pl
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2008-03-31 09:32:09 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2008-03-31 09:32:09 +0000
commita010e0f9b8134529188ebc771104fdfdb137692a (patch)
tree14585b23b005c9e8cdceb59c6abf4d69a9934fe1 /nagios-check-raid.pl
parent2bcc9eca6f6c925bacc206e0a68cadc482553030 (diff)
Return warn on running rsync
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@325 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'nagios-check-raid.pl')
-rwxr-xr-xnagios-check-raid.pl28
1 files changed, 21 insertions, 7 deletions
diff --git a/nagios-check-raid.pl b/nagios-check-raid.pl
index 504d622..7919e26 100755
--- a/nagios-check-raid.pl
+++ b/nagios-check-raid.pl
@@ -15,6 +15,7 @@
# ------------------------------------------------------------------------------
# Date Author Reason
# ---- ------ ------
+# 2008-03-31 Peter Palfrader Return warning on running resync
# 2007-11-07 Peter Palfrader Return unknown if /proc/mdstat does not exist
# 05/10/2004 Peter Palfrader Make it work without that 'use util (vars)'
# 14/06/2003 TN Initial Release
@@ -39,7 +40,7 @@ sub print_usage ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
-my ( $line, $prevline, $stat, $state ,@device, $msg, $status, $timeout);
+my ( $line, $stat, $state ,@device, $msg, $status, $timeout);
$stat="/proc/mdstat";
@@ -86,20 +87,33 @@ open (FH, $stat) or print("UNKNOWN: Cannot open $stat: $!\n"), exit $ERRORS{'UNK
$state = $ERRORS{'OK'};
$msg ="";
+my @resyncing = ();
+my $device = '';
+
# Now check the mdstat file..
while (<FH>) {
- $line= $_;
- if( $line =~ / \[_|_\]|U_|_U /) {
+ $line = $_;
+ if ($line =~ /^(md.*) /) {
+ $device = $0;
+ } elsif( $line =~ / \[_|_\]|U_|_U /) {
$state = $ERRORS{'CRITICAL'};
- @device = split(/ /,$prevline);
- $msg = $msg . $device[0] . ": - ";
- }
- $prevline = $line;
+ $msg = $msg . $device . ": - ";
+ }
+ elsif ( $line =~ / resync /) {
+ # [==>..................] resync = 10.3% (15216320/146994624) finish=2153.2min speed=1018K/sec
+ my ($percent) = ($line =~ m# resync = ([0-9.]+%)#);
+ my ($finish) = ($line =~ m# finish=([0-9.]+min)#);
+ my ($speed) = ($line =~ m# speed=([0-9.]+K/sec)#);
+ push @resyncing, "$device ($percent done, finish in $finish at $speed)";
+ }
}
close (FH);
if ( $state == $ERRORS{'CRITICAL'} ) {
print "CRITICAL - Device(s) $msg have failed\n";
+} elsif ( scalar @resyncing > 0 ) {
+ print "WARNING: Resyncing: ".(join "; ", @resyncing)."\n";
+ $state = $ERRORS{'WARNING'};
} elsif ( $state == $ERRORS{'OK'} )
{ print "OK - All devices are online\n"; }
exit $state;