#!/opt/bin/perl -I/opt/ras/lib

use Report;
use Util;

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

$reps = Report->readAllReports();

foreach $r (@$reps) {
  print $r->name() . "\n";
}

%M = (Jan => 1, Feb => 2, Mar => 3, Apr => 4, May => 5, Jun => 6,
      Jul => 7, Aug => 8, Sep => 9, Oct =>10, Nov => 11,Dec => 12);


open(O, "/var/adm/messages");

while ($l = <O>) {
  chop($l);
  if ($l =~ /\@w[0-9a-f]+/) { 
    $wwn = substr($1,2);
    if ($l =~ /(offline)/ || ($l =~ /(WARNING)/) )) {
      $type = $1;
      @a = split(/ +/, $l);
      $month = $M{$a[0]};
      $day = $a[1];

      foreach $r (@$reps) {
         $v = $r->value();
         foreach $i (keys %$v) {
             if ($v->{$i} =~ /$wwn/) {
                print "$wwn : $type, $i," . $r->name() . "," . $r->category() ."\n";
             }
         }
      }
    }
  }
}
close(O);


