Skip to content

Commit

Permalink
Refactor source status print statement
Browse files Browse the repository at this point in the history
  • Loading branch information
michielp1807 authored and davidv1992 committed Sep 12, 2024
1 parent a438ed2 commit d2471ca
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions ntpd/src/ctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,28 +243,32 @@ async fn print_state(print: Format, observe_socket: PathBuf) -> Result<ExitCode,
println!("Sources:");
for source in &output.sources {
println!(
concat!(
"{}/{}{} ({}): {:+.6}±{:.6}(±{:.6})s\n{}",
" poll interval: {:.0}s, missing polls: {}\n",
" root dispersion: {:.6}s, root delay:{:.6}s"
),
"{}/{}{} ({}): {:+.6}±{:.6}(±{:.6})s",
source.name,
source.address,
source.nts_cookies.map_or("", |_| " [NTS]"),
source.id,
source.timedata.offset.to_seconds(),
source.timedata.uncertainty.to_seconds(),
source.timedata.delay.to_seconds(),
source.nts_cookies.map_or(String::new(), |c| format!(
" NTS cookies: {}/{} available\n",
c,
ntp_proto::MAX_COOKIES,
)),
);
println!(
" poll interval: {:.0}s, missing polls: {}",
source.poll_interval.as_duration().to_seconds(),
source.unanswered_polls,
);
println!(
" root dispersion: {:.6}s, root delay:{:.6}s",
source.timedata.remote_uncertainty.to_seconds(),
source.timedata.remote_delay.to_seconds(),
source.timedata.remote_delay.to_seconds()
);
if let Some(nts_cookies) = source.nts_cookies {
println!(
" NTS cookies: {}/{} available",
nts_cookies,
ntp_proto::MAX_COOKIES
)
}
}
println!();
println!("Servers:");
Expand Down

0 comments on commit d2471ca

Please sign in to comment.