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.
We classify on the maxerror field, not the STA_UNSYNC status bit. STA_UNSYNC is an unreliable "is the clock disciplined?" signal: chrony leaves it set unless the `rtcsync` directive is configured, and systemd-timesyncd lets the kernel re-assert it between polls -- both produce false "unsynced" reports on hosts whose clocks are in fact NTP-synced (the Raspberry Pi false positive this fixes). `timedatectl`'s "System clock synchronized" line is computed by systemd-timedated's ntp_synced(), which calls adjtimex and returns `maxerror < 16 s`, explicitly ignoring STA_UNSYNC. Mirroring that threshold makes Graywolf agree with timedatectl across daemons and configurations.