about summary refs log tree commit diff
path: root/src/gatherer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gatherer.rs')
-rw-r--r--src/gatherer.rs19
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