Skip to content

Commit

Permalink
Exposed root dispersion and root delay reported by time source as met…
Browse files Browse the repository at this point in the history
…rics
  • Loading branch information
davidv1992 committed Sep 21, 2023
1 parent 28d5b00 commit a2b71cf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
36 changes: 23 additions & 13 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions ntpd/src/ctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,17 @@ async fn print_state(print: Format, observe_socket: PathBuf) -> Result<ExitCode,
},
) => {
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,
timedata.offset.to_seconds(),
timedata.uncertainty.to_seconds(),
timedata.delay.to_seconds(),
poll_interval.as_duration().to_seconds(),
unanswered_polls
unanswered_polls,
timedata.remote_uncertainty.to_seconds(),
timedata.remote_delay.to_seconds(),
);
}
}
Expand Down
18 changes: 18 additions & 0 deletions ntpd/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@ pub fn format_state(w: &mut impl std::fmt::Write, state: &ObservableState) -> 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",
Expand Down

0 comments on commit a2b71cf

Please sign in to comment.