From d11aa11f992d4107d250f71cc4f2e2966844d43a Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Tue, 18 Nov 2025 17:54:51 +0100 Subject: [PATCH] Add Status::Inactive for inactive services with empty circle display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add new Status::Inactive variant to enum for better service state representation - Agent now assigns Status::Inactive instead of Status::Warning for inactive services - Dashboard displays inactive services with empty circle (○) icon in gray color - User-stopped services still show as Status::Ok with green filled circle - Inactive services treated as OK for host status aggregation - Improves visual clarity between active (●), inactive (○), and warning (◐) states --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/collectors/backup.rs | 2 ++ agent/src/collectors/systemd.rs | 3 ++- dashboard/Cargo.toml | 2 +- dashboard/src/ui/mod.rs | 1 + dashboard/src/ui/theme.rs | 3 +++ dashboard/src/ui/widgets/services.rs | 1 + shared/Cargo.toml | 2 +- shared/src/metrics.rs | 11 +++++++++++ 10 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c93c57..db22c33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.75" +version = "0.1.76" dependencies = [ "anyhow", "chrono", @@ -292,7 +292,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.75" +version = "0.1.76" dependencies = [ "anyhow", "async-trait", @@ -315,7 +315,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.75" +version = "0.1.76" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index c4873f1..79ca9ae 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.76" +version = "0.1.77" edition = "2021" [dependencies] diff --git a/agent/src/collectors/backup.rs b/agent/src/collectors/backup.rs index ad3ec76..babea7a 100644 --- a/agent/src/collectors/backup.rs +++ b/agent/src/collectors/backup.rs @@ -136,6 +136,7 @@ impl Collector for BackupCollector { name: "backup_overall_status".to_string(), value: MetricValue::String(match overall_status { Status::Ok => "ok".to_string(), + Status::Inactive => "inactive".to_string(), Status::Pending => "pending".to_string(), Status::Warning => "warning".to_string(), Status::Critical => "critical".to_string(), @@ -199,6 +200,7 @@ impl Collector for BackupCollector { name: format!("backup_service_{}_status", service_name), value: MetricValue::String(match service_status { Status::Ok => "ok".to_string(), + Status::Inactive => "inactive".to_string(), Status::Pending => "pending".to_string(), Status::Warning => "warning".to_string(), Status::Critical => "critical".to_string(), diff --git a/agent/src/collectors/systemd.rs b/agent/src/collectors/systemd.rs index df20579..afa8daf 100644 --- a/agent/src/collectors/systemd.rs +++ b/agent/src/collectors/systemd.rs @@ -372,7 +372,8 @@ impl SystemdCollector { debug!("Service '{}' is inactive but marked as user-stopped - treating as OK", service_name); Status::Ok } else { - Status::Warning + debug!("Service '{}' is inactive - treating as Inactive status", service_name); + Status::Inactive } }, "failed" | "error" => Status::Critical, diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 81c532d..28e31a7 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.76" +version = "0.1.77" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index 46b8f0a..936a8f5 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -718,6 +718,7 @@ impl TuiApp { Status::Warning => has_warning = true, Status::Pending => has_pending = true, Status::Ok => ok_count += 1, + Status::Inactive => ok_count += 1, // Treat inactive as OK for aggregation Status::Unknown => {}, // Ignore unknown for aggregation Status::Offline => {}, // Ignore offline for aggregation } diff --git a/dashboard/src/ui/theme.rs b/dashboard/src/ui/theme.rs index dbcdd4c..2905f74 100644 --- a/dashboard/src/ui/theme.rs +++ b/dashboard/src/ui/theme.rs @@ -143,6 +143,7 @@ impl Theme { pub fn status_color(status: Status) -> Color { match status { Status::Ok => Self::success(), + Status::Inactive => Self::muted_text(), // Gray for inactive services Status::Pending => Self::highlight(), // Blue for pending Status::Warning => Self::warning(), Status::Critical => Self::error(), @@ -243,6 +244,7 @@ impl StatusIcons { pub fn get_icon(status: Status) -> &'static str { match status { Status::Ok => "●", + Status::Inactive => "○", // Empty circle for inactive services Status::Pending => "◉", // Hollow circle for pending Status::Warning => "◐", Status::Critical => "!", @@ -256,6 +258,7 @@ impl StatusIcons { let icon = Self::get_icon(status); let status_color = match status { Status::Ok => Theme::success(), // Green + Status::Inactive => Theme::muted_text(), // Gray for inactive services Status::Pending => Theme::highlight(), // Blue Status::Warning => Theme::warning(), // Yellow Status::Critical => Theme::error(), // Red diff --git a/dashboard/src/ui/widgets/services.rs b/dashboard/src/ui/widgets/services.rs index dc9829e..f68dfe1 100644 --- a/dashboard/src/ui/widgets/services.rs +++ b/dashboard/src/ui/widgets/services.rs @@ -144,6 +144,7 @@ impl ServicesWidget { let icon = StatusIcons::get_icon(info.widget_status); let status_color = match info.widget_status { Status::Ok => Theme::success(), + Status::Inactive => Theme::muted_text(), Status::Pending => Theme::highlight(), Status::Warning => Theme::warning(), Status::Critical => Theme::error(), diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 6e6087f..30f1d82 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.76" +version = "0.1.77" edition = "2021" [dependencies] diff --git a/shared/src/metrics.rs b/shared/src/metrics.rs index fb98c70..57a5a00 100644 --- a/shared/src/metrics.rs +++ b/shared/src/metrics.rs @@ -83,6 +83,7 @@ impl MetricValue { #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub enum Status { Ok, + Inactive, Pending, Warning, Critical, @@ -181,6 +182,16 @@ impl HysteresisThresholds { Status::Ok } } + Status::Inactive => { + // Inactive services use normal thresholds like first measurement + if value >= self.critical_high { + Status::Critical + } else if value >= self.warning_high { + Status::Warning + } else { + Status::Ok + } + } Status::Pending => { // Service transitioning, use normal thresholds like first measurement if value >= self.critical_high {