Configure loopstats and peerstats to troubleshoot NTP synchronization issues
search cancel

Configure loopstats and peerstats to troubleshoot NTP synchronization issues

book

Article ID: 413890

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This kb outlines the steps to configure NTP loopstats and peerstats to troubleshoot NTP synchronisation issues. These steps are extremely helpful when a user wishes to monitor and export the NTP statistics for a certain duration (for example a day or two) to confirm the behavior of NTP peers throughout the said period.

Loopstats and Peerstats are NTP (Network Time Protocol) logging options used for troubleshooting the time synchronization process. While loopstats records statistics on the server's internal clock discipline, peerstats records synchronization statistics for each individual NTP peer the server is communicating with, including offset, delay, and status. Both are enabled in the ntp.conf file using the statistics command and can be essential for diagnosing NTP related issues. 

Environment

VMware vSphere ESXi 7.x
VMware vSphere ESXi 8.x

Resolution

  1. Login to the ESXi Host using SSH.

  2. Create a new directory inside var/log to capture the NTP statistics files.

    mkdir -p /var/log/ntp/

  3. Run the following command as it is to enable peerstats and loopstats in the ntp backup that gets created as a part of the process. The command specifies that all generated statistics files should be placed in the /var/log/ntp/ directory (which is created in step 2). Additionally, the statistics file shall be rotated daily. 

    cp /etc/ntp.conf /etc/ntp.conf.bak && echo "statistics loopstats
     statsdir /var/log/ntp/
     filegen peerstats file peers type day link enable
     filegen loopstats file loops type day link enable" >> /etc/ntp.conf.bak

  4. Load the NTP configuration of the ESXi Host from the specified file'/etc/ntp.conf.bak' file and restart NTP service.

    esxcli system ntp set -f /etc/ntp.conf.bak && esxcli system ntp set -e 1