From a2b71cf65a622c8a5050a0bfa645cfda7d9523fc Mon Sep 17 00:00:00 2001 From: David Venhoek Date: Thu, 21 Sep 2023 09:06:33 +0200 Subject: [PATCH] Exposed root dispersion and root delay reported by time source as metrics --- CHANGELOG.md | 1 + docs/guide/getting-started.md | 36 ++++++++++++++++++++++------------- ntpd/src/ctl.rs | 6 ++++-- ntpd/src/metrics/mod.rs | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe17f97f..da6fa3ba3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added - Added metrics for NTS packets processed in the server +- Exposed root dispersion and root delay reported by time source as metrics. ### Fixed - Fixed peer trying to request more cookies than it can encode in it's packet buffer. diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 6b7c77809..d6eb19379 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -16,19 +16,23 @@ ntp-ctl status If everything is installed and working correctly this will display information looking like: ``` Synchronization status: -Dispersion: 0.000177s, Delay: 0.004485s +Dispersion: 0.000104s, Delay: 0.005740s Desired poll interval: 16s -Stratum: 2 +Stratum: 3 Sources: -ntpd-rs.pool.ntp.org:123/162.159.200.123:123 (1): -0.000217±0.000076(±0.004655)s +ntpd-rs.pool.ntp.org:123/20.101.57.9:123 (1): -0.022944±0.000218(±0.004720)s pollinterval: 16s, missing polls: 0 -ntpd-rs.pool.ntp.org:123/213.239.154.12:123 (2): +0.000253±0.000070(±0.003234)s + root dispersion: 0.103531s, root delay:0.001434s +ntpd-rs.pool.ntp.org:123/35.204.193.221:123 (2): +0.000564±0.000138(±0.007323)s pollinterval: 16s, missing polls: 0 -ntpd-rs.pool.ntp.org:123/154.51.12.215:123 (3): +0.001769±0.000065(±0.005667)s + root dispersion: 0.000000s, root delay:0.007538s +ntpd-rs.pool.ntp.org:123/94.198.159.15:123 (3): +0.000140±0.000202(±0.005725)s pollinterval: 16s, missing polls: 0 -ntpd-rs.pool.ntp.org:123/213.136.0.252:123 (4): +0.000330±0.000096(±0.005370)s + root dispersion: 0.000015s, root delay:0.000015s +ntpd-rs.pool.ntp.org:123/95.211.123.72:123 (4): +0.000052±0.000189(±0.005118)s pollinterval: 16s, missing polls: 0 + root dispersion: 0.039536s, root delay:0.021667s Servers: @@ -53,23 +57,29 @@ count = 2 After restarting the daemon (using `sudo systemctl restart ntpd-rs` if you are using Linux) and waiting a bit for it to synchronize, the status now looks like ``` Synchronization status: -Dispersion: 0.000144s, Delay: 0.005345s +Dispersion: 0.000123s, Delay: 0.005496s Desired poll interval: 16s Stratum: 2 Sources: -ntp.time.nl:123/94.198.159.14:123 (1): +0.000620±0.000188(±0.005378)s +ntp.time.nl:123/94.198.159.10:123 (1): +0.000380±0.000249(±0.005496)s pollinterval: 16s, missing polls: 0 -ntp.time.nl:123/94.198.159.10:123 (2): +0.000557±0.000219(±0.005345)s + root dispersion: 0.000122s, root delay:0.000000s +ntp.time.nl:123/94.198.159.14:123 (2): -0.000046±0.000154(±0.005520)s pollinterval: 16s, missing polls: 0 -ntpd-rs.pool.ntp.org:123/45.32.4.67:123 (3): +0.001134±0.000233(±0.081599)s + root dispersion: 0.000122s, root delay:0.000000s +ntpd-rs.pool.ntp.org:123/84.245.9.254:123 (3): -0.000288±0.000698(±0.008572)s pollinterval: 16s, missing polls: 0 -ntpd-rs.pool.ntp.org:123/86.80.166.233:123 (4): -0.000569±0.000417(±0.007668)s + root dispersion: 0.000305s, root delay:0.006226s +ntpd-rs.pool.ntp.org:123/83.98.155.30:123 (4): +0.000000±0.000163(±0.005186)s pollinterval: 16s, missing polls: 0 -ntpd-rs.pool.ntp.org:123/94.228.220.14:123 (5): +0.000213±0.000191(±0.005438)s + root dispersion: 0.005020s, root delay:0.004898s +ntpd-rs.pool.ntp.org:123/162.159.200.123:123 (5): -0.000380±0.000140(±0.004535)s pollinterval: 16s, missing polls: 0 -ntpd-rs.pool.ntp.org:123/162.159.200.123:123 (6): +0.000114±0.000187(±0.004175)s + root dispersion: 0.000259s, root delay:0.003662s +ntpd-rs.pool.ntp.org:123/5.255.99.180:123 (6): +0.000193±0.000203(±0.005414)s pollinterval: 16s, missing polls: 0 + root dispersion: 0.008499s, root delay:0.005661s Servers: diff --git a/ntpd/src/ctl.rs b/ntpd/src/ctl.rs index 09885ef7f..eef8a2054 100644 --- a/ntpd/src/ctl.rs +++ b/ntpd/src/ctl.rs @@ -255,7 +255,7 @@ async fn print_state(print: Format, observe_socket: PathBuf) -> Result { println!( - "{}/{} ({}): {:+.6}±{:.6}(±{:.6})s\n pollinterval: {:.0}s, missing polls: {}", + "{}/{} ({}): {:+.6}±{:.6}(±{:.6})s\n pollinterval: {:.0}s, missing polls: {}\n root dispersion: {:.6}s, root delay:{:.6}s", address, ip, id, @@ -263,7 +263,9 @@ async fn print_state(print: Format, observe_socket: PathBuf) -> Result st collect_sources!(state, |p| p.timedata.uncertainty.to_seconds()), )?; + format_metric( + w, + "ntp_source_root_delay", + "Root delay reported by the time source", + MetricType::Gauge, + Some(Unit::Seconds), + collect_sources!(state, |p| p.timedata.remote_delay.to_seconds()), + )?; + + format_metric( + w, + "ntp_source_root_dispersion", + "Uncertainty reported by the time source", + MetricType::Gauge, + Some(Unit::Seconds), + collect_sources!(state, |p| p.timedata.remote_uncertainty.to_seconds()), + )?; + format_metric( w, "ntp_server_received_packets_total",