Compare commits

...
2 Commits
Author SHA1 Message Date
ktims 7242ed4108 fixes for influx, metrics reporting, etc 2026-09-24 01:02:48 -07:00
ktims b3481686b2 fix chrony refids 2026-09-23 23:47:29 -07:00
5 changed files with 593 additions and 610 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"
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
View File
@@ -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 {
+2 -2
View File
@@ -78,7 +78,7 @@ impl SourceReportDetails for HwmonReport {
for (sensor, value) in &self.values {
metrics.push(SourceMetricSet {
tags: sensor.tags.clone(),
metrics: vec![SourceMetric::new_float("hwmon_value", *value)],
metrics: vec![SourceMetric::new_float("value", *value)],
})
}
// for (sensor, alarm) in &self.alarms {
@@ -145,7 +145,7 @@ impl ChimemonSource for HwmonSource {
}
},
Err(e) => {
error!("Unable to get hwmon sensor value ({})", e.to_string());
error!("Unable to get hwmon sensor value ({}) @ `{:?}`", e.to_string(), s.value_path.to_str());
continue
}
}
+21 -4
View File
@@ -130,10 +130,13 @@ impl SourceReportDetails for UCCMGPSSatsReport {
self.tracked_svs.len() >= 4
}
fn to_metrics(&self) -> Vec<SourceMetricSet> {
vec![SourceMetricSet {
tags: Arc::new(vec![]),
metrics: self.tracked_svs.iter().map(|sv| sv.into()).collect(),
}]
self.tracked_svs
.iter()
.map(|sv| SourceMetricSet {
tags: Arc::new(vec![("sv_id", sv.sv.to_string())]),
metrics: vec![SourceMetric::new_int("sv_cno", sv.cno as i64)],
})
.collect()
}
}
@@ -452,6 +455,20 @@ impl UCCMMonitor {
if sysnow - last_sent_report
>= Duration::from_std(self.config.status_interval).unwrap()
{
if let Err(e) = chan.send(
SourceReport {
name: "uccm".to_owned(),
status: if valid {
SourceStatus::Healthy
} else {
SourceStatus::Unknown
},
details: Arc::new(tod),
}
.into(),
) {
error!(error = ?e, "Unable to send message to channel")
}
if let Some(loop_diag) = &last_loop_diag {
if let Err(e) = chan.send(
SourceReport {