Thanks much for your infinite wisdom:)#!/usr/local/bin/perl use strict; my (@list) #DRACSTAT is nothing more than a text file which is appended to everyt +ime a job is # launched, it gives information about the type of job, where it was r +un, etc. chdir(); open (DRACSTAT, "<.dractrack") or die "Can't open drackstat.."; while (<DRACSTAT>){ chomp $_; push (@list, $_); } close DRACSTAT; # For each line run the log checker. Ideally, I would do this in parr +allel for # each item for (my $i=0; $i<@list; $i++){ &CheckStat($list[$i]); chdir(); open (DRACNEW, ">>.dracnew") or die "I think dracktrack is running"; # as you get done remove that item from the list.. for (my $j=$i; $j+1<@list; $j++){ print DRACNEW "$list[$j+1]\n"; print "$list[$j+1]\n"; } rename (".dracnew", ".dractrack") or die "Can't replace .dracktrack. +."; } sub CheckStat { my (%drac, @stages, @lstage); my $tmp = shift; # this is the line from DRACSTAT ($drac{Type},$drac{primary},$drac{rundir},$drac{printfile},$drac{hos +tname}) = split / /, $tmp , 5; chdir($drac{rundir}); # This just gets the total number of stages in a particular job open (STAGES, "jxrun.stg") or die "Can't open jxrun.stg"; while (<STAGES>){ chomp $_; @stages = split /\b/, $_; } close STAGES; my $percomp = 0; while ($percomp != 100){ # This is the actual logfile which we are continually monitoring.. open (LOGFILE, "<$drac{printfile}"."."."log") or die "Can't open $ +drac{printfile}.log"; while(<LOGFILE>){ chomp $_; next if ($_ !~ m/AT STAGE:/); @lstage = split /\s+/, $_; } close LOGFILE; my $percomp = ($lstage[3]/$stages[8])*100; # Give'm stats - I don't like the /r but it works -- any better i +deas? if ($percomp == 100){ print "\n$drac{Type} job $drac{primary} on $drac{hostname} -- DO +NE\n"; return; } else { print "Cell: $drac{primary} Verifying: $drac{type} Total Stages: + $stages[8] Number complete: $lstage[3] -- "; printf ("%2.2f\%\r", $percomp); } } }
The <it>seeker</it> of perl wisdom. In reply to Is this the most efficient way to monitor log files..
by Rhodium
For:
Use:
& & < < > > [ [ ] ]