Accurate time synchronization is a silent but critical dependency for every distributed system. From database transaction ordering to TLS certificate validation, log correlation, and distributed consensus protocols — everything breaks when clocks drift. Yet most infrastructure teams only discover time drift issues during an outage, when correlating logs across servers reveals timestamp mismatches.
In this guide, we cover three essential self-hosted tools for monitoring and diagnosing NTP (Network Time Protocol) synchronization: chronyc (the chrony control program), ntpstat (a simple sync status checker), and ntpviz (the NTP visualization toolkit from ntpsec). Unlike general monitoring platforms, these tools focus specifically on time synchronization accuracy, stratum levels, offset tracking, and peer health.
Overview Comparison
| Feature | chronyc | ntpstat | ntpviz |
|---|---|---|---|
| Package | chrony | ntpstat (standalone) | ntpsec |
| GitHub Stars | N/A (part of chrony) | 160+ | Part of ntpsec |
| NTP Daemon | chronyd | Works with ntpd or chronyd | ntpd (ntpsec) |
| Output Type | CLI (interactive) | CLI (single-line) | HTML reports + graphs |
| Visual Reports | ASCII tables | No | HTML + gnuplot charts |
| Best For | Active monitoring & debugging | Quick health checks | Historical analysis & reports |
| Data Collection | Real-time queries | Current status snapshot | Log-based analysis |
chronyc: The chrony Control Interface
chrony is the default NTP implementation on most modern Linux distributions (RHEL, Fedora, Ubuntu, Debian). Its companion CLI tool, chronyc, provides real-time access to the chrony daemon’s internal state — including peer statistics, clock drift measurements, and synchronization accuracy.
Key Commands
| |
Example Output
| |
Docker-Based chrony Server Setup
| |
Monitoring chrony with Prometheus
| |
ntpstat: Quick Synchronization Health Check
ntpstat is a lightweight utility that returns a single-line summary of NTP synchronization status, making it ideal for monitoring scripts, alerting systems, and health checks.
Usage
| |
Integration with Monitoring Systems
| |
Installing ntpstat
| |
ntpviz: Historical NTP Performance Visualization
ntpviz is part of the ntpsec project — a security-hardened fork of the classic NTP daemon. The ntpviz tool parses NTP daemon statistics logs and generates comprehensive HTML reports with graphs showing offset trends, jitter patterns, peer reachability, and frequency drift over time.
Generating Reports
| |
Key Visualizations
| |
Nginx Configuration for NTP Reports
| |
Why Monitor NTP Synchronization?
Time synchronization is one of those infrastructure concerns that goes unnoticed until something catastrophic happens. A few milliseconds of clock drift can cascade into serious problems across your stack.
Database consistency: Distributed databases like CockroachDB, YugabyteDB, and MongoDB rely on accurate timestamps for transaction ordering and conflict resolution. Clock skew between nodes can cause write conflicts, split-brain scenarios, and data loss.
Security and authentication: TLS certificates, Kerberos tickets, and OAuth tokens all have validity windows. If a server’s clock drifts even a few minutes, authentication will fail. Two-factor authentication (TOTP) also requires synchronized time to generate valid codes.
Log correlation and incident response: When troubleshooting an outage across multiple services, correlated timestamps are essential. A 30-second clock skew between your application server and database server can make it impossible to determine causation from logs.
Distributed consensus: Protocols like Raft, Paxos, and leader election algorithms depend on bounded clock drift. Excessive drift can cause false leader timeouts, unnecessary elections, and cluster instability.
For related infrastructure monitoring topics, see our container monitoring guide, endpoint monitoring tools, and UPS monitoring guide.
FAQ
What is an acceptable NTP offset for production servers?
For most production workloads, an offset of less than 100 milliseconds is acceptable. For distributed databases and financial trading systems, aim for under 10 milliseconds. chrony typically achieves sub-millisecond accuracy on modern hardware with good network connectivity to NTP servers.
Should I use chrony or ntpd?
chrony is the recommended choice for most modern Linux distributions. It converges faster than ntpd, handles intermittent network connections better, and provides more accurate timekeeping on virtual machines. ntpd (via ntpsec) is preferred when you need ntpviz-style historical reporting or legacy NTP compatibility.
How often does chrony poll NTP servers?
chrony uses an adaptive polling interval that ranges from 64 seconds to 1024 seconds (about 17 minutes). When synchronization is stable, it polls less frequently. After a reboot or when it detects clock drift, it polls more aggressively. You can override this with minpoll and maxpoll settings in /etc/chrony.conf.
Can I use ntpstat in an automated monitoring pipeline?
Yes, ntpstat is designed for scripting. It returns exit code 0 when synchronized, 1 when unsynchronized, and 2 when it cannot contact the NTP daemon. This makes it ideal for Nagios/Icinga checks, cron-based monitoring scripts, or Prometheus blackbox-exporter probes.
How do I set up a local NTP server for my network?
Install chrony on a dedicated server, configure it to sync with upstream pool servers, and allow client connections in /etc/chrony.conf using allow 192.168.0.0/16. Point all internal servers to this local NTP server. This reduces external NTP traffic and provides faster sync for internal machines.
What happens when an NTP server goes offline?
chrony maintains a list of multiple NTP peers and will automatically switch to the best available source. It also remembers the last measured drift rate and can continue correcting the local clock for hours even when all peers are unreachable. Use chronyc sources to see which peers are reachable.