LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-27-2012, 12:03 PM   #1
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Rep: Reputation: 34
how to indentify whether the multiple hosts are in sync with ntp server


Hi,
I have 3000 hosts in my network & they are in sync with ntp server
but i want to very whether all the hosts are in sync with ntp & also
how can i check the same for all the hosts remotly through ntp server without login to the hosts system.

Any solution will be appreciated.
 
Old 02-27-2012, 01:30 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,577
Blog Entries: 14

Rep: Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969
The ntp server doesn't keep track of the hosts that rely on it for time so you can't tell what the time on your 3000 hosts is from the ntp server.

What I've done as a kluge to check times is setup a host (let's call it "master") that has ssh trust to all my other hosts and have a list of those hosts. I then script it to get the time (run date command) on the client first then get the time on the master and compare the two.

You want to get master AFTER the client to remove the time difference created by doing the ssh over the network - that is to say the ssh to the client could be delayed by a second or two but the master's time won't be since it will be a local command - by getting client first then immediately getting master you help insure the two times are the same.

In the above of course the time on each client will be different because it will take time to ssh to all of the 3000 hosts. This is why you compare each to the master's time that you get AFTER each host - that way it doesn't matter that they're not all the same - all you care about is that the client matches the master at the point you query the client.

edit: I just modified a script I had for this purpose. You'd need to create your /root/linuxservers.list with the 3000 servers then run against it.

Code:
#!/bin/bash
/bin/echo -e "TIME CHECK COMPARISON OF SERVERS TO MASTER\n"
for server in $(cat /root/linuxservers.list |awk -F: '{print $2}')
do srvtime=$(/usr/bin/ssh $server date)
   mstrtime=$(date)
   if ! [ "$srvtime" = "$mstrtime" ]
   then /bin/echo -e "ERROR $server has $srvtime and $(hostname) has $mstrtime \n"
   else /bin/echo -e "OK $server has $srvtime and $(hostname) has $mstrtime \n"
   fi
done
For 3000 servers it might be better to do it in perl for speed but I'll leave that as an exercise for you.

Last edited by MensaWater; 02-27-2012 at 01:54 PM.
 
Old 03-04-2012, 08:59 AM   #3
smilemukul
Member
 
Registered: Jun 2009
Distribution: Redhat,CentOS,Ubuntu,Puppet
Posts: 292

Original Poster
Rep: Reputation: 34
Thanks for the info but is there any other way so that I don't require to sign the ssh keys between master & client.
 
Old 03-04-2012, 09:08 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Try http://linux.die.net/man/8/ntpq passing remote hostname & also see http://linux.die.net/sag/ntp-toolkit.html
 
Old 03-05-2012, 10:07 AM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,577
Blog Entries: 14

Rep: Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969
Quote:
Originally Posted by chrism01 View Post
Could you give an example? When I try this I don't get the date output from the target system even when I turn off iptables there. Does it have to be running as an ntpserver rather than just a client? If so I don't see how this would be easier than what I suggested as the OP would have to reconfigure all his systems to allow ntpq to talk remotely to them.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NTP server sync issues machielr Linux - Server 1 04-20-2011 05:31 AM
[SOLVED] Slackware server - ntp time sync stops after a day tennis_slacker Slackware 81 08-04-2010 10:05 AM
ntp server cannot sync clients NdAd Linux - Software 22 07-15-2010 12:13 AM
NTP server not sync sebash00 Linux - General 6 04-04-2008 02:40 AM
NTP Sync? carlosinfl Linux - Networking 12 04-13-2006 11:33 AM


All times are GMT -5. The time now is 06:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration