mirror of
				https://github.com/csehviktor/status-monitor.git
				synced 2025-08-08 18:06:14 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			620 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			620 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use config::{load_config, Config};
 | |
| use mqtt::MqttHandle;
 | |
| use collector::Collector;
 | |
| use std::time::Duration;
 | |
| use std::thread;
 | |
| 
 | |
| pub mod collector;
 | |
| pub mod config;
 | |
| pub mod mqtt;
 | |
| pub mod cpu;
 | |
| 
 | |
| #[tokio::main]
 | |
| async fn main() -> anyhow::Result<()> {
 | |
|     let cfg = load_config()?;
 | |
|     let cfg: &'static mut Config = Box::leak(Box::new(cfg));
 | |
| 
 | |
|     let client = MqttHandle::create(&mut cfg.mqtt).await;
 | |
|     let mut collector = Collector::new();
 | |
| 
 | |
|     loop {
 | |
|         let metrics = collector.collect_all();
 | |
|         client.send_metrics(metrics).await?;
 | |
| 
 | |
|         thread::sleep(Duration::from_secs(cfg.send_interval_seconds));
 | |
|     }
 | |
| }
 |