[ntp:questions] Monitoring ntp synchronization status

unruh unruh at invalid.ca
Thu Jul 4 17:13:51 UTC 2013


On 2013-07-04, Orna Sumszyk <orna.sumszyk at gmail.com> wrote:
> Hello everybody,
>
> I run ntpd in my Linux machine.
> In my application running on that computer, I run every second a little
> code that checks the ntp synchronization status.
> It checks 2 things:
> 1. The returned string of ntpstat command. If it writes "ntp is not
> synchronized", I conclude there is no synchronization. Else I check the
> next thing.
> 2. It runs ntpq and parses the returned string. If the * sign doesn't
> appear next to my ntp server (I only have one server in my private network,
> it is a tcg device that has a gps clock and also behaves as an ntp server),
> I also conclude there is no synchronization.
>
> To check this code, I did the following. I changed the time of my server on
> purpose to a wrong time: I added half an hour to it. The server after a

And why do you think that ntp should behave reasonably in such a totally
irrational situation? Clocks to not simply jump by half and hour and
then jump back again. ntpd is justified in thinking that the system is
completely messed up. 


> given short time sets back the right time. In my machine (the ntp client),
> when I run ntpq every second, I can see that at the beginning, the jitter
> value grows a lot. Then it suddenly goes very small but the offset value
> grows a lot. Finally, a step is performed and the time is adjusted.
> The problem is that until the step is performed, ntpstat returns that it is
> synchronized and ntpq still shows the * in my ntp server line. But in fact,
> the time is not good and this can be
> seen from the jitter and offset values.

no the time is "good" because ntpd assumes that the problem is in the
source not in your local clock. It has to wait a while to figure out
that the problem is local not with the server. Network problems or
server problems are not unkown and ntpd has no way of knowing that some
one changed the local time out from under ntp. 


>
> So do you think I should refine my monitoring and take into account the
> offset and jitter values? Are there other things I should take into
> account? Should I do things differently?

You should test in realistic scenarios, not in absurd ones. 

At about 3 years of age, children realise that others do not necessarily
have the same knowledge that they do. ntpd has no way of knowing that
you messed around with the system. 



>
> Thank you!



More information about the questions mailing list