This commit is contained in:
2025-10-12 17:25:15 +02:00
parent 4bb36b7735
commit 088c42e55a
2 changed files with 74 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ fn render_metrics(
let mut data = WidgetData::new(
title,
Some(WidgetStatus::new(widget_status)),
vec!["Service".to_string(), "Memory".to_string(), "Disk".to_string()]
vec!["Service".to_string(), "Memory".to_string(), "CPU".to_string(), "Disk".to_string()]
);
@@ -60,6 +60,7 @@ fn render_metrics(
"No services reported".to_string(),
"".to_string(),
"".to_string(),
"".to_string(),
],
);
render_widget_data(frame, area, data);
@@ -94,6 +95,7 @@ fn render_metrics(
vec![
svc.name.clone(),
format_memory_value(svc.memory_used_mb, svc.memory_quota_mb),
format_cpu_value(svc.cpu_percent),
format_disk_value(svc.disk_used_gb),
],
);
@@ -140,6 +142,16 @@ fn format_memory_value(used: f32, quota: f32) -> String {
}
}
fn format_cpu_value(cpu_percent: f32) -> String {
if cpu_percent >= 0.1 {
format!("{:.1}%", cpu_percent)
} else if cpu_percent > 0.0 {
"<0.1%".to_string()
} else {
"".to_string()
}
}
fn format_disk_value(used: f32) -> String {
if used >= 1.0 {
format!("{:.1} GiB", used)