<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Cain Manor &#187; NTP</title> <atom:link href="http://cainmanor.com/tag/ntp/feed/" rel="self" type="application/rss+xml" /><link>http://cainmanor.com</link> <description>Your Guide To All Things Cain™</description> <lastBuildDate>Thu, 17 May 2012 19:43:34 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>Various Time Scripts</title><link>http://cainmanor.com/tech/unix/various-time-scripts/</link> <comments>http://cainmanor.com/tech/unix/various-time-scripts/#comments</comments> <pubDate>Wed, 01 Apr 2009 22:40:40 +0000</pubDate> <dc:creator>Greg Cain</dc:creator> <category><![CDATA[UNIX]]></category> <category><![CDATA[CentOS]]></category> <category><![CDATA[NTP]]></category> <category><![CDATA[time]]></category><guid
isPermaLink="false">http://cainmanor.com/tech/unix/various-time-scripts</guid> <description><![CDATA[To see the offset for a range of system for X in `cat YourList.txt` do Y=`ssh $X -l root 'ntpdate -q 10.168.XX.XX' &#124; awk -F, '{print $3}'` echo $X $Y done Your output HOST1 offset 0.007304 HOST2 offset 0.044396 HOST3 offset 0.038323 HOST4 offset 274.636170 HOST5 offset 189.366374 To see how far your servers are [...]]]></description> <content:encoded><![CDATA[<p>To see the offset for a range of system</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> X <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> YourList.txt<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #007800;">Y</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$X</span> <span style="color: #660033;">-l</span> root <span style="color: #ff0000;">'ntpdate -q 10.168.XX.XX'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> -F, <span style="color: #ff0000;">'{print $3}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$X</span> <span style="color: #007800;">$Y</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div><p><span
id="more-539"></span><br
/> Your output</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">HOST1 offset <span style="color: #000000;">0.007304</span>
HOST2 offset <span style="color: #000000;">0.044396</span>
HOST3 offset <span style="color: #000000;">0.038323</span>
HOST4 offset <span style="color: #000000;">274.636170</span>
HOST5 offset <span style="color: #000000;">189.366374</span></pre></div></div><p>To see how far your servers are from the NTP source</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> X <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> YourList.txt<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #007800;">Y</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$X</span> <span style="color: #660033;">-l</span> root <span style="color: #ff0000;">'ntpdc -c loopinfo'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> offset<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$X</span> <span style="color: #007800;">$Y</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div><p>Output</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">HOST1 offset: <span style="color: #000000;">0.009959</span> s
HOST2 offset: <span style="color: #000000;">0.042295</span> s
HOST3 offset: <span style="color: #000000;">0.038320</span> s
HOST4 offset: <span style="color: #000000;">0.000000</span> s
HOST5 offset: <span style="color: #000000;">0.000000</span> s</pre></div></div><p>0.000000 s means you haven&#8217;t picked up an authoritative time source yet.</p> ]]></content:encoded> <wfw:commentRss>http://cainmanor.com/tech/unix/various-time-scripts/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>NTP Client Setup</title><link>http://cainmanor.com/tech/ntp-client-setup/</link> <comments>http://cainmanor.com/tech/ntp-client-setup/#comments</comments> <pubDate>Fri, 27 Mar 2009 02:07:54 +0000</pubDate> <dc:creator>Greg Cain</dc:creator> <category><![CDATA[Tech]]></category> <category><![CDATA[UNIX]]></category> <category><![CDATA[NTP]]></category><guid
isPermaLink="false">http://cainmanor.com/tech/ntp-client-setup</guid> <description><![CDATA[This document serves two purposes. The first is to document the setup of an NTP client (not an NTP server.) The second is to allow other to see how to monitor NTP. Enable syncing with upstream servers from your NTP source. These settings are set in /etc/ntp.conf # Use public servers from the pool.ntp.org project. [...]]]></description> <content:encoded><![CDATA[<p>This document serves two purposes. The first is to document the setup of an NTP client (not an NTP server.) The second is to allow other to see how to monitor NTP.</p><p>Enable syncing with upstream servers from your NTP source.  These settings are set in /etc/ntp.conf</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;"># Use public servers from the pool.ntp.org project.
# Please consider joining the pool <span style="color: #33cc33;">(</span>http://www.pool.ntp.org/join.html<span style="color: #33cc33;">)</span>.
# Limiting to three servers as requested by pool.ntp.org
server myTIME01.domain.com
server myTIME02.domain.com</pre></div></div><p><span
id="more-535"></span>Now we need to make sure our time is somewhat accurate &#8211; within a minute or so.  But before we do that we have to stop the ntpd daemon.</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">service ntpd stop</pre></div></div><p>Now sync time</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">ntpdate -u qantp01.qa.testlab.com</pre></div></div><p>Make sure the NTP daemon is enabled</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">chkconfig --list ntpd
ntpd           	0:off	1:off	2:off	3:off	4:off	5:off	6:off</pre></div></div><p>If it&#8217;s not, enable it</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">chkconfig --level 2345 ntpd on</pre></div></div><p>and verify</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">chkconfig --list ntpd
ntpd           	0:off	1:off	2:on	3:on	4:on	5:on	6:off</pre></div></div><p>And restart the daemon</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">service ntpd start</pre></div></div><p>Now we need to make sure time is syncing correctly.  We can do this with ntpq \-p (or use \-np for ip&#8217;s, and not names.) This provided you with a list of time servers and the delay, offset and jitter that your server is experiencing with them. The delay and offset values should be non-zero and the jitter value should be under 100.  The times are in milliseconds (1/1000 of a second.)  The important thing to look for is the * you see in the first line.  The * means you are syncing with a server on the internet.  If you don&#8217;t see it right away, wait a few minutes and try again.  It may take up to 15 minute for the local clock to get in sync with the remote server.  Patience is your friend.</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">ntpq -p
     remote           refid      st t when poll reach   delay   offset  <span style="color: #448844;">jitter</span>
