| Server IP : 20.75.53.88 / Your IP : 216.73.217.72 [ Web Server : Apache System : Linux VMRALP-3 4.4.0-256-generic #290~14.04.1-Ubuntu SMP Thu Jun 20 09:24:50 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29+esm15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Domains : 3 Domains MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/sbin/ |
Upload File : |
#! /usr/bin/perl -w
die "perl5 needed\n" unless ($] > 5);
use Getopt::Std;
$opt_n = 1000; # How many tries before we give up? (10 min+)
$opt_s = 6; # Seconds to sleep between tries (6s = 10/min)
$opt_v = 0; # Be verbose?
getopts('n:s:v');
$cmd = 'ntpq -c "rv 0"';
$| = 1; # Autoflush output.
print "Waiting for ntpd to synchronize... " if ($opt_v);
for ($i = 0; $i < $opt_n; ++$i) {
open(Q, $cmd." 2>&1 |") || die "Can't start ntpq: $!";
while(<Q>) {
chomp;
# the first line should be similar to:
# associd=0 status=0645 leap_none, sync_ntp, ...
if (/^associd=0 status=(\S{4}) (\S+), (\S+),/) {
my $status = $1;
my $leap = $2;
my $sync = $3;
# print $_;
# print "status <$status>, leap <$leap>, sync <$sync>\n";
last if ($leap =~ /(sync|leap)_alarm/);
if ($leap =~ /leap_(none|((add|del)_sec))/) {
# We could check $sync here to make sure we like the source...
print "\bOK!\n" if ($opt_v);
exit 0;
}
print "\bUnexpected 'leap' status <$leap>\n";
exit 1;
}
if (/Connection refused/) {
print "\bntpd is not running!\n" if ($opt_v);
exit 1;
}
# Otherwise, we have a bigger problem.
print "\bUnexpected first line <$_>\n";
exit 1;
}
close(Q);
print "\b".substr("*+:.", $i % 4, 1) if ($opt_v);
sleep($opt_s);
}
print "\bNo!\nntpd did not synchronize.\n" if ($opt_v);
exit 1;