# Get today's date which will be used as the default. my($day, $month, $year) = (localtime)[3,4,5]; $month = sprintf '%02d', $month+1; $day = sprintf '%02d', $day; $year = $year+1900; $ymd = "$year-$month-$day"; my $total; # variable to be used for queue total for the given timeframe my $count = 0; ## Get command line arguments, convert time to seconds ##my $logFile = "pmmd-ltc-fsrlabs21-mdrc-server-cta.log"; my $logFile = "pmmd-ltc-fsrlabs41-mdrc-server-ice.log"; my $sTime= $ARGV[0]; my @sTime=split(/:/,$sTime); # split start time my $sSecs=$sTime[0] * 3600 + $sTime[1] * 60 + $sTime[2]; # convert start-time to seconds my $eTime = $ARGV[1]; my @eTime=split(/:/,$eTime); # split end time my $eSecs=$eTime[0] * 3600 + $eTime[1] * 60 + $eTime[2]; # convert stop-time to seconds my $tHold = $ARGV[2]; open(LOG, "$logFile") or die "Couldn't open file for processing: $!"; while ( $line = ) { unless (($data[10] =~ m/Pending=/) || ($data[6] =~ m/Gap/)) { next; } # skip elements we don't want if ($line =~ m/Pending=/) { my @data=split(/ /,$line); # split the line up $data[10] =~ s/[A-Za-z=.]//g; # delete "Pending", "=" and "." $data[1] =~ s/\..*//g; # delete the millisecond element of the (line)lTime var my @lTime=split(/:/,$data[1]); # split the line time my $lSecs=$lTime[0] * 3600 + $lTime[1] * 60 + $lTime[2]; # convert line-time to seconds if (($data[0] eq $ymd) && ($data[10] >= $tHold) && ($lSecs >= $sSecs) && ($lSecs <= $eSecs)) { $line = "$data[1],$data[10]"; } } elsif ($line =~ m/Gap detect/) { my @data=split(/ /,$line); # split the line up $data[1] =~ s/\..*//g; # delete the millisecond element of the (line)lTime var my @lTime=split(/:/,$data[1]); # split the line time my $lSecs=$lTime[0] * 3600 + $lTime[1] * 60 + $lTime[2]; # convert line-time to seconds if (($data[0] eq $ymd) && ($lSecs >= $sSecs) && ($lSecs <= $eSecs)) { $line = "$data[1],$data[9]"; } } else { next; } ($time, $rest) = split ',', $line, 2; #$time =~ s/\..*//g; # delete the millisecond element @fields = split ',', $rest; $HoA{$time} = [ @fields ]; } for $time (sort (keys (%HoA)) ) { print "$time: @{ $HoA{$time} }\n"; } close LOG;