[ntp:questions] ntpq -p command query

unruh unruh at invalid.ca
Wed Jul 31 14:19:04 UTC 2013


On 2013-07-31, Biswajit Panigrahi <BP00106533 at TechMahindra.com> wrote:
> Hi ,
> Basically my intention is to get notification in client when ever the connection between server changes(Ex-lan connectivity OR ntp server itself is down).For that I am doing the following step:

ntp is NOT the way to test connectivity. That is not its purpose. 

>
> In client:
> 1.Execute ntpq -c associations 
> 2.Get the data in status field 
> 3.If there is any change in that field ,then collect the 4th bit of that.(Ex:f69a & 1000)
> 4.If its 1 then reachable else unreachable.
>
> But the problem I am facing is: 
> Whenever the connectivity between the server goes down, the status field  will not change immediately.
> My observation was whenever the reach field of ntpq -p command comes to zero then only the status field changes.
> That's why I was trying to reduce the time gap.

And you are running into a lack of knowledge of how ntp works. ntp sends
our query packets, which is 2^p sec where p is the poll number-- between 6
and 10 by default. 
Ie, ntpd has not idea that the remote server is down untill it has
polled it. ntpd collects the last 8 querries and uses only the one with
the shortest roundtrip time. Thus it does not care if there is no
response for a few polls. 
ntpd knows that there could be a huge number of possible reasons for a
poll to get lost and does not worry about it. Why do you?



>
> If My approach is not correct then please suggest me the other approach.

approach to what? What is the problem you are trying to solve?

>
> -----Original Message-----
> From: questions-bounces+bp00106533=techmahindra.com at lists.ntp.org [mailto:questions-bounces+bp00106533=techmahindra.com at lists.ntp.org] On Behalf Of David Taylor
> Sent: Wednesday, July 31, 2013 12:46 AM
> To: questions at lists.ntp.org
> Subject: Re: ntpq -p command query
>
> On 30/07/2013 15:24, Biswajit Panigrahi wrote:
>> Hi,
>>
>> I have configured the ntp server and ntp client on two machine.
>>
>> Both are communicating properly. I would like to test when the
>> connectivity between those two goes down, after how much time the
>> "reach" option in ntpq -p command becomes zero.
>>
>> For that I stopped the ntp server  and I executed the ntpq -p in
>> client's  console,
>>
>> The reach option will still  keep on increase to 377 then gradually
>> decreases to zero. The time duration to come to zero is almost 20
>> minute.
>>
>> Can we reduce the time gap ?
> []
>> Regards,
>>
>> Biswajit
>
> Biswajit,
>
> Look for a value not equal to 377, rather than 0.  Possibly 376 would be 
> the first indication of a problem.
>
> 20 minutes (actually 1024 seconds) is the polling interval which will be 
> reached in a stable default configuration, so as others have said, 
> reduce the value of maxpoll for servers which are local to your network 
> (i.e. not public servers).  On my own network, I typically have maxpoll 
> set to 5 for local servers, and minpoll set to 10 for Internet servers.



More information about the questions mailing list