use Time::local; $ccdrive = $ENV{CC_DEFAULT_DRIVE}; $file = "whatever"; $upsitesynckey = "SyncState X"; $downsitesynckey = "SyncState Y"; $upsitereplicakey = "Replica for X"; $downsitereplicakey = "Replica for Y"; my @newtime; my $htmlpath='synccheck.htm'; my $logfile='synccheck.log'; my $maxtime; my %month = (Jan => 0, Feb => 1, Mar => 2, Apr => 3, May => 4, Jun => 5, Jul => 6, Aug => 7, Sep => 8, Oct => 9, Nov => 10, Dec => 11); #Define some colors... my $GRN="#00FF00"; my $YEL="#FFFF00"; my $RED="#FF0000"; my $GRY="#808080"; my $curcolor=$GRN; my %rephash; open(TFILE2,">$htmlpath") || die "Can't open $htmlpath"; # Print the html header section. print TFILE2 < SyncCheck

 

Sync Check Summary

/font>

 

WEB_PAGE # Handle the "Last Update" my $time=localtime(time); print TFILE2 "

Last update: $time


\n"; open (FILE, "$file") || die "Can't open $file"; $tmp=; foreach(split(/\t/,$tmp)){ push(@hashkeys, $_); } while () { $tmp=$_; @config=split(/\t/,$tmp); $idx=0; #Combine the two arrays into a hash. Taking the long way around, here. foreach(@config){ $vobhash{$hashkeys[$idx]}=$_; $idx++; } #Clear out the arrays. @config=(""); # Get a more accurate vob tag. $name=$hash{"Tag"}; #If the syncstate of a site has an X or "EXPORT", Add its replica to the list. if(uc($vobhash{$upsitesynckey}) eq "X" || uc($hash{$upsitesynckey}) eq "EXPORT"){ push(@replicas, $hash{$upsitereplicakey}); push(@vobs, $vobname); } if(uc($vobhash{$downsitesynckey}) eq "X" || uc($vobhash{$downsitesynckey}) eq "EXPORT"){ push(@replicas, $vobhash{$downsitereplicakey}); push(@vobs, $vobname); } %vobhash = (""); } close (FILE); $idx=0; foreach $replica (@replicas) { $cmd="cleartool describe replica:$replica\@\\$vobs[$idx]"; $time=`$cmd`; $time =~ /last_export = /g; $time=substr($time, pos($time), length($time)-pos($time)); $idx++; @timelocal = localtime(time); $day=substr($time, 0, 2); $mon=substr($time, 3, 3); $year="20".substr($time, 7, 2); $hour=substr($time, 10, 2); $min=substr($time, 13, 2); $sec=substr($time, 16, 2); # Convert the month abbreviation to a number (0-11). Use separate variable. $mon = $month{$mon}; @newtime=($sec, $min, $hour, $day, $mon, $year, undef, undef, undef); #print "$mon\n"; $x=Time::Local::timelocal(@timelocal); $y=Time::Local::timelocal(@newtime); $z=$x-$y; #print "$x $y $z\n"; my $durhours=int($z/3600); $z-=($durhours*3600); my $durmins=int($z/60); $z-=($durmins*60); my $dursecs=$z; #$rephash{$replica}=$durhours; #$rephash=("$replica"=>"$durhours","durhours"=>"$curcolor"); if ($durhours < 3) { $curcolor = "$GRN"; } if ($durhours >= 3 && $maxtime < 7 ) { $curcolor = "$YEL"; } if ($durhours > 7 ) { $curcolor = "$RED"; } if ($durhours > $maxtime) { $maxtime = $durhours; } %rephash=($replica=>"$curcolor"); #print "$rephash{$replica}\n"; if ($replica =~ /ABC/g) { push (@ABC, $replica); } if ($replica =~ /DEF/g || $replica =~ /whatever/g) { push (@DEF, $replica); } } $idx=0; $ref1 = @ABC; $ref2 = @DEF; print TFILE2 ""; # while ($idx < @ABC || $idx < @DEF) { print TFILE2 " "; if ($idx1 <= $ref2) { #chomp($DEF[$idx]); #print TFILE2 "" ; print TFILE2 " "; #print "%rephash{$DEF[$idx]}\n"; } if ($idx1 <= $ref1) { #chomp($ABC[$idx]); #print TFILE2 " "; print TFILE2 " "; } print TFILE2 ""; $idx++; } print TFILE2 "
$vobs[$idx] $rephash{$replica} $DEF[$idx]  $vobs[$idx] $ABC[$idx] 
";