Nagios command definition:
define command { blah }This can be run easially via nrpe, just make sure you're not trying to pass along any arguments when not necessary. I did that once accidentially and was confused for about 2 days wondering why the check was coming back as UNKNOWN.
Here's the syntax highlighted version of check_disksuite. Click here to download the sourcecode.
#!/usr/bin/perl use strict; use warnings; my ( $metastat, $device, $submirror ); open( METASTAT, "-|", "/usr/sbin/metastat") or die "Couldn't run metastat $device ($!)"; while (<METASTAT>) { chomp; $_ =~ s/^\s+//; $_ =~ s/\s+$//; if ( $_ eq "" ) { undef $device; undef $submirror; next; } if ( $_ =~ m/^(d\d+): (.+)/ ) { $device = $1; $metastat->{$device}->{type} = $2; } if ( $_ =~ m/Submirror (\d+): (d\d+)/ ) { $submirror = $2; } if ( $_ =~ m/State: (.+)/ ) { my $state = $1; if ( $metastat->{$device}->{type} eq "Mirror" && defined($submirror) ) { $metastat->{$submirror}->{state} = $state; undef $submirror; } elsif ( $metastat->{$device}->{type} eq "RAID" ) { $metastat->{$device}->{state} = $state; } } if ( $_ =~ m/Invoke: (.+)/ ) { $metastat->{$device}->{remedy} = $1; } } close METASTAT; foreach my $device ( keys %$metastat ) { delete $metastat->{$device} unless ( scalar keys %{ $metastat->{$device} } > 1 ); } foreach my $device ( keys %$metastat ) { delete $metastat->{$device} if ( $metastat->{$device}->{state} eq "Okay" ); } my ( $message, $exitcode ); $exitcode = 0; while ( my ( $device, $info ) = each %$metastat ) { if ( defined $info->{state} !~ m/Okay/ ) { if ( defined( $info->{remedy} ) ) { # CRITICAL $exitcode = 2; $message .= defined $message ? " " : ""; $message .= sprintf "%s: %s, %s, please run %s.", $device, $info->{type}, $info->{state}, $info->{remedy}; } else { $exitcode = 1 unless ( $exitcode > 1 ); $message .= defined $message ? " " : ""; $message .= sprintf "%s: %s, %s.", $device, $info->{type}, $info->{state}, $info->{remedy}; } } } if ( $exitcode == 0 ) { print "OK - No disk failures detected\n" } elsif ( $exitcode == 1 ) { print "WARNING - $message\n"; } elsif ( $exitcode == 2 ) { print "CRITICAL - $message\n"; } exit $exitcode;