From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/263186-check_linux_raid.pl.diff | 77 +++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 web/attachments/263186-check_linux_raid.pl.diff (limited to 'web/attachments/263186-check_linux_raid.pl.diff') diff --git a/web/attachments/263186-check_linux_raid.pl.diff b/web/attachments/263186-check_linux_raid.pl.diff new file mode 100644 index 0000000..0e7861c --- /dev/null +++ b/web/attachments/263186-check_linux_raid.pl.diff @@ -0,0 +1,77 @@ +--- contrib/check_linux_raid.pl 2007-08-28 04:19:45.000000000 +0100 ++++ contrib/check_linux_raid.pl.new 2008-01-21 17:28:18.000000000 +0000 +@@ -3,6 +3,7 @@ + # Copyright (c) 2002 ISOMEDIA, Inc. + # originally written by Steve Milton + # later updates by sean finney ++# bux fixing & usage message by Alain Williams + # + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by +@@ -26,6 +27,8 @@ + use lib "/usr/local/nagios/libexec"; + use utils qw(%ERRORS); + ++my ($progname) = $0 =~ m|([^/]+)$|; ++ + # die with an error if we're not on Linux + if ($^O ne 'linux') { + print "This plugin only applicable on Linux.\n"; +@@ -42,9 +45,22 @@ + return "UNKNOWN"; + } + ++sub usage { ++ print "Inspect Linux software raid devices and return a status for nagios\n"; ++ print "Usage:\n"; ++ print "$progname [--help | -h] [md-device ...]\n"; ++ print "A md-device might be: md0\n"; ++ print "If md-device is not given, all mds will be inspected\n"; ++ exit 0; ++} ++ + my $nextdev; +-if(defined $ARGV[0]) { $nextdev = shift; } +-else { $nextdev = "md[0-9]"; } ++if(defined $ARGV[0]) { ++ $nextdev = shift; ++ usage() if($nextdev eq '--help' or $nextdev eq '-h'); ++} else { ++ $nextdev = "md[0-9]+"; # All MD devices ++} + + my $code = "UNKNOWN"; + my $msg = ""; +@@ -53,6 +69,7 @@ + my %finish; + my %active; + my %devices; ++my $debug; + + while(defined $nextdev){ + open (MDSTAT, "< /proc/mdstat") or die "Failed to open /proc/mdstat"; +@@ -60,14 +77,22 @@ + while() { + if (defined $device) { + if (/(\[[_U]+\])/) { ++ print "status='$1' device '$device'\n" if($debug); + $status{$device} = $1; + } elsif (/recovery = (.*?)\s/) { + $recovery{$device} = $1; + ($finish{$device}) = /finish=(.*?min)/; +- } elsif (/^\s*$/) { ++ } elsif (/^\s*$/) { # Start of another device - blank line. NB: may not be present ++ print "undef '$device' _='$_'\n" if($debug); + $device=undef; ++ } elsif(/^md[0-9]+\s*:/) { # Start of another device - another way ++ print "undef '$device' _='$_'\n" if($debug); ++ undef $device; + } +- } elsif (/^($nextdev)\s*:/) { ++ } ++ ++ # No current device and this line matches the device pattern ? ++ if ( ! defined($device) and /^($nextdev)\s*:/) { + $device=$1; + $devices{$device}=$device; + if (/active/) { -- cgit v1.2.3-74-g34f1