From e60e9fae45915a4ca4457dfdc9794980e373b1f1 Mon Sep 17 00:00:00 2001 From: gennyble Date: Sun, 23 Feb 2025 06:08:09 -0600 Subject: Conf key to turn off statistics --- src/gatherer.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/gatherer.rs') diff --git a/src/gatherer.rs b/src/gatherer.rs index b1fa416..9b2a80a 100644 --- a/src/gatherer.rs +++ b/src/gatherer.rs @@ -31,10 +31,29 @@ impl Gatherer { fn task(state: AwakeState) { tracing::info!("starting gatherer thread"); + if !state.do_statistics { + tracing::warn!("statistics disabled"); + return; + } + // I just want a graph on first boot; don't care about divisions just yet make_mem_graph(&state); make_net_graph(&state); + // If we collected a point less than a minute ago, like after + // just being restarted, wait until it's been a minute + let last_meminfo = state.database.get_last_host_meminfo(); + let since = OffsetDateTime::now_utc() - last_meminfo.stamp; + if since < time::Duration::minutes(1) { + let to_minute = time::Duration::minutes(1) - since; + + tracing::info!( + "waiting for {}s to space a minute apart", + to_minute.whole_seconds() + ); + std::thread::sleep(to_minute.try_into().unwrap()); + } + let mut last_netinfo: Option = None; // this is a `let _` because otherwise the attribute was -- cgit 1.4.1-3-g733a5