[Petter Reinholdtsen] > Can anyone have a look at this draft script, and let me know what > the exit codes and output must be to have nagios accept it as a > monitor script?
I managed to find some documentation, and also concluded that the subshell in the original script made it hard to return the correct exit code, so I rewrote it in perl. Please have a look at this version, and let me know if I am on the right track. #!/usr/bin/perl # # Author: Petter Reinholdtsen # Date: 2006-05-15 # # Nagios module to report the RAID status from the gdth linux kernel # module. # # Based on documentation found in # <URL:http://nagiosplug.sourceforge.net/developer-guidelines.html> 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 = ""; 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 (<INFO>) { chomp; 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; -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

