Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Daemon startup time logged

it'll probably be actually very useful for such a small change
  • Loading branch information...
commit d46055624745e1932b9b64d10d057fc4b22fe9fd 1 parent 1fe1455
Olivier Bilodeau obilodeau authored
Showing with 12 additions and 1 deletion.
  1. +1 −0  NEWS
  2. +2 −0  addons/packages/packetfence.spec
  3. +9 −1 lib/pf/services.pm
1  NEWS
View
@@ -27,6 +27,7 @@ Enhancements
* Slightly more helpful installer.pl
* Added a virtual IP (vip) parameter for interfaces in configuration which overrides auto-detection (#1396)
* More logging
+ * Daemon startup time logged. Allows for easier troubleshooting of slow-to-restart setups.
Bug Fixes
* Proxy Bypass issues in environment with Virtual IP (#1385)
2  addons/packages/packetfence.spec
View
@@ -80,6 +80,8 @@ Requires: perl(File::Tail)
Requires: perl(IPC::Cmd)
Requires: perl(IPTables::ChainMgr)
Requires: perl(IPTables::Parse)
+# Perl core modules but still explicitly defined just in case distro's core perl get stripped
+Requires: perl(Time::HiRes)
# Required for inline mode. Specific version matches system's iptables version.
# CentOS 5 (iptables 1.3.5)
%{?el5:Requires: perl(IPTables::libiptc) = 0.14}
10 lib/pf/services.pm
View
@@ -28,6 +28,7 @@ use File::Basename;
use IPC::Cmd qw[can_run run];
use Log::Log4perl;
use Readonly;
+use Time::HiRes;
use Try::Tiny;
use UNIVERSAL::require;
@@ -141,7 +142,11 @@ sub service_ctl {
my $cmd_line = "$service $flags{$daemon}";
if ($cmd_line =~ /(.+)/) {
$cmd_line = $1;
- return ( system($cmd_line) );
+ my $t0 = Time::HiRes::time();
+ my $return_value = system($cmd_line);
+ my $elapsed = Time::HiRes::time() - $t0;
+ $logger->info(sprintf("Daemon $exe took %.3f seconds to start.", $elapsed));
+ return $return_value;
}
} else {
if ( isenabled( $Config{'network'}{'dhcpdetector'} ) )
@@ -156,7 +161,10 @@ sub service_ctl {
$logger->info(
"Starting $exe with '$cmd_line'"
);
+ my $t0 = Time::HiRes::time();
system($cmd_line);
+ my $elapsed = Time::HiRes::time() - $t0;
+ $logger->info(sprintf("Daemon $exe took %.3f seconds to start.", $elapsed));
}
}
return 1;
Please sign in to comment.
Something went wrong with that request. Please try again.