mirror of
				https://github.com/csehviktor/status-monitor.git
				synced 2025-08-08 18:06:14 +02:00 
			
		
		
		
	improve agent + config
This commit is contained in:
		| @@ -1,19 +1,23 @@ | ||||
| use config::{load_config, Config}; | ||||
| use mqtt::MqttHandle; | ||||
| use collector::Collector; | ||||
| use std::time::Duration; | ||||
| use std::thread; | ||||
| use std::time; | ||||
|  | ||||
| pub mod collector; | ||||
|  | ||||
| const REFRESH_INTERVAL: u64 = 3000; | ||||
| #[tokio::main] | ||||
| async fn main() -> anyhow::Result<()> { | ||||
|     let cfg = load_config()?; | ||||
|     let cfg: &'static mut Config = Box::leak(Box::new(cfg)); | ||||
|  | ||||
| fn main() { | ||||
|     let client = MqttHandle::create(&mut cfg.mqtt).await; | ||||
|     let mut collector = Collector::new(); | ||||
|  | ||||
|     loop { | ||||
|         let metrics = collector.collect_all(); | ||||
|         client.send_metrics(metrics).await?; | ||||
|  | ||||
|         println!("Metrics: {:?}", metrics); | ||||
|  | ||||
|         thread::sleep(time::Duration::from_millis(REFRESH_INTERVAL)); | ||||
|         thread::sleep(Duration::from_secs(cfg.send_interval_seconds)); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user