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> { async fn query(&self, request: RequestBody) -> Result<reply::Reply, std::io::Error> {
let server = self.server; let server = self.server.clone();
let client_options = self.client_options; let client_options = self.client_options.clone();
tokio::task::spawn_blocking(move || blocking_query(request, client_options, &server)) tokio::task::spawn_blocking(move || blocking_query(request, client_options, &server))
.await .await
.map_err(|e| { .map_err(|e| {

View File

@ -42,8 +42,16 @@ impl ChimemonTarget for ChronySockServer {
{ {
let frame = ChronyTimeReport { let frame = ChronyTimeReport {
tv: timeval { tv: timeval {
tv_sec: tr.system_time.timestamp(), tv_sec: tr
tv_usec: tr.system_time.timestamp(), .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, offset: tr.offset.num_nanoseconds().unwrap() as f64 / 1e9,
leap: if tr.leap_flag { 1 } else { 0 }, 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(key, value)
} }
builder = builder builder = builder
.tag("name", &s.name) .tag("sensor", &s.name)
.tag("sensor", &s.sensor)
.tag("device", &s.device)
.field("value", sensor_val.trim().parse::<i64>().unwrap()); .field("value", sensor_val.trim().parse::<i64>().unwrap());
builder.build().unwrap() builder.build().unwrap()
}); });

View File

@ -68,8 +68,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} else { } else {
None None
}; };
if let Some(c) = chrony { match chrony {
tasks.push(tokio::spawn(c.run(sourcechan.clone()))); Some(c) => {
tasks.push(tokio::spawn(c.run(sourcechan.clone())));
}
None => (),
}; };
let hwmon = if config.sources.hwmon.enabled { let hwmon = if config.sources.hwmon.enabled {
@ -77,8 +80,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} else { } else {
None None
}; };
if let Some(hwmon) = hwmon { match hwmon {
tasks.push(tokio::spawn(hwmon.run(sourcechan.clone()))); Some(hwmon) => {
tasks.push(tokio::spawn(hwmon.run(sourcechan.clone())));
}
None => (),
}; };
let uccm = if config.sources.uccm.enabled { let uccm = if config.sources.uccm.enabled {
@ -88,8 +94,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("UCCMMonitor not configured"); info!("UCCMMonitor not configured");
None None
}; };
if let Some(uccm) = uccm { match uccm {
tasks.push(tokio::spawn(uccm.run(sourcechan.clone()))); Some(uccm) => {
tasks.push(tokio::spawn(uccm.run(sourcechan.clone())));
}
None => (),
}; };
let chrony_refclock = if config.targets.chrony.enabled { let chrony_refclock = if config.targets.chrony.enabled {
@ -97,8 +106,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} else { } else {
None None
}; };
if let Some(chrony_refclock) = chrony_refclock { match chrony_refclock {
tasks.push(tokio::spawn(chrony_refclock.run(sourcechan.subscribe()))); Some(chrony_refclock) => {
tasks.push(tokio::spawn(chrony_refclock.run(sourcechan.subscribe())));
}
None => (),
}; };
let mut influxrx = sourcechan.subscribe(); 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> { fn try_from(strbuf: &[u8]) -> Result<Self, Self::Error> {
debug!("TOD buffer: `{:#?}`", String::from_utf8(strbuf.to_vec())); debug!("TOD buffer: `{:#?}`", String::from_utf8(strbuf.to_vec()));
let resp: Vec<u8> = strbuf 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)) .map(|x| u8::from_str_radix(str::from_utf8(x).unwrap_or(""), 16).unwrap_or(0))
.collect(); .collect();
let mut rdr = Cursor::new(resp); let mut rdr = Cursor::new(resp);
@ -257,7 +257,9 @@ impl TryFrom<&str> for UCCMLoopDiagReport {
"No lines!", "No lines!",
))??; ))??;
let ocxo_val = ocxo_line let ocxo_val = ocxo_line
.split(':').nth(1) .split(':')
.skip(1)
.next()
.ok_or(std::io::Error::new( .ok_or(std::io::Error::new(
std::io::ErrorKind::InvalidData, std::io::ErrorKind::InvalidData,
"no colon!", "no colon!",
@ -280,7 +282,7 @@ impl TryFrom<&str> for UCCMGPSSatsReport {
"Invalid response (expected `NSATS CNOS`)", "Invalid response (expected `NSATS CNOS`)",
))?; ))?;
let nsats = nsats.parse::<u8>().map_err(|e| { 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 let tracked_svs = cnos
.split(',') .split(',')
@ -319,7 +321,7 @@ impl UCCMMonitor {
rx, rx,
tx, tx,
info: None, info: None,
config, config: config,
} }
} }
@ -420,7 +422,11 @@ impl UCCMMonitor {
system_time: sysnow, system_time: sysnow,
offset, offset,
leaps: tod.leaps as isize, 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, valid,
})) }))
.expect("Unable to send to channel"); .expect("Unable to send to channel");