Hi Warewolf & All,<br><br>After looking at the code carefully, I decided it'd be easier for my purposes to rewrite: I only have access to RAID1 to test so the code won't work if you're using a different RAID level. Feedback is most welcome!
<br><br><font size="1"><span style="font-family: courier new,monospace;">#!/usr/bin/perl</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
use constant OK => 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">use constant CRITICAL => 2;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">open METASTAT, "-|", "/usr/sbin/metastat" || die "Couldn't run metastat ($!)";</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">while ( <METASTAT> )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> chomp;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> s/^\s+//;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( /^(d\d+): (.+)/ ) # begin new device</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $device = $1;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $type = $2;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( $type eq "Mirror" ) # begin new device of type "Mirror"
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( /^Submirror \d+: (d\d+)/ ) # begin new "Submirror"
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $submirror = $1;
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $submirrors++;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( /^State: (\S+)/ ) # read in new "State"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $state = $1;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( $state ne "Okay" )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $message .= " and submirror $submirror of mirror $device is \"$state\"";</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
$exitcode = CRITICAL;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( $_ eq "" ) # finished with device on blank line
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if ( $type eq "Mirror" && $submirrors == 1 )
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $message .= " and $device has only one submirror!";
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $exitcode = CRITICAL;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> undef $submirrors; # clear our flags</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
undef $device;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> next;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">close METASTAT;
</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$message =~ s/^ and //;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">if ( $exitcode == OK ) { print "OK - No disk failures detected\n" }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">elsif ( $exitcode == CRITICAL ) { print "CRITICAL - $message\n"; }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
exit $exitcode;</span></font><br><br>Kind Regards,<br>Alex Harvey<br><br><br><br><div><span class="gmail_quote">On 11/7/06, <b class="gmail_sendername">Alexander Harvey</b> <<a href="mailto:alexh19740110@gmail.com">alexh19740110@gmail.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi to Warewolf<br><br>--or anyone else using the check_disksuite2 plugin from the NagiosExchange--if you're out there!
<br><br>I have been using your plugin and have discovered a "bug" / feature depending on what you intended: in the event that a submirror is detached, the plugin returns a value of OK.
<br><br>Just wondering if you're happy for me to submit a patch for this? Or is it something you'd rather look at yourself? Or has someone out there prepared a patch already?<br><br>Kind Regards,<br>Alex Harvey<br>
</blockquote></div><br>