VMware Cloud Community
admin
Immortal
Immortal

Check NTP from the command line?

Hi All,

I have an ESXi server that I need to setup to sync NTP from the command line / unsupported mode.

I noticed that there is an /etc/ntpd.conf a and /etc/init.d/ntpd.

I know I can stop, restart, and check status of the ntpd by using the init.d script.

How can I know that ntpd is receiveing accurate time data from the source?

Is /var/log/messages my best option?  I'd really like something else so I don't have to scan through all of the other junk in /var/log/messages.


THANKS !!!

Andrew 

Tags (3)
0 Kudos
7 Replies
pcerda
Virtuoso
Virtuoso

Hi,
It's more simple to use the vicfg-ntp command through the vMA or vCLI, in order to configure the NTP settings.
  • To add a NTP server: vicfg-ntp --add 192.XXX.XXX.XX 
  • To start the NTP service: vicfg-ntp --start 
  • To list the NTP servers: vicfg-ntp --list
  • To stop the NTP service: vicfg-ntp --stop
  • To delete a NTP server: vicfg-ntp --delete 192.XXX.XXX.XX 
Regards / Saludos - Patricio Cerda - vExpert 2011 / 2012 / 2013
admin
Immortal
Immortal

pcerda,

Thanks for the helpful response!  I tested those commands and they worked as you described.


I am still looking for a way to verify that NTP is receiving time from the source though.

Once the host is added to vCenter it will be easy.

I am hoping to find a way not just to verify what the time is on the host, but that it is able to succesfully talk to the NTP server.

I will try to tail /var/log/messages and restart the service to see if any NTPd messages are reported.

Andrew

0 Kudos
bulletprooffool
Champion
Champion

Will PowerCli do?

If so, the solution is in the following thread:

http://communities.vmware.com/thread/283523

One day I will virtualise myself . . .
0 Kudos
depping
Leadership
Leadership

what about this:

echo restrict default kod nomodify notrap noquerynopeer > /etc/ntp.conf
echo restrict 127.0.0.1 >> /etc/ntp.conf
echo server 10.0.0.11 >> /etc/ntp.conf
echo server 10.0.0.12 >> /etc/ntp.conf
echo driftfile /var/lib/ntp/drift >> /etc/ntp.conf
/sbin/chkconfig --level 345 ntpd on
/etc/init.d/ntpd stop
/etc/init.d/ntpd start

Wrote about it on this blog: http://blogs.vmware.com/esxi/2011/02/ops-changes-part-2-scripted-installation.html

Duncan (VCDX)

Available now on Amazon: vSphere 4.1 HA and DRS technical deepdive

0 Kudos
ThompsG
Virtuoso
Virtuoso

Hi,

The only way I have found in ESXi is to troll the /var/log/messages log. I do this from the vSphere client and then filter on ntpd which makes it easier to see what is happening. On my ESXi server I could see events like: synchronized to x.x.x.x, stratum 2, etc.

Trust this helps.

Kind regards,

Glen

0 Kudos
ThompsG
Virtuoso
Virtuoso

Hi,

Just fully read your reply and noticed the part about not being connected to vCenter. In this case I would grep the messages log for ntpd and this will show you the time sync process.

Kind regards,

Glen

0 Kudos
Guardian1234
Contributor
Contributor

log into the host and at the cmd line:

# ntpq -p

or

# for i in 1 2 3 4 5 6 7 8 9

# do

# ntpq -p; sleep 10

# done

0 Kudos