<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># raid-monitor.pl
# Check if some RAID device is reporting errors

sub get_raid_status
{
return { 'up' =&gt; -1 } if (!&amp;foreign_check("raid"));
&amp;foreign_require("raid", "raid-lib.pl");
local $conf = &amp;raid::get_raidtab();
local ($raid) = grep { $_-&gt;{'value'} eq $_[0]-&gt;{'device'} } @$conf;
if ($raid) {
	if (ref($raid-&gt;{'errors'})) {
		local ($bad) = grep { $_ eq "_" } @{$raid-&gt;{'errors'}};
		if ($bad) {
			return { 'up' =&gt; 0,
				 'desc' =&gt; $text{'raid_bad'} };
			}
		else {
			return { 'up' =&gt; 1 };
			}
		}
	elsif ($raid-&gt;{'resync'}) {
		return { 'up' =&gt; 0,
			 'desc' =&gt; $text{'raid_resync'} };
		}
	else {
		return { 'up' =&gt; 1 };
		}
	}
else {
	return { 'up' =&gt; -1,
		 'desc' =&gt; &amp;text('raid_notfound', $_[0]-&gt;{'device'}) };
	}
}

sub show_raid_dialog
{
&amp;foreign_require("raid", "raid-lib.pl");
local $conf = &amp;raid::get_raidtab();
local @opts;
foreach my $c (@$conf) {
	local $lvl = &amp;raid::find_value('raid-level', $c-&gt;{'members'});
	push(@opts, [ $c-&gt;{'value'},
		      $c-&gt;{'value'}." - ".
		      ($lvl eq 'linear' ? $raid::text{'linear'}
					: $raid::text{"raid$lvl"}) ]);
	}
local ($got) = grep { $_-&gt;[0] eq $_[0]-&gt;{'device'} } @opts;
if (!@opts) {
	print &amp;ui_table_row($text{'raid_device'},
			    &amp;ui_textbox("other", $_[0]-&gt;{'device'}, 10));
	}
else {
	push(@opts, [ "", $text{'raid_other'} ]);
	print &amp;ui_table_row($text{'raid_device'},
		&amp;ui_select("device", !$_[0]-&gt;{'device'} ? $opts[0]-&gt;[0] :
				     !$got ? "" : $_[0]-&gt;{'device'}, \@opts).
		" ".&amp;ui_textbox("other", $got ? "" : $_[0]-&gt;{'device'}, 10));
	}
}

sub parse_raid_dialog
{
&amp;depends_check($_[0], "raid");
$_[0]-&gt;{'device'} = $in{'device'} || $in{'other'};
$_[0]-&gt;{'device'} =~ /^\S+$/ || &amp;error($text{'raid_edevice'});
}

</pre></body></html>