fix chrony refids
This commit is contained in:
Generated
+545
-601
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -29,10 +29,10 @@ backoff = { version = "0.4.0", features = ["tokio"] }
|
||||
serde_repr = "0.1.20"
|
||||
tracing = "0.1.44"
|
||||
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"
|
||||
bitflags = "2.10.0"
|
||||
influxdb2 = { version = "0.5.2" }
|
||||
influxdb2 = { version = "0.5.2", default-features = false, features = ["rustls"] }
|
||||
chrono = "0.4.43"
|
||||
serde_with = "3.16.1"
|
||||
ctrlc = "3.5.1"
|
||||
|
||||
+23
-1
@@ -2,6 +2,7 @@ use std::net::{SocketAddr, ToSocketAddrs};
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use chrony_candm::common::ChronyAddr;
|
||||
use chrony_candm::reply::{self, ReplyBody, SourceMode};
|
||||
use chrony_candm::request::{self, RequestBody};
|
||||
use chrony_candm::{ClientOptions, blocking_query};
|
||||
@@ -40,6 +41,23 @@ pub struct ChronyTrackingReport {
|
||||
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 {
|
||||
fn is_healthy(&self) -> bool {
|
||||
true
|
||||
@@ -79,8 +97,12 @@ impl SourceReportDetails for ChronySourcesReport {
|
||||
let mut metrics = Vec::with_capacity(self.sources.len());
|
||||
|
||||
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![
|
||||
("ref_id", source.ip_addr.to_string()),
|
||||
("ref_id", ref_id),
|
||||
(
|
||||
"mode",
|
||||
match source.mode {
|
||||
|
||||
Reference in New Issue
Block a user