Slide 41
Slide 41 text
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
while(1){
open(my $fh, "-|", "tail","-5000","/var/log/nginx/access.log") or die $!;
my %path_query;
while(<$fh>){
if ( m!pre-cacher! ) { next }
if ( $_ !~ m!(cachemode=readahead|group.limit)! ) { next }
if ( m!\suri:(.+?)\s! ){
$path_query{"$1"} = 1;
}
}
my $ua = LWP::UserAgent->new(agent=>”pre-cacher");
$ua->timeout(20);
for my $path_query ( keys %path_query ) {
my $req = HTTP::Request->new(
GET => ‘http://localhost' . $path_query
);
$req->header('Host'=>'lb-search');
$ua->request($req);
}
sleep 5;
}