system peer: 94-246-113-188.isp.djdata.se
system peer mode: client
leap indicator: 00
stratum: 3
precision: -23
root distance: 0.04117 s
root dispersion: 0.05130 s
reference ID: [94.246.113.188]
reference time: d95fccb6.9c21530b Sun, Jul 26 2015 23:16:38.609
system flags: auth monitor ntp kernel stats
jitter: 0.001999 s
stability: 0.000 ppm
broadcastdelay: 0.000000 s
authdelay: 0.000000 s
####
stratum
leap indicator
precision
last sync
NTP server
poll interval
####
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
if ( $^O eq 'MSWin32' ) {
}
elsif ( $^O eq 'WinXP' ) {
}
else {
my @ntpdate_tmp = `ntpdc -c sysinfo`;
my %ntpdc = setKeyAndValue(@ntpdate_tmp);
($ntpdc{"reference time"}, $ntpdc{"tmp"}) = split(/ /, $ntpdc{"reference time"}, 2);
delete $ntpdc{"tmp"};
( $ntpdc{"Reference Timestamp Sec"},
$ntpdc{"Reference Timestamp Micro Sec"} ) = split(/\./,$ntpdc{"reference time"});
delete $ntpdc{"reference time"};
$ntpdc{"Reference Timestamp Sec"} =
hex($ntpdc{"Reference Timestamp Sec"}) - 2208988800;
$ntpdc{"Reference Timestamp Micro Sec"} = hex($ntpdc{"Reference Timestamp Micro Sec"});
chop($ntpdc{"root distance"});
chop($ntpdc{"root dispersion"});
($ntpdc{"root dispersion sec"}, $ntpdc{"root dispersion fraction"}) = split(/\./,$ntpdc{"root dispersion"});
($ntpdc{"root distance sec"}, $ntpdc{"root distance fraction"}) = split(/\./,$ntpdc{"root distance"});
print Dumper \%ntpdc;
}
sub setKeyAndValue {
my @KeyAndValue = @_;
@KeyAndValue = map { s/^\s+|\s+$//g; $_; } @KeyAndValue;
my @ntpdc = ();
foreach my $element (@KeyAndValue) {
$element =~ s/\s\s+/ /g;
push @ntpdc, split(/: /, $element, 2);
}
my %ntpdcTmp = @ntpdc;
return %ntpdcTmp;
}
__END__
$VAR1 = {
'Reference Timestamp Micro Sec' => 276843474,
'stability' => '0.000 ppm',
'system peer mode' => 'client',
'root distance' => '0.03453 ',
'root distance sec' => '0',
'Reference Timestamp Sec' => 1438043541,
'reference ID' => '[94.246.113.188]',
'authdelay' => '0.000000 s',
'root distance fraction' => '03453 ',
'precision' => '-23',
'root dispersion fraction' => '04585 ',
'broadcastdelay' => '0.000000 s',
'stratum' => '3',
'system peer' => '94-246-113-188.isp.djdata.se',
'system flags' => 'auth monitor ntp kernel stats',
'root dispersion' => '0.04585 ',
'root dispersion sec' => '0',
'leap indicator' => '00',
'jitter' => '0.000504 s'
};
####
$VAR1 = {
'leapindicator' => '00',
'rootdispersion' => '0.05389s',
'rootdistance' => '0.03000s',
'systempeer' => '94-246-113-188.isp.djdata.se',
'systemflags' => 'authmonitorntpkernelstats',
'authdelay' => '0.000000s',
'stability' => '0.000ppm',
'jitter' => '0.002380s',
'systempeermode' => 'client',
'precision' => '-23',
'stratum' => '3',
'referenceID' => '[94.246.113.188]',
'referencetime' => 'd95fd604.9bccbe66Sun,Jul26201523:56:20.608',
'broadcastdelay' => '0.000000s'
};
####
$VAR1 = {
'systemflags' => 'authmonitorntpkernelstats',
'rootdistance' => '0.02570s',
'referenceID' => '[83.168.200.199]',
'broadcastdelay' => '0.000000s',
'precision' => '-23',
'jitter' => '0.001984s',
'systempeermode' => 'client',
'stability' => '0.000ppm',
'systempeer' => 'ntp3.flashdance.cx',
'leapindicator' => '00',
'authdelay' => '0.000000s',
'stratum' => '3',
'rootdispersion' => '0.04956s',
'referencetime' => 'd95fc917.9be1e269Sun,Jul26201523',
'01' => '11.608'
};