From: Petter Reinholdtsen Date: Tue, 16 May 2006 09:40:23 +0000 (+0000) Subject: Add new nagios module. X-Git-Url: https://pere.pagekite.me/gitweb/homepage.git/commitdiff_plain/169c8ecc572f0b42a1b1312bda980abc2c4371da Add new nagios module. --- diff --git a/linux/check_gdth_raid b/linux/check_gdth_raid new file mode 100644 index 0000000000..48289245e9 --- /dev/null +++ b/linux/check_gdth_raid @@ -0,0 +1,75 @@ +#!/usr/bin/perl +# +# Author: Petter Reinholdtsen +# Date: 2006-05-15 +# License: GPL +# +# Nagios module to report the RAID status from the gdth linux kernel +# module. +# +# Based on documentation found in +# + +use strict; +use warnings; + +use Getopt::Long; + +my $verbose; +my $help; +my $RC = 0; + +sub usage { + print "Usage: $0 [-h|--help]\n"; + print " Reports the gdth status as found in /proc/scsi/gdth/*\n" +} + +my $result = GetOptions ("help" => \$help, "verbose+" => \$verbose); + +if ($help) { + usage(); + exit 0; +} + +if ( ! -d "/proc/scsi/gdth" ) { + print "No gdth status file found, /proc/scsi/gdth/ missing"; + exit 3; +} + +chdir "/proc/scsi/gdth"; + +my $RESULT = ""; + +# Looking for this text block: +# Logical Drives: +# Number: 0 Status: ok +# Capacity [MB]: 17333 Type: RAID-1 +# Slave Number: 15 Status: ok +# Missing Drv.: 0 Invalid Drv.: 0 +# To Array Drv.: -- +for my $controller (<*>) { + open(INFO, "< $controller") || die "Unable to read from $controller"; + # Have to use 'cat', as redirect into egrep didn't work with the + # file in /proc/. + while () { + chomp; + last if (/Array Drives:/); # Stop after the Logical Drive block + if (m/^\s+Number:\s+(\d+)\s+Status:\s+(\S+)$/) { + my ($num, $status) = ($1,$2); + if ("ok" ne $status) { + $RC = 2; + $RESULT="$RESULT ID $controller volume $num($status)"; +# print "Gdth RAID controller $controller volume $num ($status) NOT OK\n" + } else { +# print "Gdth RAID controller $controller volume $num OK\n" + } + } + } + close(INFO); +} +if ( 0 == "$RC" ) { + print "gdth RAID OK\n"; +} else { + print "gdth RAID $RESULT NOT OK\n"; +} +exit $RC;