Skip to content

Commit

Permalink
Time how long reports take to run
Browse files Browse the repository at this point in the history
  • Loading branch information
skarfacegc committed Feb 14, 2015
1 parent a8b1ad6 commit ec93430
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions FlowTrack.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Carp;
use Getopt::Long;
use Data::Dumper;
use Time::HiRes qw ( gettimeofday tv_interval);

use FT::Configuration;
use FT::FlowCollector;
Expand Down Expand Up @@ -191,7 +192,7 @@ sub startWebserver
my $daemon = Mojo::Server::Daemon->new( listen => [ 'http://*:' . $config->{web_port} ] );
my $app = FT::FlowTrackWeb->new();

$app->secrets(['3305CA4A-DE4D-4F34-9A38-F17E0A656A25']);
$app->secrets( ['3305CA4A-DE4D-4F34-9A38-F17E0A656A25'] );
$daemon->app( FT::FlowTrackWeb->new() );
$daemon->run();

Expand All @@ -206,8 +207,8 @@ sub startWebserver
# in time.
sub runReports
{
my $logger = get_logger();
my $config = FT::Configuration::getConf();
my $logger = get_logger();
my $config = FT::Configuration::getConf();
my $reports = FT::Reporting->new($config);

while (1)
Expand All @@ -216,7 +217,10 @@ sub runReports
sleep( ( $config->{reporting_interval} * 60 ) - ( time % ( $config->{reporting_interval} * 60 ) ) );

$logger->info('Running report');

my $start_time = [gettimeofday];
$reports->runReports();
$logger->info( 'Reporting took: ' . tv_interval($start_time) );

sleep( $config->{reporting_interval} * 60 );
}
Expand All @@ -234,14 +238,14 @@ sub savePIDFile
if ( -w $config->{pid_files} )
{
open( my $fh, ">", $config->{pid_files} . "/$process.pid" )
|| $logger->logconfess("Couldn't open " . $config->{pid_files} . "/$process.pid: $!");
|| $logger->logconfess( "Couldn't open " . $config->{pid_files} . "/$process.pid: $!" );
print $fh "$pid\n";
close($fh);

}
else
{
$logger->logconfess($config->{pid_files} . " is either missing or not writable");
$logger->logconfess( $config->{pid_files} . " is either missing or not writable" );
}

return;
Expand Down

0 comments on commit ec93430

Please sign in to comment.