VMware vSphere

 View Only
  • 1.  Check NTP from the command line?

    Posted Feb 23, 2011 01:37 PM

    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 



  • 2.  RE: Check NTP from the command line?

    Posted Feb 23, 2011 01:49 PM
    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 


  • 3.  RE: Check NTP from the command line?

    Posted Feb 23, 2011 02:35 PM

    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



  • 4.  RE: Check NTP from the command line?

    Posted Feb 24, 2011 09:43 AM

    Will PowerCli do?

    If so, the solution is in the following thread:

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



  • 5.  RE: Check NTP from the command line?

    Posted Feb 24, 2011 10:33 AM

    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



  • 6.  RE: Check NTP from the command line?

    Posted Feb 24, 2011 10:35 AM

    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



  • 7.  RE: Check NTP from the command line?

    Broadcom Employee
    Posted Feb 24, 2011 10:23 AM

    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



  • 8.  RE: Check NTP from the command line?

    Posted Aug 29, 2012 03:43 PM

    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