---End Source------Source --- #!/usr/bin/perl -w use strict; use File::Tail; $|=1; my @ports = (10290,10291,10292,10293,10294,10295,10298); my @logs; foreach my $port (@ports) { my $file = "/usr/local/qpxlocal/log/act*" . $port . ".log"; my @files = `/bin/ls -r $file`; if($files[0] ne "") { chomp $files[0]; push(@logs,$files[0]); print "Push $files[0]\n"; }else{ print "Log file for $port is missing!\n"; } } my @files_to_tail; my $debug; foreach (@logs) { push(@files_to_tail,File::Tail->new(name=>"$_",debug=>"1",maxinter +val=>"1",i nterval=>"1", errmode=>"warn",reset_tail=>"-1")); } while(1) { my ($nfound,$timeleft,@pending)=File::Tail::select(undef,undef,und +ef,2,@file s_to_tail); unless($nfound) { my @ints; foreach(@files_to_tail) { push(@ints,$_->interval); } print "Nothing new in the past 1 seconds (" . join(",",@ints) +. ")\n"; } foreach (@pending) { my $file_name = $_->{'input'}; my $read_data = $_->read; $file_name =~ /.+(\d{5})\.log/; my $port = $1; print "$port: $read_data";# unless $_->predict; } }
--Begin output---
>perl big_log Push /usr/local/qpxlocal/log/activity-200104192022-av2J15-10290.log Push /usr/local/qpxlocal/log/activity-200104192022-av2J15-10291.log Push /usr/local/qpxlocal/log/activity-200104192022-av2J15-10292.log Push /usr/local/qpxlocal/log/activity-200104192022-av2J15-10293.log Push /usr/local/qpxlocal/log/activity-200104192022-av2J15-10294.log Push /usr/local/qpxlocal/log/activity-200104192022-av2J15-10295.log Push /usr/local/qpxlocal/log/activity-200104192022-av2J15-10298.log Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1) 10290: [20010419 20:22z] AVS started on port 10290 of av2J15.eg.orbitz +.com [av2J15:10290] 10291: [20010419 20:22z] AVS started on port 10291 of av2J15.eg.orbitz +.com [av2J15:10291] 10298: [20010419 20:23z] ERROR: zero-length command received, or timeo +ut (ignored) 10298: [20010419 20:23z] an error occurred processing the last command +: return code -1. 10298: [20010419 20:25z] [987711918182] Flight V0 Cache count= 941 tim +eout= 1000 local= 0 remote= 941 returned= 522 elapsed= 106.61 Nothing new in the past 1 seconds (1,1,1,1,1,1,1) 10290: [20010419 20:27z] [987712053494] Flight V0 Cache count= 712 tim +eout= 1000 local= 0 remote= 712 returned= 336 elapsed= 95.03 Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1) 10290: [20010419 20:27z] [987712057676] Flight V0 Cache count= 712 tim +eout= 1000 local= 0 remote= 712 returned= 264 elapsed= 118.06 Nothing new in the past 1 seconds (1,1,1,1,1,1,1) 10290: [20010419 20:27z] [987712061014] Flight V0 Cache count= 712 tim +eout= 1000 local= 0 remote= 712 returned= 376 elapsed= 92.58 Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1) Nothing new in the past 1 seconds (1,1,1,1,1,1,1)
In reply to File::Tail Issue by neb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |