- Rename alerts widget to hosts widget for clarity - Add sub_service field to ServiceInfo for display differentiation - Integrate system metrics (CPU load, memory, temperature, disk) as service rows - Convert nginx sites to individual sub-service rows with tree structure - Remove nginx site checkmarks - status now shown via row indicators - Update dashboard layout to display system and service data together - Maintain description lines for connection counts and service details Services widget now shows: - System metrics as regular service rows with status - Nginx sites as sub-services with ├─/└─ tree formatting - Regular services with full resource data and descriptions - Unified status indication across all row types
174 lines
4.2 KiB
Rust
174 lines
4.2 KiB
Rust
#![allow(dead_code)]
|
|
|
|
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct SmartMetrics {
|
|
pub status: String,
|
|
pub drives: Vec<DriveInfo>,
|
|
pub summary: DriveSummary,
|
|
pub issues: Vec<String>,
|
|
pub timestamp: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct DriveInfo {
|
|
pub name: String,
|
|
pub temperature_c: f32,
|
|
pub wear_level: f32,
|
|
pub power_on_hours: u64,
|
|
pub available_spare: f32,
|
|
pub capacity_gb: Option<f32>,
|
|
pub used_gb: Option<f32>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct DriveSummary {
|
|
pub healthy: usize,
|
|
pub warning: usize,
|
|
pub critical: usize,
|
|
pub capacity_total_gb: f32,
|
|
pub capacity_used_gb: f32,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct SystemMetrics {
|
|
pub summary: SystemSummary,
|
|
pub timestamp: u64,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct SystemSummary {
|
|
pub cpu_load_1: f32,
|
|
pub cpu_load_5: f32,
|
|
pub cpu_load_15: f32,
|
|
#[serde(default)]
|
|
pub cpu_status: Option<String>,
|
|
pub memory_used_mb: f32,
|
|
pub memory_total_mb: f32,
|
|
pub memory_usage_percent: f32,
|
|
#[serde(default)]
|
|
pub memory_status: Option<String>,
|
|
#[serde(default)]
|
|
pub cpu_temp_c: Option<f32>,
|
|
#[serde(default)]
|
|
pub cpu_temp_status: Option<String>,
|
|
#[serde(default)]
|
|
pub cpu_cstate: Option<Vec<String>>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ServiceMetrics {
|
|
pub summary: ServiceSummary,
|
|
pub services: Vec<ServiceInfo>,
|
|
pub timestamp: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ServiceSummary {
|
|
pub healthy: usize,
|
|
pub degraded: usize,
|
|
pub failed: usize,
|
|
#[serde(default)]
|
|
pub services_status: Option<String>,
|
|
pub memory_used_mb: f32,
|
|
pub memory_quota_mb: f32,
|
|
#[serde(default)]
|
|
pub system_memory_used_mb: f32,
|
|
#[serde(default)]
|
|
pub system_memory_total_mb: f32,
|
|
#[serde(default)]
|
|
pub memory_status: Option<String>,
|
|
#[serde(default)]
|
|
pub disk_used_gb: f32,
|
|
#[serde(default)]
|
|
pub disk_total_gb: f32,
|
|
#[serde(default)]
|
|
pub cpu_load_1: f32,
|
|
#[serde(default)]
|
|
pub cpu_load_5: f32,
|
|
#[serde(default)]
|
|
pub cpu_load_15: f32,
|
|
#[serde(default)]
|
|
pub cpu_status: Option<String>,
|
|
#[serde(default)]
|
|
pub cpu_cstate: Option<Vec<String>>,
|
|
#[serde(default)]
|
|
pub cpu_temp_c: Option<f32>,
|
|
#[serde(default)]
|
|
pub cpu_temp_status: Option<String>,
|
|
#[serde(default)]
|
|
pub gpu_load_percent: Option<f32>,
|
|
#[serde(default)]
|
|
pub gpu_temp_c: Option<f32>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ServiceInfo {
|
|
pub name: String,
|
|
pub status: ServiceStatus,
|
|
pub memory_used_mb: f32,
|
|
pub memory_quota_mb: f32,
|
|
pub cpu_percent: f32,
|
|
pub sandbox_limit: Option<f32>,
|
|
#[serde(default)]
|
|
pub disk_used_gb: f32,
|
|
#[serde(default)]
|
|
pub description: Option<Vec<String>>,
|
|
#[serde(default)]
|
|
pub sub_service: bool,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum ServiceStatus {
|
|
Running,
|
|
Degraded,
|
|
Restarting,
|
|
Stopped,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct BackupMetrics {
|
|
pub overall_status: String,
|
|
pub backup: BackupInfo,
|
|
pub service: BackupServiceInfo,
|
|
#[serde(default)]
|
|
pub disk: Option<BackupDiskInfo>,
|
|
pub timestamp: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct BackupInfo {
|
|
pub last_success: Option<DateTime<Utc>>,
|
|
pub last_failure: Option<DateTime<Utc>>,
|
|
pub size_gb: f32,
|
|
#[serde(default)]
|
|
pub latest_archive_size_gb: Option<f32>,
|
|
pub snapshot_count: u32,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct BackupServiceInfo {
|
|
pub enabled: bool,
|
|
pub pending_jobs: u32,
|
|
pub last_message: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct BackupDiskInfo {
|
|
pub device: String,
|
|
pub health: String,
|
|
pub total_gb: f32,
|
|
pub used_gb: f32,
|
|
pub usage_percent: f32,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum BackupStatus {
|
|
Healthy,
|
|
Warning,
|
|
Failed,
|
|
Unknown,
|
|
}
|