[nagiosplug] Patch for check_linux_raid with on linear/raid0 ...

"Thomas Guyot-Sionnest" <[email protected]>
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
 Module: nagiosplug
 Branch: master
 Commit: e30f77864054e54f3c777aee0315f9c13b10957d
 Author: Thomas Guyot-Sionnest <[email protected]>
   Date: Tue Oct  5 23:19:03 2010 -0400
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=e30f778

Patch for check_linux_raid with on linear/raid0 arrays

Fixes bug #3049988, Debian bug #579049

---

 contrib/check_linux_raid.pl |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/contrib/check_linux_raid.pl b/contrib/check_linux_raid.pl
index d2e5b46..77e75f6 100644
--- a/contrib/check_linux_raid.pl
+++ b/contrib/check_linux_raid.pl
@@ -71,7 +71,8 @@ while(defined $nextdev){
 		} elsif (/^($nextdev)\s*:/) {
 			$device=$1;
 			$devices{$device}=$device;
-			if (/active/) {
+			if (/\sactive/) {
+				$status{$device} = ''; # Shall be filled later if available
 				$active{$device} = 1;
 			}
 		}
@@ -80,7 +81,11 @@ while(defined $nextdev){
 }
 
 foreach my $k (sort keys %devices){
-	if ($status{$k} =~ /_/) {
+	if (!exists($status{$k})) {
+		$msg .= sprintf " %s inactive with no status information.",
+			$devices{$k};
+		$code = max_state($code, "CRITICAL");
+	} elsif ($status{$k} =~ /_/) {
 		if (defined $recovery{$k}) {
 			$msg .= sprintf " %s status=%s, recovery=%s, finish=%s.",
 				$devices{$k}, $status{$k}, $recovery{$k}, $finish{$k};
@@ -94,10 +99,11 @@ foreach my $k (sort keys %devices){
 		$code = max_state($code, "OK");
 	} else {
 		if ($active{$k}) {
-			$msg .= sprintf " %s active with no status information.\n",
+			$msg .= sprintf " %s active with no status information.",
 				$devices{$k};
 			$code = max_state($code, "OK");
 		} else {
+			# This should't run anymore, but is left as a catch-all
 			$msg .= sprintf " %s does not exist.\n", $devices{$k};
 			$code = max_state($code, "CRITICAL");
 		}


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.