Compare commits

..

No commits in common. "bb0e721e6cb6cb1de73088852a0dde67b1b30d97" and "d7c57cf23aa064e578d566f27a2668ba287d3010" have entirely different histories.

5 changed files with 44 additions and 20 deletions

View File

@ -114,8 +114,8 @@ impl ChronyClient {
}
}
async fn query(&self, request: RequestBody) -> Result<reply::Reply, std::io::Error> {
let server = self.server;
let client_options = self.client_options;
let server = self.server.clone();
let client_options = self.client_options.clone();
tokio::task::spawn_blocking(move || blocking_query(request, client_options, &server))
.await
.map_err(|e| {

View File

@ -42,8 +42,16 @@ impl ChimemonTarget for ChronySockServer {
{
let frame = ChronyTimeReport {
tv: timeval {
tv_sec: tr.system_time.timestamp(),
tv_usec: tr.system_time.timestamp(),
tv_sec: tr
.system_time
.timestamp()
.try_into()
.unwrap_or_default(),
tv_usec: tr
.system_time
.timestamp()
.try_into()
.unwrap_or_default(),
},
offset: tr.offset.num_nanoseconds().unwrap() as f64 / 1e9,
leap: if tr.leap_flag { 1 } else { 0 },

View File

@ -69,9 +69,7 @@ impl ChimemonSource for HwmonSource {
builder = builder.tag(key, value)
}
builder = builder
.tag("name", &s.name)
.tag("sensor", &s.sensor)
.tag("device", &s.device)
.tag("sensor", &s.name)
.field("value", sensor_val.trim().parse::<i64>().unwrap());
builder.build().unwrap()
});

View File

@ -68,8 +68,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} else {
None
};
if let Some(c) = chrony {
tasks.push(tokio::spawn(c.run(sourcechan.clone())));
match chrony {
Some(c) => {
tasks.push(tokio::spawn(c.run(sourcechan.clone())));
}
None => (),
};
let hwmon = if config.sources.hwmon.enabled {
@ -77,8 +80,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} else {
None
};
if let Some(hwmon) = hwmon {
tasks.push(tokio::spawn(hwmon.run(sourcechan.clone())));
match hwmon {
Some(hwmon) => {
tasks.push(tokio::spawn(hwmon.run(sourcechan.clone())));
}
None => (),
};
let uccm = if config.sources.uccm.enabled {
@ -88,8 +94,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("UCCMMonitor not configured");
None
};
if let Some(uccm) = uccm {
tasks.push(tokio::spawn(uccm.run(sourcechan.clone())));
match uccm {
Some(uccm) => {
tasks.push(tokio::spawn(uccm.run(sourcechan.clone())));
}
None => (),
};
let chrony_refclock = if config.targets.chrony.enabled {
@ -97,8 +106,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} else {
None
};
if let Some(chrony_refclock) = chrony_refclock {
tasks.push(tokio::spawn(chrony_refclock.run(sourcechan.subscribe())));
match chrony_refclock {
Some(chrony_refclock) => {
tasks.push(tokio::spawn(chrony_refclock.run(sourcechan.subscribe())));
}
None => (),
};
let mut influxrx = sourcechan.subscribe();

View File

@ -206,7 +206,7 @@ impl TryFrom<&[u8]> for UCCMTODReport {
fn try_from(strbuf: &[u8]) -> Result<Self, Self::Error> {
debug!("TOD buffer: `{:#?}`", String::from_utf8(strbuf.to_vec()));
let resp: Vec<u8> = strbuf
.split(|c| *c == b' ')
.split(|c| *c == ' ' as u8)
.map(|x| u8::from_str_radix(str::from_utf8(x).unwrap_or(""), 16).unwrap_or(0))
.collect();
let mut rdr = Cursor::new(resp);
@ -257,7 +257,9 @@ impl TryFrom<&str> for UCCMLoopDiagReport {
"No lines!",
))??;
let ocxo_val = ocxo_line
.split(':').nth(1)
.split(':')
.skip(1)
.next()
.ok_or(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"no colon!",
@ -280,7 +282,7 @@ impl TryFrom<&str> for UCCMGPSSatsReport {
"Invalid response (expected `NSATS CNOS`)",
))?;
let nsats = nsats.parse::<u8>().map_err(|e| {
std::io::Error::new(std::io::ErrorKind::InvalidData, format!("Invalid number of sats ({e})"))
std::io::Error::new(std::io::ErrorKind::InvalidData, "Invalid number of sats")
})?;
let tracked_svs = cnos
.split(',')
@ -319,7 +321,7 @@ impl UCCMMonitor {
rx,
tx,
info: None,
config,
config: config,
}
}
@ -420,7 +422,11 @@ impl UCCMMonitor {
system_time: sysnow,
offset,
leaps: tod.leaps as isize,
leap_flag: tod.flags.contains(UCCMFlags::LEAP_FLAG),
leap_flag: if tod.flags.contains(UCCMFlags::LEAP_FLAG) {
true
} else {
false
},
valid,
}))
.expect("Unable to send to channel");