==============================================================================
*qantp01.qa.test 209.20.66.253    3 u  113  256  377    0.165   -2.251   2.791
 LOCAL<span style="color: #33cc33;">(</span>0<span style="color: #33cc33;">)</span>        .LOCL.          10 l   27   64  377    0.000    0.000   0.001</pre></div></div><p>The first character in the leftmost column indicates the status of the peer, followed by the name or IP of the peer</p><blockquote><p>&#8220;*&#8221; selected for synchronization<br
/> &#8220;o&#8221; selected for synchronization, PPS signal in use.<br
/> &#8220;+&#8221; included in the final selection set;<br
/> &#8220;sp&#8221; discarded as unreachable, synchronized to this server (synch loop) or outrageous synchronization distance;<br
/> &#8220;x&#8221; designated falsticker by the intersection algorithm;<br
/> &#8220;.&#8221; culled from the end of the candidate list;<br
/> &#8220;-&#8221; discarded by the clustering algorithm;<br
/> &#8220;#&#8221; selected for synchronization but distance exceeds maximum;The third column (st) is the stratum of your peer.  LOCAL is a loopback address used for when no other clocks are available, and has a default setting of 10.  Valid values are between 1 and 15.  A value of 16 is a invalid stratum value representing &#8220;this server is not considered as a time provider&#8221;. This can be for various reasons, the most common reasons are &#8220;time provider not synchronized&#8221;, &#8220;configured source does not exist&#8221; or &#8220;ntp server not running&#8221;.</p></blockquote><p>The fourth column indicates the type of server it is, and isn&#8217;t of much concern.</p><blockquote><p>l = local (such as a GPS, WWVB)<br
/> u = unicast (most common)<br
/> m = multicast<br
/> b = broadcast<br
/> - = netaddr</p></blockquote><p>The seventh column indicates reach, and should be at 377. An explanation of why from <a
title="Linux Journal" href="http://www.linuxjournal.com/article/6812">Linux Journal</a></p><blockquote><p>Each remote server or peer is assigned its own buffer by ntpd. This buffer represents the status of the last eight NTP transactions between the NTP daemon and a given remote time server. Each bit is a boolean value, where a 1 indicates a successful transaction and a 0 indicates a failure. Each time a new packet is sent, the entire eight-bit register is shifted one bit left as the newest bit enters from the right.<br
/> The net result is that dropped packets can be tracked over eight poll intervals before falling off the end of the register to make room for new data. This recycling of space in the register is why it&#8217;s called a circular buffer, but it may make more sense to think of it in linear terms, as a steady, leftward march&#8211;eight small steps, and then the bit ends up wherever bits go when they die.<br
/> For reasons that seemed good to the developers, this register is displayed to the user in octal values instead of binary, decimal or even hex. The maximum value of an eight-bit binary number is 11111111, which is 377 in octal, 255 in decimal and 0xFF in hex.</p></blockquote><p>The ninth column indicates offset in milliseconds, and should be less than 150<br
/> If you want to see how accurate your time is, you can use</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">ntpdc -c loopinfo
offset:               -0.064429 s
frequency:            -19.206 ppm
poll adjust:          30
watchdog timer:       175 s</pre></div></div><p>To see the remaining correction</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">[root<span style="color: #33cc33;">@</span>QANTP01 ~]# ntpdc -c kerninfo
pll offset:           4294.91 s
pll frequency:        -19.206 ppm
maximum error:        0.437245 s
estimated error:      0.06018 s
status:               0001  pll
pll time constant:    6
precision:            1e-06 s
frequency tolerance:  512 ppm</pre></div></div><p>You can get the same rough information from ntptime</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">ntptime
ntp_gettime<span style="color: #33cc33;">()</span> returns code 0 <span style="color: #33cc33;">(</span>OK<span style="color: #33cc33;">)</span>
  time cd6e9ff0.43c3e000  Fri, Mar 20 2009 16:06:24.264, <span style="color: #33cc33;">(</span>.264708<span style="color: #33cc33;">)</span>,
  maximum error 468477 us, estimated error 60180 us
