#!/usr/bin/perl -I/opt/SUNWstade/lib

use System;
use Grid;
use Getopt::Std;

System->set_home("/opt/SUNWstade");

if (!getopts("c:h", \%opts) || !$opts{c}) {
    print "Usage: read_grid -c code -h [html]\n";
    exit;
}

$code = $opts{c};
$HTML = $opts{h};


$obj = Grid->getInfoString(undef, undef, $code, 1);
@SEV = ('Notice','Warning','Error','Error/Critical');
my $act = "Actionable" if ($ev->{action});

if ($HTML) {
  print <<EOF;
<table border=1 cellspacing=0 cellpadding=2>
<tr><td align=right><b>Code:</b>
    <td> $obj->{code}</td>
<tr><td align=right><b>Default Sev.:</b>
    <td> $SEV[$obj->{severity}] $act</td>
<tr><td align=right><b>Sample Desc.:</b>
    <td> $obj->{desc}</td>
<tr><td align=right><b>Information:</b>
    <td> $obj->{info}</td>
<tr><td align=right><b>Probable Cause:</b>
    <td> $obj->{cause}</td>
<tr><td align=right><b>Recommended Action:</b>
    <td> $obj->{action}</td>
</table>
EOF

} else {
  print Dumper($obj);
}


# $VAR1 = {
#  'comp' => 'disk.temperature',
#   'code' => '13.5.94',
#   'desc' => 'The temperature of disk.u1d1 went over 40.  ',
#   'cause' => '1. PCU fan(s) may not be functioning',
#   'info' => 'The temperature threshold for one of the disks in the array has been ex',
#   'type' => 't3.AlarmEvent-',
#   'action' => '1',
#   'severity' => '0'
#
