Documentation
¶
Overview ¶
Package clocksync reports whether the host's system clock is being disciplined by a time source (NTP, chrony, systemd-timesyncd, ...).
An undisciplined clock skews every time-relative calculation in Graywolf: packet ages go wrong (and can even read negative), and the web map's Time Range filter hides stations whose beacons fall outside the skewed window. See chrissnell/graywolf#234. The startup banner calls Check so operators get a heads-up before chasing phantom bugs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Status ¶
type Status int
Status is the outcome of a clock-sync check.
const ( // Unknown means the check could not be performed -- the platform has // no query API or the syscall failed. Callers should stay silent // rather than warn on a value they couldn't actually measure. Unknown Status = iota // Synced means the kernel reports the clock is disciplined. Synced // Unsynced means the kernel reports no time source is disciplining // the clock. Unsynced )
func Check ¶
func Check() Status
Check queries the kernel NTP discipline state via adjtimex(2). A zero Modes field makes this a read-only query that needs no privileges.
The kernel initializes its NTP status word to STA_UNSYNC at boot and clears that bit only once a time source (NTP, chrony, systemd-timesyncd) has disciplined the clock -- the same signal `timedatectl`'s "System clock synchronized" line is derived from. STA_UNSYNC alone is therefore the precise "not disciplined" signal: it covers both the no-daemon case (bit still set from boot) and the daemon-not-yet-converged case, while a synced clock with a leap second pending (TIME_INS/TIME_DEL) keeps the bit clear and is correctly reported as Synced.