This might be useful for sysadmins who manage Solaris servers. The iostat -En command can be used to check for cumulative disk errors but the output is rather dense so it can be difficult to sort the wood from the trees. This script uses Term::ANSIColor to make errors easier to spot.
use strict;
use warnings;
use Term::ANSIColor qw{ :constants };
my $rxTriggers = do {
my @triggers = (
q{Soft Errors: },
q{Hard Errors: },
q{Transport Errors: },
q{Media Error: },
q{Device Not Ready: },
q{No Device: },
q{Recoverable: },
q{Illegal Request: },
q{Predictive Failure Analysis: },
);
local $" = q{|};
qr{(@triggers)(\d+)}
};
my @iostatCmd = qw{ /usr/bin/iostat -En };
open my $iostatFH, q{-|}, @iostatCmd
or die qq{open: @iostatCmd |: $!\n};
print q{-} x 60, qq{\n};
while ( not eof $iostatFH )
{
my $record;
$record .= $_ for
map { eof $iostatFH ? () : scalar <$iostatFH> }
1 .. 5;
substr $record, 16, 0, RESET;
substr $record, 0, 0, BOLD;
$record =~
s{$rxTriggers}
{ $2 eq q{0}
? $1 . GREEN . $2 . RESET
: YELLOW . $1 . RED . $2 . RESET }eg;
print $record;
print q{-} x 60, qq{\n};
}
close $iostatFH
or die qq{close: @iostatCmd |: $!\n};
I no longer have a working Solaris box to provide example output but I hope this will be useful for somebody out there.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.