perl File::Tail not reading lines from file after certain period -
i having issues understanding why file::tail fails read lines updating file 1000s of transactions, , automatic rollover .
it read extend correctly, later slows down, , long period not able read lines in logs. can confirm actual log being populated when file::tail shows nothing.
my $file = file::tail->new(name=>"$name", tail => 1000, maxinterval=>1, interval=>1, adjustafter=>5,resetafter=>1, ignore_nonexistant=>1, maxbuf=>32768); while (defined(my $line=$file->read)) { #my $line=$file->read; $xml_string = ""; #### read 1 event per line , deal xml. #### if log entry not slim log, ignore it. if ($line =~ /(\<slim\-log\>.*\<\/slim\-log\>)/) { do_something } else { not_working reason }
can please me understand this. know log file updated @ 10mb per second or 1000 events per second approximation.
should handing filehandle or file::tail results other more efficient way?
seems there's limitations in file::tail. there's suggestions around other more direct options (a pipe, fork, thread, seeking end of file in perl) discussed in http://www.perlmonks.org/?node_id=387706.
my favorite pick blocking read pipe:
open(tail, "tail -f $name|") or die "tail : $!"; while (<tail>) { test_and_do_something }
Comments
Post a Comment