package Monitor::OV;

require 5.001;

use strict;
use vars qw(@ISA @EXPORT $VERSION);
use Monitor::logfile;

@ISA = qw(Monitor::logfile);


sub create {
    ;
}


sub decode {
    my( $self, $line ) = @_;
    my( $tmp1, $tmp2, $part1, $part2, $tmp3, $message, $timestamp, $cat );
    my( $wday,$month,$day,$time,$year,$source, $sev, $eventoid, $ovobjid );
    my( $readline );

    print "OV: decodeing ".$line."\n" if( $BigSister::common::dl>7 );
    $readline = $line;
    ($tmp1,$tmp2) = split(/\t/,$readline);
    ($part1,$part2) = split(/\;/,$tmp2);
    ($tmp3) = split(/\;/,$tmp2);
    $message = substr($tmp3,2,length($tmp3));
    ($timestamp,$cat,$wday,$month,$day,$time,$year,$source) = split(/\s+/,$tmp1);
    ($sev,$eventoid,$ovobjid) = split(/\s+/,$part2);
    $_ = $message;
    if( $message =~ /System name changed \(was ([^\)]+)\)/ ) {
	my $name = $1;
	if( $source =~ /^[\d\.]+$/ ) {
	    $self->{"translations"}->{$source} = $name;
	}
	elsif( $name =~ /^[\d\.]+$/ ) {
	    $self->{"translations"}->{$name} = $source;
	    if( $self->{"stati"}->{$name} ) {
		$self->{"stati"}->{$source} = $self->{"stati"}->{$name};
		delete $self->{"stati"}->{$name};
	    }
	}
    }
    return( $timestamp, $message, $source );
}

1;