ntp_adjtime<span style="color: #33cc33;">()</span> returns code 0 <span style="color: #33cc33;">(</span>OK<span style="color: #33cc33;">)</span>
  modes 0x0 <span style="color: #33cc33;">()</span>,
  offset -60495.000 us, frequency -19.206 ppm, interval 1 s,
  maximum error 468477 us, estimated error 60180 us,
  status 0x1 <span style="color: #33cc33;">(</span>PLL<span style="color: #33cc33;">)</span>,
  time constant 6, precision 1.000 us, tolerance 512 ppm,</pre></div></div><p>To query your time server, but not change it, you can use ntpdate -q.  However, you&#8217;ll need to supply an IP address.  I suggest you use the one with the * when you do an ntpq -np, as that is the one you are using for syncing.</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">ntpdate -q 192.168.106.34
server 192.168.106.34, stratum 3, offset -0.001684, delay 0.02576
26 Mar 16:21:46 ntpdate[23454]: adjust time server 192.168.106.34 offset -0.001684 sec</pre></div></div><p>You can also use ntpdate -d to look at the same information, but with debugging information.</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">ntpdate -q 192.168.106.34
server 192.168.106.34, stratum 3, offset -0.001684, delay 0.02576
26 Mar 16:21:46 ntpdate[23454]: adjust time server 192.168.106.34 offset -0.001684 sec
ntpdate -d 192.168.10.10
26 Mar 16:22:28 ntpdate[23457]: ntpdate 4.2.2p1<span style="color: #33cc33;">@</span>1.1570-o Tue Jun 10 00:07:14 UTC 2008 <span style="color: #33cc33;">(</span>1<span style="color: #33cc33;">)</span>
Looking <span style="color: #00b100; font-weight: bold;">for</span> host 192.168.106.34 and service ntp
host found : <span style="color: #b100b1; font-weight: bold;">qantp01.qa.testlab.com</span>
transmit<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
receive<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
transmit<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
receive<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
transmit<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
receive<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
transmit<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
receive<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
transmit<span style="color: #33cc33;">(</span>192.168.106.34<span style="color: #33cc33;">)</span>
server 192.168.106.34, port 123
stratum 3, precision -20, leap 00, trust 000
refid [192.168.106.34], delay 0.02576, dispersion 0.00000
transmitted 4, <span style="color: #00b100; font-weight: bold;">in</span> filter 4
reference time:    cd7688e3.2844bded  Thu, Mar 26 2009 16:06:11.157
originate timestamp: cd768cb4.2295b2a8  Thu, Mar 26 2009 16:22:28.135
transmit timestamp:  cd768cb4.22fc6972  Thu, Mar 26 2009 16:22:28.136
filter delay:  0.02579  0.02576  0.02579  0.02576
         0.00000  0.00000  0.00000  0.00000
filter offset: -0.00164 -0.00164 -0.00165 -0.00164
         0.000000 0.000000 0.000000 0.000000
delay 0.02576, dispersion 0.00000
offset -0.001646
&nbsp;
26 Mar 16:22:28 ntpdate[23457]: adjust time server 192.168.106.34 offset -0.001646 sec</pre></div></div><p>You can also use ntptrace to watch the system time synchronization (the -n flag turns off name lookups.) This will allow you to follow the time synchronization to it&#8217;s master time source.</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">ntptrace -n 192.168.106.34
192.168.106.34: stratum 3, offset -0.005207, synch distance 0.299721
209.20.66.253: stratum 2, offset 0.004282, synch distance 0.061297
192.5.41.40: stratum 1, offset -0.000018, synch distance 0.000000, refid 'USNO'</pre></div></div><p>If you find you are experiencing trouble (and you&#8217;ve waited more than 15 minutes for your client clock to sync) you can enable more extensive logging.  This is part of the /etc/ntp.conf configuration file.</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;"># These should enable statistics to be kept
statsdir /var/log/ntp/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable</pre></div></div><p>Don&#8217;t forget to make the directory and make it readable by the ntp user (which the ntp daemon runs as.)</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;"><span style="color: #b1b100; font-weight: bold;">mkdir</span> /var/log/ntp/
chown ntp:ntp /var/log/ntp</pre></div></div><p>Now restart ntpd</p><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">service ntpd restart</pre></div></div>]]></content:encoded> <wfw:commentRss>http://cainmanor.com/tech/ntp-client-setup/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 3/6 queries in 0.002 seconds using disk: basic
Object Caching 267/270 objects using disk: basic

Served from: cainmanor.com @ 2012-05-21 19:57:24 -->
