mirror of
https://github.com/csehviktor/status-monitor.git
synced 2025-08-08 18:06:14 +02:00
use shared constant for message interval
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use common::MQTT_SEND_INTERVAL;
|
||||
use collector::Collector;
|
||||
use std::time::Duration;
|
||||
use mqtt::MqttHandle;
|
||||
@@ -19,9 +20,6 @@ struct Args {
|
||||
|
||||
#[arg(long, default_value_t = 1883)]
|
||||
port: u16,
|
||||
|
||||
#[arg(long, short='i', default_value_t = 5)]
|
||||
interval: u64,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -37,6 +35,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
let metrics = collector.collect_all();
|
||||
client.send_metrics(metrics).await?;
|
||||
|
||||
thread::sleep(Duration::from_secs(args.interval));
|
||||
thread::sleep(Duration::from_secs(MQTT_SEND_INTERVAL));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::metrics::Metrics;
|
||||
pub mod metrics;
|
||||
|
||||
pub const MQTT_TOPIC: &str = "system/metrics";
|
||||
pub const MQTT_SEND_INTERVAL: u64 = 5;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct StatusMessage<'a> {
|
||||
|
||||
Reference in New Issue
Block a user