Operating System - HP-UX
1838374 Members
3302 Online
110125 Solutions
New Discussion

checking ntp is running and synching

 
YLTan
Frequent Advisor

checking ntp is running and synching


I use ntpq -p and its output is
remote refid st t when poll reach delay offset disp
==============================================================================
*ntpsvr1.m1.com 8.m1.com 5 u 62 64 377 1.07 -0.174 0.08

Can someone advice how to write a simple scripts to check if the ntp is synching with the time server? what does all those column means?
tyl
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: checking ntp is running and synching

ntpq -p
rc=$?

if [ $rc -eq 0 ] then
echo "NTP is working"
else
echo "NTP is not working"
fi

columns(I don't know many)

remote server providing the ntp time

The last few involve the adjustment/difference between the time serer and the server making the query.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
RAC_1
Honored Contributor

Re: checking ntp is running and synching

The column details are self explainatory.

How to check if ntp is syncing with time server. I do this for that.

telnet time_server 13
telnet localhost 13 OR date

And compare the times on both machines.
There is no substitute to HARDWORK
Bernhard Mueller
Honored Contributor

Re: checking ntp is running and synching

Hi,

actually I cannot give you fully proof definitions for each column but what is important is that the value under "reach" increases. this indicates the number of successfull polls.

So you could write script that every hour or two checks that the value actually increases.

Regards,
Bernhard
Jean-Louis Phelix
Honored Contributor

Re: checking ntp is running and synching

Hi,

Have a look to KBRC00001347 for columns explanation. I agree with you that it's not so obvious ... :^)

Regards.
It works for me (© Bill McNAMARA ...)
Helen French
Honored Contributor

Re: checking ntp is running and synching

You can grep for xntpd daemon and see if NTP is working:

# ps -aef | grep xntpd.

If needed, you can add ntpq and ps commands in crontab and run it on a regular interval to see if it's working properly. To find out more about the process:

# man xntpd
# man ntpq

Also, refer this book:
http://www1.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000071549972
Life is a promise, fulfill it!
Angus Crome
Honored Contributor

Re: checking ntp is running and synching

See the following thread... I put a script and some useful information in it (as did quite a few others).

The trick to verifying that it is syncing is to check for the * next to one of the timeservers in the first column. If it is not there, then time sync is at best degrading.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=210263
There are 10 types of people in the world, those who understand binary and those who don't - Author Unknown
Jeff Schussele
Honored Contributor

Re: checking ntp is running and synching

Hi,

Just check your syslog.log file

grep ntp /var/adm/syslog/syslog.log

If you have sync statements in there & nothing else - you'll be as accurate as the NTP server(s).

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!