Compare commits
	
		
			2 Commits
		
	
	
		
			d7c57cf23a
			...
			bb0e721e6c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| bb0e721e6c | |||
| cef472d2c5 | 
| @@ -114,8 +114,8 @@ impl ChronyClient { | ||||
|         } | ||||
|     } | ||||
|     async fn query(&self, request: RequestBody) -> Result<reply::Reply, std::io::Error> { | ||||
|         let server = self.server.clone(); | ||||
|         let client_options = self.client_options.clone(); | ||||
|         let server = self.server; | ||||
|         let client_options = self.client_options; | ||||
|         tokio::task::spawn_blocking(move || blocking_query(request, client_options, &server)) | ||||
|             .await | ||||
|             .map_err(|e| { | ||||
|   | ||||
| @@ -42,16 +42,8 @@ impl ChimemonTarget for ChronySockServer { | ||||
|                         { | ||||
|                             let frame = ChronyTimeReport { | ||||
|                                 tv: timeval { | ||||
|                                     tv_sec: tr | ||||
|                                         .system_time | ||||
|                                         .timestamp() | ||||
|                                         .try_into() | ||||
|                                         .unwrap_or_default(), | ||||
|                                     tv_usec: tr | ||||
|                                         .system_time | ||||
|                                         .timestamp() | ||||
|                                         .try_into() | ||||
|                                         .unwrap_or_default(), | ||||
|                                     tv_sec: tr.system_time.timestamp(), | ||||
|                                     tv_usec: tr.system_time.timestamp(), | ||||
|                                 }, | ||||
|                                 offset: tr.offset.num_nanoseconds().unwrap() as f64 / 1e9, | ||||
|                                 leap: if tr.leap_flag { 1 } else { 0 }, | ||||
|   | ||||
| @@ -69,7 +69,9 @@ impl ChimemonSource for HwmonSource { | ||||
|                     builder = builder.tag(key, value) | ||||
|                 } | ||||
|                 builder = builder | ||||
|                     .tag("sensor", &s.name) | ||||
|                     .tag("name", &s.name) | ||||
|                     .tag("sensor", &s.sensor) | ||||
|                     .tag("device", &s.device) | ||||
|                     .field("value", sensor_val.trim().parse::<i64>().unwrap()); | ||||
|                 builder.build().unwrap() | ||||
|             }); | ||||
|   | ||||
							
								
								
									
										28
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -68,11 +68,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|     } else { | ||||
|         None | ||||
|     }; | ||||
|     match chrony { | ||||
|         Some(c) => { | ||||
|             tasks.push(tokio::spawn(c.run(sourcechan.clone()))); | ||||
|         } | ||||
|         None => (), | ||||
|     if let Some(c) = chrony { | ||||
|         tasks.push(tokio::spawn(c.run(sourcechan.clone()))); | ||||
|     }; | ||||
|  | ||||
|     let hwmon = if config.sources.hwmon.enabled { | ||||
| @@ -80,11 +77,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|     } else { | ||||
|         None | ||||
|     }; | ||||
|     match hwmon { | ||||
|         Some(hwmon) => { | ||||
|             tasks.push(tokio::spawn(hwmon.run(sourcechan.clone()))); | ||||
|         } | ||||
|         None => (), | ||||
|     if let Some(hwmon) = hwmon { | ||||
|         tasks.push(tokio::spawn(hwmon.run(sourcechan.clone()))); | ||||
|     }; | ||||
|  | ||||
|     let uccm = if config.sources.uccm.enabled { | ||||
| @@ -94,11 +88,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|         info!("UCCMMonitor not configured"); | ||||
|         None | ||||
|     }; | ||||
|     match uccm { | ||||
|         Some(uccm) => { | ||||
|             tasks.push(tokio::spawn(uccm.run(sourcechan.clone()))); | ||||
|         } | ||||
|         None => (), | ||||
|     if let Some(uccm) = uccm { | ||||
|         tasks.push(tokio::spawn(uccm.run(sourcechan.clone()))); | ||||
|     }; | ||||
|  | ||||
|     let chrony_refclock = if config.targets.chrony.enabled { | ||||
| @@ -106,11 +97,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|     } else { | ||||
|         None | ||||
|     }; | ||||
|     match chrony_refclock { | ||||
|         Some(chrony_refclock) => { | ||||
|             tasks.push(tokio::spawn(chrony_refclock.run(sourcechan.subscribe()))); | ||||
|         } | ||||
|         None => (), | ||||
|     if let Some(chrony_refclock) = chrony_refclock { | ||||
|         tasks.push(tokio::spawn(chrony_refclock.run(sourcechan.subscribe()))); | ||||
|     }; | ||||
|  | ||||
|     let mut influxrx = sourcechan.subscribe(); | ||||
|   | ||||
							
								
								
									
										16
									
								
								src/uccm.rs
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/uccm.rs
									
									
									
									
									
								
							| @@ -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 == ' ' as u8) | ||||
|             .split(|c| *c == b' ') | ||||
|             .map(|x| u8::from_str_radix(str::from_utf8(x).unwrap_or(""), 16).unwrap_or(0)) | ||||
|             .collect(); | ||||
|         let mut rdr = Cursor::new(resp); | ||||
| @@ -257,9 +257,7 @@ impl TryFrom<&str> for UCCMLoopDiagReport { | ||||
|                 "No lines!", | ||||
|             ))??; | ||||
|             let ocxo_val = ocxo_line | ||||
|                 .split(':') | ||||
|                 .skip(1) | ||||
|                 .next() | ||||
|                 .split(':').nth(1) | ||||
|                 .ok_or(std::io::Error::new( | ||||
|                     std::io::ErrorKind::InvalidData, | ||||
|                     "no colon!", | ||||
| @@ -282,7 +280,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, "Invalid number of sats") | ||||
|             std::io::Error::new(std::io::ErrorKind::InvalidData, format!("Invalid number of sats ({e})")) | ||||
|         })?; | ||||
|         let tracked_svs = cnos | ||||
|             .split(',') | ||||
| @@ -321,7 +319,7 @@ impl UCCMMonitor { | ||||
|             rx, | ||||
|             tx, | ||||
|             info: None, | ||||
|             config: config, | ||||
|             config, | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -422,11 +420,7 @@ impl UCCMMonitor { | ||||
|                                 system_time: sysnow, | ||||
|                                 offset, | ||||
|                                 leaps: tod.leaps as isize, | ||||
|                                 leap_flag: if tod.flags.contains(UCCMFlags::LEAP_FLAG) { | ||||
|                                     true | ||||
|                                 } else { | ||||
|                                     false | ||||
|                                 }, | ||||
|                                 leap_flag: tod.flags.contains(UCCMFlags::LEAP_FLAG), | ||||
|                                 valid, | ||||
|                             })) | ||||
|                             .expect("Unable to send to channel"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user