Add Status::Inactive for inactive services with empty circle display
All checks were successful
Build and Release / build-and-release (push) Successful in 1m12s

- 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
This commit is contained in:
Christoffer Martinsson 2025-11-18 17:54:51 +01:00
parent 0ca06d2507
commit d11aa11f99
10 changed files with 26 additions and 7 deletions

6
Cargo.lock generated
View File

@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]] [[package]]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.75" version = "0.1.76"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -292,7 +292,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.75" version = "0.1.76"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -315,7 +315,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.75" version = "0.1.76"
dependencies = [ dependencies = [
"chrono", "chrono",
"serde", "serde",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.76" version = "0.1.77"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -136,6 +136,7 @@ impl Collector for BackupCollector {
name: "backup_overall_status".to_string(), name: "backup_overall_status".to_string(),
value: MetricValue::String(match overall_status { value: MetricValue::String(match overall_status {
Status::Ok => "ok".to_string(), Status::Ok => "ok".to_string(),
Status::Inactive => "inactive".to_string(),
Status::Pending => "pending".to_string(), Status::Pending => "pending".to_string(),
Status::Warning => "warning".to_string(), Status::Warning => "warning".to_string(),
Status::Critical => "critical".to_string(), Status::Critical => "critical".to_string(),
@ -199,6 +200,7 @@ impl Collector for BackupCollector {
name: format!("backup_service_{}_status", service_name), name: format!("backup_service_{}_status", service_name),
value: MetricValue::String(match service_status { value: MetricValue::String(match service_status {
Status::Ok => "ok".to_string(), Status::Ok => "ok".to_string(),
Status::Inactive => "inactive".to_string(),
Status::Pending => "pending".to_string(), Status::Pending => "pending".to_string(),
Status::Warning => "warning".to_string(), Status::Warning => "warning".to_string(),
Status::Critical => "critical".to_string(), Status::Critical => "critical".to_string(),

View File

@ -372,7 +372,8 @@ impl SystemdCollector {
debug!("Service '{}' is inactive but marked as user-stopped - treating as OK", service_name); debug!("Service '{}' is inactive but marked as user-stopped - treating as OK", service_name);
Status::Ok Status::Ok
} else { } else {
Status::Warning debug!("Service '{}' is inactive - treating as Inactive status", service_name);
Status::Inactive
} }
}, },
"failed" | "error" => Status::Critical, "failed" | "error" => Status::Critical,

View File

@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.76" version = "0.1.77"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -718,6 +718,7 @@ impl TuiApp {
Status::Warning => has_warning = true, Status::Warning => has_warning = true,
Status::Pending => has_pending = true, Status::Pending => has_pending = true,
Status::Ok => ok_count += 1, Status::Ok => ok_count += 1,
Status::Inactive => ok_count += 1, // Treat inactive as OK for aggregation
Status::Unknown => {}, // Ignore unknown for aggregation Status::Unknown => {}, // Ignore unknown for aggregation
Status::Offline => {}, // Ignore offline for aggregation Status::Offline => {}, // Ignore offline for aggregation
} }

View File

@ -143,6 +143,7 @@ impl Theme {
pub fn status_color(status: Status) -> Color { pub fn status_color(status: Status) -> Color {
match status { match status {
Status::Ok => Self::success(), Status::Ok => Self::success(),
Status::Inactive => Self::muted_text(), // Gray for inactive services
Status::Pending => Self::highlight(), // Blue for pending Status::Pending => Self::highlight(), // Blue for pending
Status::Warning => Self::warning(), Status::Warning => Self::warning(),
Status::Critical => Self::error(), Status::Critical => Self::error(),
@ -243,6 +244,7 @@ impl StatusIcons {
pub fn get_icon(status: Status) -> &'static str { pub fn get_icon(status: Status) -> &'static str {
match status { match status {
Status::Ok => "", Status::Ok => "",
Status::Inactive => "", // Empty circle for inactive services
Status::Pending => "", // Hollow circle for pending Status::Pending => "", // Hollow circle for pending
Status::Warning => "", Status::Warning => "",
Status::Critical => "!", Status::Critical => "!",
@ -256,6 +258,7 @@ impl StatusIcons {
let icon = Self::get_icon(status); let icon = Self::get_icon(status);
let status_color = match status { let status_color = match status {
Status::Ok => Theme::success(), // Green Status::Ok => Theme::success(), // Green
Status::Inactive => Theme::muted_text(), // Gray for inactive services
Status::Pending => Theme::highlight(), // Blue Status::Pending => Theme::highlight(), // Blue
Status::Warning => Theme::warning(), // Yellow Status::Warning => Theme::warning(), // Yellow
Status::Critical => Theme::error(), // Red Status::Critical => Theme::error(), // Red

View File

@ -144,6 +144,7 @@ impl ServicesWidget {
let icon = StatusIcons::get_icon(info.widget_status); let icon = StatusIcons::get_icon(info.widget_status);
let status_color = match info.widget_status { let status_color = match info.widget_status {
Status::Ok => Theme::success(), Status::Ok => Theme::success(),
Status::Inactive => Theme::muted_text(),
Status::Pending => Theme::highlight(), Status::Pending => Theme::highlight(),
Status::Warning => Theme::warning(), Status::Warning => Theme::warning(),
Status::Critical => Theme::error(), Status::Critical => Theme::error(),

View File

@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.76" version = "0.1.77"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@ -83,6 +83,7 @@ impl MetricValue {
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum Status { pub enum Status {
Ok, Ok,
Inactive,
Pending, Pending,
Warning, Warning,
Critical, Critical,
@ -181,6 +182,16 @@ impl HysteresisThresholds {
Status::Ok 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 => { Status::Pending => {
// Service transitioning, use normal thresholds like first measurement // Service transitioning, use normal thresholds like first measurement
if value >= self.critical_high { if value >= self.critical_high {