Monitoring mirroring

Subhendu Ghosh sghosh at sghosh.org
Tue Sep 16 06:47:50 CEST 2003


On Mon, 15 Sep 2003, Mark Snyder wrote:
> Is there a check for monitoring mirrored disks?  Maybe monitoring the output from a metastat command?

A couple of version that quite haven't made there way into the 
distribution.

-- 
-sg
-------------- next part --------------
#!/usr/bin/perl -w

# check_metastat Nagios Plugin - Version 1.0
# Last Updated: 5/12/2003
#
# Report any bugs/questions to Russell Scibetti at nagios at quadrix.com

use Getopt::Long;
&Getopt::Long::config('bundling');

#YOU MUST SET YOUR PATH PROPERLY!
$ENV{PATH} = "/usr/opt/SUNWmd/sbin:/usr/sbin:$ENV{PATH}";

GetOptions
        ("V"   => \$version,    "version"       => \$version,
         "h"   => \$help,       "help"          => \$help,
         "v"   => \$verbose,    "verbose"       => \$verbose,
         "e=s" => \$error,       "error=s"	=> \$error);

if ($version) {
  printVersion();
  exit 3;
}

if ($help) {
  printVersion();
  printHelp();
  exit 3;
}

if (!$error) {
 $error = "Matinenance|Error";
} 

my $disk = "";
my $cmd = "metastat";

foreach $_ (`$cmd`) {
  chomp;
  if (/$error/) {
    $failure = 1;
    if (!(/State:/)) {
      @data = split;
      if ($disk) {
        $disk .= ", $data[0]";
      }
      else {
        $disk = $data[0];
      }
    }
  }
  $lastline = $_;
}

$exitcode = $? >> 8;

if ($exitcode == 0) {

  if ($failure) {
    if ($disk) {
      printf "CRITICAL - Error on disk $disk\n";
      exit 2;
    }
    else {
      printf "CRITICAL - MetaStat Disk Error Found\n";
      exit 2;
    }
  }
  else {
    printf "OK - No Disk Errors\n";
    exit 0;
  }
}
else {
  printf "Metastat command error: $lastline\n";
  exit $exitcode;
}

################################
#
# Version and Help Information
#
################################

sub printVersion {
  printf <<EndVersion;
$0 (nagios-plugins) 1.0
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
EndVersion
}

sub printHelp {
  printf <<EOF;

This plugin runs the metastat command and looks for any disk in an error state.

Usage: $0 (-e <Error RegEx>)
       $0 --help
       $0 --version
NOTE: -H and -C must BOTH be specified

Options:

 -e, --error=<Error RegEx>
   Regular Expression to match for as an Error
   (Default = "Maintenance|Error")
 -v, --verbose
   Show each line of output from metastat
 -h, --help
   Print detailed help screen
 -V, --version
   Print version information

EOF
}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: check_metadisk.sh
Type: application/x-sh
Size: 4180 bytes
Desc: 
URL: <https://www.monitoring-lists.org/archive/users/attachments/20030916/a4e81f31/attachment.sh>


More information about the Users mailing list