Compare commits
2
Commits
c22ad764e6
...
7242ed4108
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7242ed4108 | ||
|
|
b3481686b2 |
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 {
|
||||
|
||||
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user