ntpq hangs

Issues related to applications and software problems
Post Reply
rezizter1
Posts: 4
Joined: 2018/04/09 13:34:08

ntpq hangs

Post by rezizter1 » 2018/04/10 05:24:24

Hi
Version: Centos 7
ntp-4.2.6p5-25.el7_3.2.x86_64

Having a strange issue where ntpq -pn takes over a minute to respond.
Everything else on the system is responsive.

We are having this issue on all our Centos 7 boxes running on vmware but not physical boxes in the same subnet

Here is my ntp.conf file

Code: Select all

# This file is managed by Puppet
# Do not edit this file

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1
restrict -6 ::1

fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
server 192.168.0.140
server 192.168.0.145
server  127.127.1.0     # local clock
When the results of NTPQ come in they look like this

Code: Select all

     remote           refid      st t when poll reach   delay   offset  jitter                                                                                                  
==============================================================================                                                                                                  
*192.168.0.140      41.73.40.11      2 u  769 1024  377    0.615    0.438   4.731                                                                                                  
+192.168.0.145      41.73.40.11      2 u  578 1024  377    0.733    0.302   0.281                                                                                                  
 127.127.1.0     .LOCL.          10 l  18h   64    0    0.000    0.000   0.000
Any advise on how to speed this up would be appreciated

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: ntpq hangs

Post by hunter86_bg » 2018/04/10 19:21:07

I don't see a restrict stanza for '-4'. Also add 'iburst' to both server definition.
It is recommended to have an odd number of srrvers as in your case if 1 of the servers drifts away - your client won't know which one is correct.
You can always get the default config and set your servers and try if it fixs it.

Edit: What is the output of:

Code: Select all

cat /sys/devices/system/clocksource/clocksource0/{current_clocksource,available_clocksource}
Edit2: As per this Red Hat Solution "Chrony should be preferred for all systems except for the systems that are managed or monitored by tools that do not support chrony, or the systems that have a hardware reference clock which cannot be used with chrony."

rezizter1
Posts: 4
Joined: 2018/04/09 13:34:08

Re: ntpq hangs

Post by rezizter1 » 2018/04/11 10:16:10

Thank you for the reply.
Unfortunately chrony is not an option for now. we have software that relies on ntp, we are re writing said software.

output of

Code: Select all

cat /sys/devices/system/clocksource/clocksource0/{current_clocksource,available_clocksource}
tsc
tsc hpet acpi_pm
I have made the -4 changes to my config so that they reflect the following:

Code: Select all

restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

restrict -4 127.0.0.1
restrict -6 ::1

fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
server 192.168.0.140
server 192.168.0.145
server  127.127.1.0     # local clock
But it is still slow

MartinR
Posts: 714
Joined: 2015/05/11 07:53:27
Location: UK

Re: ntpq hangs

Post by MartinR » 2018/04/11 11:05:32

I've extracted the relevant bits from my ntp.conf:

Code: Select all

server <fqdn1> iburst
server <fqdn2> iburst
server <fqdn3> iburst
tos orphan 7
#
driftfile /var/lib/ntp/drift
#
logconfig =syncstatus +sysevents
* First, please note the iburst as recommended by hunter86_bg.
* Second, try using tos orphan instead of setting the localhost as a server.
--edit:
If using tos orphan you don't need the fudge.

rezizter1
Posts: 4
Joined: 2018/04/09 13:34:08

Re: ntpq hangs

Post by rezizter1 » 2018/04/11 12:23:55

Thank you.
I have made the changes, and speed is better, it now takes around 40 seconds for ntpq -pn to return results, which is alot better.
Is there anything else I can do to speed this up to near instant?

Unfortunately we only have 2 NTP servers for now, I will get a third one in place


My new config file

Code: Select all

restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

restrict -4 127.0.0.1
restrict -6 ::1

driftfile /var/lib/ntp/drift
keys /etc/ntp/keys
server 192.168.0.140 iburst
server 192.168.0.145 iburst
tos orphan 7
results of ntpq -pn

Code: Select all

Wed Apr 11 14:18:57 SAST 2018
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168.0.140      146.64.58.41     2 u   50  128  377    0.678   -0.113   0.069
+192.168.0.145     146.64.8.7       2 u   19  128  377    0.651    0.025   0.029

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: ntpq hangs

Post by hunter86_bg » 2018/04/12 04:16:49

Does ntpstat react faster?
Also add

Code: Select all

tinker panic 0
and restart the ntp.
What is the output of

Code: Select all

ntpq -dnp

rezizter1
Posts: 4
Joined: 2018/04/09 13:34:08

Re: ntpq hangs

Post by rezizter1 » 2018/04/12 05:31:31

Thank you for the reply.
ntpstat is instant, the only thing I am having issues with is ntpq, for some reason that is slow
I have now added in

Code: Select all

tinker panic 0
to the config file
Response time on ntpq is still around 40 seconds.

the results of ntpq -dnp

Code: Select all

1 packets reassembled into response
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
2 packets reassembled into response
*192.168.0.140      146.64.8.7       2 u   40   64    1    0.517   -0.040   0.016

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: ntpq hangs

Post by hunter86_bg » 2018/04/12 21:54:15

Can you do the following:
1. Populate your "/etc/hosts" like this:

Code: Select all

192.168.0.140 ntp1
192.168.0.145 ntp2
2. Edit ntp.conf servers to look like these:

Code: Select all

#server 192.168.0.140 iburst
#server 192.168.0.145 iburst
server ntp1 iburst
server ntp2 iburst
3.Restart the ntpd and check the status.

Post Reply