[ntp:questions] Synchronization and Non-Synchronization status

David Woolley david at ex.djwhome.demon.invalid
Sat Feb 20 00:14:36 UTC 2010


Jaiprabhu wrote:
> Jaiprabhu wrote:
>> Assuming the following config:
>>
>> [...]
>> restrict default kod nomodify notrap noquery
>> restrict 127.0.0.1
>> driftfile ....
>> server <server1> minpoll <N> maxpoll <M>
>> server <server2> minpoll <N> maxpoll <M>
>> server <server3> minpoll <N> maxpoll <M>
>> [...]
>>
>> I need to do the following:
>>
>> 1. Set a global "sync" status when we are sure that NTPd is 
>> synchronized to *at least* one server.
>> 2. Set a global "not-sync" status when we are sure that NTPd is 
>> not-synchronized to *any* of the configured server, when there was a 
>> prior "sync" condition
>>
>> There are two parts to my problem:
>>
>> 1. How do I find out the "sync" and "not-sync" status from NTPd
>> 2. How do I make NTPd tell me when it reaches "sync" and when it is 
>> "not-sync". It's probably ok if I can use parse a log message 
>> generated by NTPd to figure this out.
>>
>> Can someone please tell me a reliable way to determine these two 
>> things. For 1 I could perhaps read the 'ntpq -pn' billboard and look 
>> at the tally codes. If there is a sys.peer ("*") in the list then I 
>> guess we are in "sync" status. For 1, I am not sure what the 
>> "not-sync" condition is though.
>>
>> Many thanks.
> 
> Anyone?
> 
> The thing I am most interested in resolving is, in which part of NTPd, 
> and how, can I determine that there are no valid peers left (either they 
> are unreachable or are not reliable servers) and therefore determine the 
> current global synchronization status to be "not-sync". One of ideas I 


Stratum = 16 - unsynchronised
Stratum = 1 through 15 synchronised.

You can do that with an ordinary client poll

You can also use the status flags provided by ntpdc's rv 0 command - 
specifically read that variable if you write a custom program.  A quick 
check of the header files will tell you which bits are important.

There is trap mechanism, but I don't know any details.

Note that synchronised is not the same  as tightly locked.  The error 
can be ~128 ms with it still showing synchronised.

> am toying with is to edit ntp_proto.c and going through the list of all 
> configured servers at the end of clock_select() and verifying that at 
> least one of the servers is a sys.peer. If not, then I send a signal out 
> to tell whoever is listening that NTP is "not-sync".
> 
> The option of looking at the billboard every poll interval (excecuting 
> 'ntpq -pe') and looking for the "*" tally code is always present but I 
> would want to avoid this polling mechanism. Instead, I would prefer 
> receiving of the "not-sync" status from withing NTPd itself.
> 
> I would really appreciate if someone can give me some input on this.
> 
> Thanks in advance.
> 
> 
> 




More information about the questions mailing list