Skip to content

Commit

Permalink
Report actual time taken for each request.
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe M. Chiasson committed Aug 9, 2014
1 parent b173a8a commit 73637da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sentry/README
Expand Up @@ -10,4 +10,4 @@ perl-DBI
perl-libwww-perl
perl-Net-DNS
perl-DBD-mysql

perl-Time-HiRes
11 changes: 8 additions & 3 deletions sentry/sentry.pl
Expand Up @@ -11,6 +11,7 @@
use LWP::UserAgent::Determined;
use Net::DNS;
use URI;
use Time::HiRes qw(gettimeofday tv_interval);

use vars qw( $dbi::errstr );
my $start_timestamp = time;
Expand Down Expand Up @@ -259,18 +260,22 @@ sub log_this {
# allow 1 redirect
$ua->max_redirect(1);

my $start = [gettimeofday];
my $res = $ua->request($req);
my $elapsed = tv_interval($start);

my $took = " TOOK=$elapsed";

if (( $res->{_rc} == 200 ) && ( $res->{_headers}->{'content-type'} !~ /text\/html/ )) {
log_this "okay.\n";
log_this "okay.$took\n";
$update_sth->execute($location->{id}, $mirror->{id}, '1', '1');
}
elsif (( $res->{_rc} == 404 ) || ( $res->{_rc} == 403 )) {
log_this "FAILED. rc=" . $res->{_rc} . "\n";
log_this "FAILED. rc=" . $res->{_rc} . "$took\n";
$update_sth->execute($location->{id}, $mirror->{id}, '0', '0');
}
else {
log_this "FAILED. rc=" . $res->{_rc} . "\n";
log_this "FAILED. rc=" . $res->{_rc} . "$took\n";
$update_sth->execute($location->{id}, $mirror->{id}, '1', '0');
}

Expand Down

0 comments on commit 73637da

Please sign in to comment.