]> pere.pagekite.me Git - homepage.git/commitdiff
Add new nagios module.
authorPetter Reinholdtsen <pere@hungry.com>
Tue, 16 May 2006 09:40:23 +0000 (09:40 +0000)
committerPetter Reinholdtsen <pere@hungry.com>
Tue, 16 May 2006 09:40:23 +0000 (09:40 +0000)
linux/check_gdth_raid [new file with mode: 0644]

diff --git a/linux/check_gdth_raid b/linux/check_gdth_raid
new file mode 100644 (file)
index 0000000..4828924
--- /dev/null
@@ -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
+# <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 = "";
+
+# 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 (<INFO>) {
+        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;