ntpstats.sources¶
Live samples from the local time daemon (no log files needed).
- chrony:
chronyc -c tracking(CSV). Field order from chrony'sclient.c: RefID, name, stratum, ref time, System time (current correction; positive = system clock slow, i.e. the ntpd sign convention), last offset (positive = local fast), RMS offset, frequency, residual freq, skew, root delay, root dispersion, update interval, leap status.chronyc -c sourcestatsadds per-source estimated offsets (same quantity as statistics.log "Est offset", positive = local fast, negated here). -
ntpd / NTPsec:
ntpq -c rvsystem variables (offsetin ms, ntpd convention;frequencyppm;sys_jitter/clk_jitterms). -
linuxptp:
pmc -u -b 0 'GET CURRENT_DATA_SET' 'GET TIME_STATUS_NP'(offsetFromMasterandmaster_offsetin ns, local - master, negated here;meanPathDelayns;gmPresent). - facebook/time:
ptpcheck statsJSON (ptp.offset_ns, local - master as reported by ptp4l, negated here;ptp.mean_path_delay_ns). - gpsd: the PPS (or, without PPS, TOFF) messages of a running gpsd
(
host:port, defaultlocalhost:2947): GNSS time minus the system clock's time stamp of the edge, withprecisionandqErr. - PHC, OCP Time Card, AWS ClockBound, Meta fbclock: see
:mod:
ntpstats.hwclocks(watch phc,timecard,clockbound,fbclock). - ntpd-rs:
ntp-ctl -f prometheus status, or the metrics exporter's HTTP endpoint (give its URL as the command). ntpd-rs 1.x exports per-sourcentp_source_offset_seconds(source - local, the ntpd convention),ntp_source_uncertainty_secondsandntp_source_delay_seconds; the sample's offset is the inverse-variance mean over the sources, the combination ntpd-rs itself applies to the sources it selects. The 2.0 pre-releases no longer export per-source offsets; they are reported as such.
Only a subprocess is used; nothing is installed or configured. The command
can be overridden (e.g. ["ssh", "host", "chronyc"]) to watch a remote host.
LocalWatch
¶
Poll the local daemon periodically (same interface as :class:ntpstats.monitor.Monitor).
parse_pmc(text)
¶
Parse pmc CURRENT_DATA_SET / TIME_STATUS_NP responses.
sample_pmc(cmd=('pmc', '-u', '-b', '0'))
¶
CURRENT_DATA_SET and TIME_STATUS_NP, plus PORT_DATA_SET of every port (the
state of each port of a boundary clock: ports, slave_port,
faulty_ports and port_states such as 1:SLAVE 2:MASTER).
parse_ptpcheck_stats(text)
¶
Parse ptpcheck stats JSON (facebook/time).
parse_prometheus_text(text)
¶
Samples of the Prometheus/OpenMetrics text format: (name, labels, value) per line.
parse_ntpdrs_metrics(text)
¶
One ntpd-rs observation from its Prometheus text output (ntp-ctl -f prometheus status).
sample_ntpdrs(cmd=('ntp-ctl', '-f', 'prometheus', 'status'))
¶
Sample ntpd-rs with ntp-ctl, or from its metrics exporter when cmd is one http(s) URL.
sample_gpsd(cmd=('localhost:2947',))
¶
One PPS offset (GNSS - system clock) from gpsd; cmd is ["host:port"].
sample_phc(cmd=('/dev/ptp0',))
¶
PHC - system clock (cmd = [device] or [device, TAI-UTC]); see :mod:ntpstats.hwclocks.
sample_timecard(cmd=('/sys/class/timecard/ocp0',))
¶
OCP Time Card status and its PHC - system clock; see :mod:ntpstats.hwclocks.
sample_clockbound(cmd=())
¶
AWS ClockBound window via libclockbound; see :mod:ntpstats.hwclocks.
sample_fbclock(cmd=('ptpcheck',))
¶
Meta fbclock window via ptpcheck fbclock; see :mod:ntpstats.hwclocks.
prometheus_query_range(url, query, start, end, step='60', timeout=30.0)
¶
Run a Prometheus /api/v1/query_range request and return the JSON document.