diff options
author | gennyble <gen@nyble.dev> | 2025-02-23 06:08:09 -0600 |
---|---|---|
committer | gennyble <gen@nyble.dev> | 2025-02-23 06:08:09 -0600 |
commit | e60e9fae45915a4ca4457dfdc9794980e373b1f1 (patch) | |
tree | 6fb7fcf9787ecbddf384ead4e9b42d941ba04e36 /src/gatherer.rs | |
parent | f5f103404857fb4f21cf71ac72fd5aa88baed95a (diff) | |
download | awake-e60e9fae45915a4ca4457dfdc9794980e373b1f1.tar.gz awake-e60e9fae45915a4ca4457dfdc9794980e373b1f1.zip |
Conf key to turn off statistics
Diffstat (limited to 'src/gatherer.rs')
-rw-r--r-- | src/gatherer.rs | 19 |
1 files changed, 19 insertions, 0 deletions
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<Netinfo> = None; // this is a `let _` because otherwise the attribute was |