about summary refs log tree commit diff
path: root/src/gatherer.rs
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2025-10-16 10:29:39 -0500
committergennyble <gen@nyble.dev>2025-10-16 10:29:39 -0500
commit19b1df3315fd7d291d8188899274c6e51f3c337f (patch)
tree411f8ba850f31e137533b876543e26deac5b85a1 /src/gatherer.rs
parent03e5e364279222b6a983a66f344ac6ddc8c3fcf9 (diff)
downloadawake-19b1df3315fd7d291d8188899274c6e51f3c337f.tar.gz
awake-19b1df3315fd7d291d8188899274c6e51f3c337f.zip
change cpu graph to use continuous line
Diffstat (limited to 'src/gatherer.rs')
-rw-r--r--src/gatherer.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/gatherer.rs b/src/gatherer.rs
index accd50d..329bc1e 100644
--- a/src/gatherer.rs
+++ b/src/gatherer.rs
@@ -117,7 +117,7 @@ pub fn make_mem_graph(state: &AwakeState) {
 	let infos = state.database.get_last_n_host_meminfo(256);
 	let max = infos[0].total_kb;
 
-	let now = OffsetDateTime::now_utc();
+	let now = get_clean_now();
 	let cleaned = clean_series(&infos, |mem| mem.stamp, now);
 	let mut usages: Vec<Option<usize>> = cleaned
 		.into_iter()
@@ -128,7 +128,7 @@ pub fn make_mem_graph(state: &AwakeState) {
 	// right side, so last in the array
 	usages.reverse();
 
-	let gif = griph::make_1line(0, max, &usages, Style::Line);
+	let gif = griph::make_1line(0, max, &usages, Style::Discontinuous);
 
 	let path = state.cache_path.join("current_hostmeminfo.gif");
 	gif.save(path).unwrap();
@@ -139,7 +139,7 @@ const NET_INCREMENTS: usize = 256;
 pub fn make_net_graph(state: &AwakeState) {
 	tracing::debug!("generating netinfo graph");
 
-	let now = OffsetDateTime::now_utc();
+	let now = get_clean_now();
 	let infos = state.database.get_last_n_hostnet(256);
 	let cleaned = clean_series(&infos, |net| net.stamp, now);
 
@@ -188,6 +188,14 @@ pub fn make_net_graph(state: &AwakeState) {
 
 	tracing::debug!("tx_sum = {tx_sum} // rx_sum = {rx_sum} // order = {order:?}");
 
+	/*for (idx, (tx, rx)) in tx_deltas.iter().zip(rx_deltas).enumerate() {
+		println!(
+			"[{idx:<03}] tx = {} / rx = {}",
+			tx.unwrap_or_default(),
+			rx.unwrap_or_default()
+		);
+	}*/
+
 	let gif = griph::make_2line(0, high_bound, &tx_deltas, &rx_deltas, order);
 
 	let path = state.cache_path.join("current_hostnetinfo.gif");
@@ -199,7 +207,7 @@ pub fn make_cpu_graph(state: &AwakeState) {
 
 	let infos = state.database.get_last_n_hostcpu(256);
 
-	let now = OffsetDateTime::now_utc();
+	let now = get_clean_now();
 	let cleaned = clean_series(&infos, |cpu| cpu.stamp, now);
 
 	// Usages are of the unit of hundreths of a second of CPU usage averaged over a minute.
@@ -233,12 +241,16 @@ pub fn make_cpu_graph(state: &AwakeState) {
 	// right side, so last in the array
 	scaled.reverse();
 
-	let gif = griph::make_1line(0, 1000, &scaled, Style::UnderfilledLine);
+	let gif = griph::make_1line(0, 1000, &scaled, Style::Line);
 
 	let path = state.cache_path.join("current_hostcpuinfo.gif");
 	gif.save(path).unwrap();
 }
 
+fn get_clean_now() -> OffsetDateTime {
+	OffsetDateTime::now_utc().replace_second(0).unwrap()
+}
+
 fn clean_series<T, F>(series: &[T], time_extractor: F, end_time: OffsetDateTime) -> [Option<T>; 256]
 where
 	F: Fn(&T) -> OffsetDateTime,