fix chrony refids

This commit is contained in:
2026-09-23 23:47:29 -07:00
parent c22ad764e6
commit b3481686b2
3 changed files with 570 additions and 604 deletions
Generated
+545 -601
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -29,10 +29,10 @@ backoff = { version = "0.4.0", features = ["tokio"] }
serde_repr = "0.1.20" serde_repr = "0.1.20"
tracing = "0.1.44" tracing = "0.1.44"
tracing-subscriber = { version = "0.3.22", features = ["fmt", "ansi", "time", "env-filter"] } tracing-subscriber = { version = "0.3.22", features = ["fmt", "ansi", "time", "env-filter"] }
serialport = "4.8.1" serialport = { version = "4.8.1", default-features = false }
gethostname = "1.1.0" gethostname = "1.1.0"
bitflags = "2.10.0" bitflags = "2.10.0"
influxdb2 = { version = "0.5.2" } influxdb2 = { version = "0.5.2", default-features = false, features = ["rustls"] }
chrono = "0.4.43" chrono = "0.4.43"
serde_with = "3.16.1" serde_with = "3.16.1"
ctrlc = "3.5.1" ctrlc = "3.5.1"
+23 -1
View File
@@ -2,6 +2,7 @@ use std::net::{SocketAddr, ToSocketAddrs};
use std::sync::Arc; use std::sync::Arc;
use async_trait::async_trait; use async_trait::async_trait;
use chrony_candm::common::ChronyAddr;
use chrony_candm::reply::{self, ReplyBody, SourceMode}; use chrony_candm::reply::{self, ReplyBody, SourceMode};
use chrony_candm::request::{self, RequestBody}; use chrony_candm::request::{self, RequestBody};
use chrony_candm::{ClientOptions, blocking_query}; use chrony_candm::{ClientOptions, blocking_query};
@@ -40,6 +41,23 @@ pub struct ChronyTrackingReport {
pub last_update_interval: f64, pub last_update_interval: f64,
} }
pub fn addr_to_string(addr: &ChronyAddr) -> String {
match addr {
ChronyAddr::V4(a) => a
.octets()
.iter()
.map_while(|c| {
if *c == 0 {
None
} else {
Some(char::from_u32(*c as u32).unwrap())
}
})
.collect(),
_ => addr.to_string(),
}
}
impl SourceReportDetails for ChronyTrackingReport { impl SourceReportDetails for ChronyTrackingReport {
fn is_healthy(&self) -> bool { fn is_healthy(&self) -> bool {
true true
@@ -79,8 +97,12 @@ impl SourceReportDetails for ChronySourcesReport {
let mut metrics = Vec::with_capacity(self.sources.len()); let mut metrics = Vec::with_capacity(self.sources.len());
for source in &self.sources { for source in &self.sources {
let ref_id = match source.stratum {
0 => addr_to_string(&source.ip_addr),
_ => source.ip_addr.to_string(),
};
let tags = Arc::new(vec![ let tags = Arc::new(vec![
("ref_id", source.ip_addr.to_string()), ("ref_id", ref_id),
( (
"mode", "mode",
match source.mode { match source.mode {