Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f23a1b5cec | |||
| 3f98f68b51 | |||
| 3d38a7a984 | |||
| b0ee0242bd | |||
| 8f9e9eabca | |||
| 937f4ad427 | |||
| 8aefab83ae | |||
| 748a9f3a3b | |||
| 5c6b11c794 | |||
| 9f0aa5f806 | |||
| fc247bd0ad | |||
| 00fe8c28ab | |||
| fbbb4a4cfb | |||
| 53e1d8bbce | |||
| 1b9fecea98 | |||
| b7ffeaced5 | |||
| 3858309a5d | |||
| df104bf940 | |||
| d5ce36ee18 | |||
| 4f80701671 | |||
| 267654fda4 | |||
| dc1105eefe | |||
| c9d12793ef |
@@ -113,13 +113,13 @@ jobs:
|
|||||||
NIX_HASH="sha256-$(python3 -c "import base64, binascii; print(base64.b64encode(binascii.unhexlify('$NEW_HASH')).decode())")"
|
NIX_HASH="sha256-$(python3 -c "import base64, binascii; print(base64.b64encode(binascii.unhexlify('$NEW_HASH')).decode())")"
|
||||||
|
|
||||||
# Update the NixOS configuration
|
# Update the NixOS configuration
|
||||||
sed -i "s|version = \"v[^\"]*\"|version = \"$VERSION\"|" hosts/services/cm-dashboard.nix
|
sed -i "s|version = \"v[^\"]*\"|version = \"$VERSION\"|" services/cm-dashboard.nix
|
||||||
sed -i "s|sha256 = \"sha256-[^\"]*\"|sha256 = \"$NIX_HASH\"|" hosts/services/cm-dashboard.nix
|
sed -i "s|sha256 = \"sha256-[^\"]*\"|sha256 = \"$NIX_HASH\"|" services/cm-dashboard.nix
|
||||||
|
|
||||||
# Commit and push changes
|
# Commit and push changes
|
||||||
git config user.name "Gitea Actions"
|
git config user.name "Gitea Actions"
|
||||||
git config user.email "actions@gitea.cmtec.se"
|
git config user.email "actions@gitea.cmtec.se"
|
||||||
git add hosts/services/cm-dashboard.nix
|
git add services/cm-dashboard.nix
|
||||||
git commit -m "Auto-update cm-dashboard to $VERSION
|
git commit -m "Auto-update cm-dashboard to $VERSION
|
||||||
|
|
||||||
- Update version to $VERSION with automated release
|
- Update version to $VERSION with automated release
|
||||||
|
|||||||
116
CLAUDE.md
116
CLAUDE.md
@@ -304,28 +304,28 @@ exclude_fs_types = ["tmpfs", "devtmpfs", "sysfs", "proc"]
|
|||||||
### Display Format
|
### Display Format
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Network:
|
||||||
|
● eno1:
|
||||||
|
├─ ip: 192.168.30.105
|
||||||
|
└─ tailscale0: 100.125.108.16
|
||||||
|
● eno2:
|
||||||
|
└─ ip: 192.168.32.105
|
||||||
CPU:
|
CPU:
|
||||||
● Load: 0.23 0.21 0.13
|
● Load: 0.23 0.21 0.13
|
||||||
└─ Freq: 1048 MHz
|
└─ Freq: 1048 MHz
|
||||||
|
|
||||||
RAM:
|
RAM:
|
||||||
● Usage: 25% 5.8GB/23.3GB
|
● Usage: 25% 5.8GB/23.3GB
|
||||||
├─ ● /tmp: 2% 0.5GB/2GB
|
├─ ● /tmp: 2% 0.5GB/2GB
|
||||||
└─ ● /var/tmp: 0% 0GB/1.0GB
|
└─ ● /var/tmp: 0% 0GB/1.0GB
|
||||||
|
|
||||||
Storage:
|
Storage:
|
||||||
● mergerfs (2+1):
|
● 844B9A25 T: 25C W: 4%
|
||||||
├─ Total: ● 63% 2355.2GB/3686.4GB
|
|
||||||
├─ Data Disks:
|
|
||||||
│ ├─ ● sdb T: 24°C W: 5%
|
|
||||||
│ └─ ● sdd T: 27°C W: 5%
|
|
||||||
├─ Parity: ● sdc T: 24°C W: 5%
|
|
||||||
└─ Mount: /srv/media
|
|
||||||
|
|
||||||
● nvme0n1 T: 25C W: 4%
|
|
||||||
├─ ● /: 55% 250.5GB/456.4GB
|
├─ ● /: 55% 250.5GB/456.4GB
|
||||||
└─ ● /boot: 26% 0.3GB/1.0GB
|
└─ ● /boot: 26% 0.3GB/1.0GB
|
||||||
|
● mergerfs /srv/media:
|
||||||
|
├─ ● 63% 2355.2GB/3686.4GB
|
||||||
|
├─ ● Data_1: WDZQ8H8D T: 28°C
|
||||||
|
├─ ● Data_2: GGA04461 T: 28°C
|
||||||
|
└─ ● Parity: WDZS8RY0 T: 29°C
|
||||||
Backup:
|
Backup:
|
||||||
● WD-WCC7K1234567 T: 32°C W: 12%
|
● WD-WCC7K1234567 T: 32°C W: 12%
|
||||||
├─ Last: 2h ago (12.3GB)
|
├─ Last: 2h ago (12.3GB)
|
||||||
@@ -361,98 +361,6 @@ Keep responses concise and focused. Avoid extensive implementation summaries unl
|
|||||||
- ✅ "Restructure storage widget with improved layout"
|
- ✅ "Restructure storage widget with improved layout"
|
||||||
- ✅ "Update CPU thresholds to production values"
|
- ✅ "Update CPU thresholds to production values"
|
||||||
|
|
||||||
## Completed Architecture Migration (v0.1.131)
|
|
||||||
|
|
||||||
## ✅ COMPLETE MONITORING SYSTEM RESTORATION (v0.1.141)
|
|
||||||
|
|
||||||
**🎉 SUCCESS: All Issues Fixed - Complete Functional Monitoring System**
|
|
||||||
|
|
||||||
### ✅ Completed Implementation (v0.1.141)
|
|
||||||
|
|
||||||
**All Major Issues Resolved:**
|
|
||||||
```
|
|
||||||
✅ Data Collection: Agent collects structured data correctly
|
|
||||||
✅ Storage Display: Perfect format with correct mount points and temperature/wear
|
|
||||||
✅ Status Evaluation: All metrics properly evaluated against thresholds
|
|
||||||
✅ Notifications: Working email alerts on status changes
|
|
||||||
✅ Thresholds: All collectors using configured thresholds for status calculation
|
|
||||||
✅ Build Information: NixOS version displayed correctly
|
|
||||||
✅ Mount Point Consistency: Stable, sorted display order
|
|
||||||
```
|
|
||||||
|
|
||||||
### ✅ All Phases Completed Successfully
|
|
||||||
|
|
||||||
#### ✅ Phase 1: Storage Display - COMPLETED
|
|
||||||
- ✅ Use `lsblk` instead of `findmnt` (eliminated `/nix/store` bind mount issue)
|
|
||||||
- ✅ Add `sudo smartctl` for permissions (SMART data collection working)
|
|
||||||
- ✅ Fix NVMe SMART parsing (`Temperature:` and `Percentage Used:` fields)
|
|
||||||
- ✅ Consistent filesystem/tmpfs sorting (no more random order swapping)
|
|
||||||
- ✅ **VERIFIED**: Dashboard shows `● nvme0n1 T: 28°C W: 1%` correctly
|
|
||||||
|
|
||||||
#### ✅ Phase 2: Status Evaluation System - COMPLETED
|
|
||||||
- ✅ **CPU Status**: Load averages and temperature evaluated against `HysteresisThresholds`
|
|
||||||
- ✅ **Memory Status**: Usage percentage evaluated against thresholds
|
|
||||||
- ✅ **Storage Status**: Drive temperature, health, and filesystem usage evaluated
|
|
||||||
- ✅ **Service Status**: Service states properly tracked and evaluated
|
|
||||||
- ✅ **Status Fields**: All AgentData structures include status information
|
|
||||||
- ✅ **Threshold Integration**: All collectors use their configured thresholds
|
|
||||||
|
|
||||||
#### ✅ Phase 3: Notification System - COMPLETED
|
|
||||||
- ✅ **Status Change Detection**: Agent tracks status between collection cycles
|
|
||||||
- ✅ **Email Notifications**: Alerts sent on degradation (OK→Warning/Critical, Warning→Critical)
|
|
||||||
- ✅ **Notification Content**: Detailed alerts with metric values and timestamps
|
|
||||||
- ✅ **NotificationManager Integration**: Fully restored and operational
|
|
||||||
- ✅ **Maintenance Mode**: `/tmp/cm-maintenance` file support maintained
|
|
||||||
|
|
||||||
#### ✅ Phase 4: Integration & Testing - COMPLETED
|
|
||||||
- ✅ **AgentData Status Fields**: All structured data includes status evaluation
|
|
||||||
- ✅ **Status Processing**: Agent applies thresholds at collection time
|
|
||||||
- ✅ **End-to-End Flow**: Collection → Evaluation → Notification → Display
|
|
||||||
- ✅ **Dynamic Versioning**: Agent version from `CARGO_PKG_VERSION`
|
|
||||||
- ✅ **Build Information**: NixOS generation display restored
|
|
||||||
|
|
||||||
### ✅ Final Architecture - WORKING
|
|
||||||
|
|
||||||
**Complete Operational Flow:**
|
|
||||||
```
|
|
||||||
Collectors → AgentData (with Status) → NotificationManager → Email Alerts
|
|
||||||
↘ ↗
|
|
||||||
ZMQ → Dashboard → Perfect Display
|
|
||||||
```
|
|
||||||
|
|
||||||
**Operational Components:**
|
|
||||||
1. ✅ **Collectors**: Populate AgentData with metrics AND status evaluation
|
|
||||||
2. ✅ **Status Evaluation**: `HysteresisThresholds.evaluate()` applied per collector
|
|
||||||
3. ✅ **Notifications**: Email alerts on status change detection
|
|
||||||
4. ✅ **Display**: Correct mount points, temperature, wear, and build information
|
|
||||||
|
|
||||||
### ✅ Success Criteria - ALL MET
|
|
||||||
|
|
||||||
**Display Requirements:**
|
|
||||||
- ✅ Dashboard shows `● nvme0n1 T: 28°C W: 1%` format perfectly
|
|
||||||
- ✅ Mount points show `/` and `/boot` (not `root`/`boot`)
|
|
||||||
- ✅ Build information shows actual NixOS version (not "unknown")
|
|
||||||
- ✅ Consistent sorting eliminates random order changes
|
|
||||||
|
|
||||||
**Monitoring Requirements:**
|
|
||||||
- ✅ High CPU load triggers Warning/Critical status and email alert
|
|
||||||
- ✅ High memory usage triggers Warning/Critical status and email alert
|
|
||||||
- ✅ High disk temperature triggers Warning/Critical status and email alert
|
|
||||||
- ✅ Failed services trigger Warning/Critical status and email alert
|
|
||||||
- ✅ Maintenance mode suppresses notifications as expected
|
|
||||||
|
|
||||||
### 🚀 Production Ready
|
|
||||||
|
|
||||||
**CM Dashboard v0.1.141 is a complete, functional infrastructure monitoring system:**
|
|
||||||
|
|
||||||
- **Real-time Monitoring**: All system components with 1-second intervals
|
|
||||||
- **Intelligent Alerting**: Email notifications on threshold violations
|
|
||||||
- **Perfect Display**: Accurate mount points, temperatures, and system information
|
|
||||||
- **Status-Aware**: All metrics evaluated against configurable thresholds
|
|
||||||
- **Production Ready**: Full monitoring capabilities restored
|
|
||||||
|
|
||||||
**The monitoring system is fully operational and ready for production use.**
|
|
||||||
|
|
||||||
## Implementation Rules
|
## Implementation Rules
|
||||||
|
|
||||||
1. **Agent Status Authority**: Agent calculates status for each metric using thresholds
|
1. **Agent Status Authority**: Agent calculates status for each metric using thresholds
|
||||||
|
|||||||
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.153"
|
version = "0.1.175"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.153"
|
version = "0.1.175"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -324,7 +324,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.153"
|
version = "0.1.175"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.153"
|
version = "0.1.175"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ use crate::collectors::{
|
|||||||
cpu::CpuCollector,
|
cpu::CpuCollector,
|
||||||
disk::DiskCollector,
|
disk::DiskCollector,
|
||||||
memory::MemoryCollector,
|
memory::MemoryCollector,
|
||||||
|
network::NetworkCollector,
|
||||||
nixos::NixOSCollector,
|
nixos::NixOSCollector,
|
||||||
systemd::SystemdCollector,
|
systemd::SystemdCollector,
|
||||||
};
|
};
|
||||||
use crate::notifications::NotificationManager;
|
use crate::notifications::NotificationManager;
|
||||||
use crate::service_tracker::UserStoppedServiceTracker;
|
|
||||||
use cm_dashboard_shared::AgentData;
|
use cm_dashboard_shared::AgentData;
|
||||||
|
|
||||||
pub struct Agent {
|
pub struct Agent {
|
||||||
@@ -25,7 +25,6 @@ pub struct Agent {
|
|||||||
zmq_handler: ZmqHandler,
|
zmq_handler: ZmqHandler,
|
||||||
collectors: Vec<Box<dyn Collector>>,
|
collectors: Vec<Box<dyn Collector>>,
|
||||||
notification_manager: NotificationManager,
|
notification_manager: NotificationManager,
|
||||||
service_tracker: UserStoppedServiceTracker,
|
|
||||||
previous_status: Option<SystemStatus>,
|
previous_status: Option<SystemStatus>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +78,11 @@ impl Agent {
|
|||||||
if config.collectors.backup.enabled {
|
if config.collectors.backup.enabled {
|
||||||
collectors.push(Box::new(BackupCollector::new()));
|
collectors.push(Box::new(BackupCollector::new()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.collectors.network.enabled {
|
||||||
|
collectors.push(Box::new(NetworkCollector::new(config.collectors.network.clone())));
|
||||||
|
}
|
||||||
|
|
||||||
if config.collectors.nixos.enabled {
|
if config.collectors.nixos.enabled {
|
||||||
collectors.push(Box::new(NixOSCollector::new(config.collectors.nixos.clone())));
|
collectors.push(Box::new(NixOSCollector::new(config.collectors.nixos.clone())));
|
||||||
}
|
}
|
||||||
@@ -90,17 +93,12 @@ impl Agent {
|
|||||||
let notification_manager = NotificationManager::new(&config.notifications, &hostname)?;
|
let notification_manager = NotificationManager::new(&config.notifications, &hostname)?;
|
||||||
info!("Notification manager initialized");
|
info!("Notification manager initialized");
|
||||||
|
|
||||||
// Initialize service tracker
|
|
||||||
let service_tracker = UserStoppedServiceTracker::new();
|
|
||||||
info!("Service tracker initialized");
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
hostname,
|
hostname,
|
||||||
config,
|
config,
|
||||||
zmq_handler,
|
zmq_handler,
|
||||||
collectors,
|
collectors,
|
||||||
notification_manager,
|
notification_manager,
|
||||||
service_tracker,
|
|
||||||
previous_status: None,
|
previous_status: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use chrono::{NaiveDateTime, DateTime};
|
|
||||||
use cm_dashboard_shared::{AgentData, BackupData, BackupDiskData};
|
use cm_dashboard_shared::{AgentData, BackupData, BackupDiskData};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ pub struct DiskCollector {
|
|||||||
/// A physical drive with its filesystems
|
/// A physical drive with its filesystems
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct PhysicalDrive {
|
struct PhysicalDrive {
|
||||||
name: String, // e.g., "nvme0n1", "sda"
|
name: String, // e.g., "nvme0n1", "sda"
|
||||||
health: String, // SMART health status
|
health: String, // SMART health status
|
||||||
temperature_celsius: Option<f32>, // Drive temperature
|
|
||||||
wear_percent: Option<f32>, // SSD wear level
|
|
||||||
filesystems: Vec<Filesystem>, // mounted filesystems on this drive
|
filesystems: Vec<Filesystem>, // mounted filesystems on this drive
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,8 +349,6 @@ impl DiskCollector {
|
|||||||
let physical_drive = PhysicalDrive {
|
let physical_drive = PhysicalDrive {
|
||||||
name: drive_name,
|
name: drive_name,
|
||||||
health: "UNKNOWN".to_string(), // Will be updated with SMART data
|
health: "UNKNOWN".to_string(), // Will be updated with SMART data
|
||||||
temperature_celsius: None,
|
|
||||||
wear_percent: None,
|
|
||||||
filesystems,
|
filesystems,
|
||||||
};
|
};
|
||||||
physical_drives.push(physical_drive);
|
physical_drives.push(physical_drive);
|
||||||
@@ -437,12 +433,14 @@ impl DiskCollector {
|
|||||||
// Return unknown data rather than failing completely
|
// Return unknown data rather than failing completely
|
||||||
return Ok(SmartData {
|
return Ok(SmartData {
|
||||||
health: "UNKNOWN".to_string(),
|
health: "UNKNOWN".to_string(),
|
||||||
|
serial_number: None,
|
||||||
temperature_celsius: None,
|
temperature_celsius: None,
|
||||||
wear_percent: None,
|
wear_percent: None,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut health = "UNKNOWN".to_string();
|
let mut health = "UNKNOWN".to_string();
|
||||||
|
let mut serial_number = None;
|
||||||
let mut temperature = None;
|
let mut temperature = None;
|
||||||
let mut wear_percent = None;
|
let mut wear_percent = None;
|
||||||
|
|
||||||
@@ -455,8 +453,21 @@ impl DiskCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serial number parsing (both SATA and NVMe)
|
||||||
|
if line.contains("Serial Number:") {
|
||||||
|
if let Some(serial_part) = line.split("Serial Number:").nth(1) {
|
||||||
|
let serial_str = serial_part.trim();
|
||||||
|
if !serial_str.is_empty() {
|
||||||
|
// Take first whitespace-separated token
|
||||||
|
if let Some(serial) = serial_str.split_whitespace().next() {
|
||||||
|
serial_number = Some(serial.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Temperature parsing for different drive types
|
// Temperature parsing for different drive types
|
||||||
if line.contains("Temperature_Celsius") || line.contains("Airflow_Temperature_Cel") {
|
if line.contains("Temperature_Celsius") || line.contains("Airflow_Temperature_Cel") || line.contains("Temperature_Case") {
|
||||||
// Traditional SATA drives: attribute table format
|
// Traditional SATA drives: attribute table format
|
||||||
if let Some(temp_str) = line.split_whitespace().nth(9) {
|
if let Some(temp_str) = line.split_whitespace().nth(9) {
|
||||||
if let Ok(temp) = temp_str.parse::<f32>() {
|
if let Ok(temp) = temp_str.parse::<f32>() {
|
||||||
@@ -474,7 +485,15 @@ impl DiskCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wear level parsing for SSDs
|
// Wear level parsing for SSDs
|
||||||
if line.contains("Wear_Leveling_Count") || line.contains("SSD_Life_Left") {
|
if line.contains("Media_Wearout_Indicator") {
|
||||||
|
// Media_Wearout_Indicator stores remaining life % in column 3 (VALUE)
|
||||||
|
if let Some(wear_str) = line.split_whitespace().nth(3) {
|
||||||
|
if let Ok(remaining) = wear_str.parse::<f32>() {
|
||||||
|
wear_percent = Some(100.0 - remaining); // Convert remaining life to wear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if line.contains("Wear_Leveling_Count") || line.contains("SSD_Life_Left") {
|
||||||
|
// Other wear attributes store value in column 9 (RAW_VALUE)
|
||||||
if let Some(wear_str) = line.split_whitespace().nth(9) {
|
if let Some(wear_str) = line.split_whitespace().nth(9) {
|
||||||
if let Ok(wear) = wear_str.parse::<f32>() {
|
if let Ok(wear) = wear_str.parse::<f32>() {
|
||||||
wear_percent = Some(100.0 - wear); // Convert remaining life to wear
|
wear_percent = Some(100.0 - wear); // Convert remaining life to wear
|
||||||
@@ -497,6 +516,7 @@ impl DiskCollector {
|
|||||||
|
|
||||||
Ok(SmartData {
|
Ok(SmartData {
|
||||||
health,
|
health,
|
||||||
|
serial_number,
|
||||||
temperature_celsius: temperature,
|
temperature_celsius: temperature,
|
||||||
wear_percent,
|
wear_percent,
|
||||||
})
|
})
|
||||||
@@ -522,6 +542,7 @@ impl DiskCollector {
|
|||||||
|
|
||||||
agent_data.system.storage.drives.push(DriveData {
|
agent_data.system.storage.drives.push(DriveData {
|
||||||
name: drive.name.clone(),
|
name: drive.name.clone(),
|
||||||
|
serial_number: smart.and_then(|s| s.serial_number.clone()),
|
||||||
health: smart.map(|s| s.health.clone()).unwrap_or_else(|| drive.health.clone()),
|
health: smart.map(|s| s.health.clone()).unwrap_or_else(|| drive.health.clone()),
|
||||||
temperature_celsius: smart.and_then(|s| s.temperature_celsius),
|
temperature_celsius: smart.and_then(|s| s.temperature_celsius),
|
||||||
wear_percent: smart.and_then(|s| s.wear_percent),
|
wear_percent: smart.and_then(|s| s.wear_percent),
|
||||||
@@ -587,6 +608,7 @@ impl DiskCollector {
|
|||||||
|
|
||||||
cm_dashboard_shared::PoolDriveData {
|
cm_dashboard_shared::PoolDriveData {
|
||||||
name: d.name.clone(),
|
name: d.name.clone(),
|
||||||
|
serial_number: smart.and_then(|s| s.serial_number.clone()),
|
||||||
temperature_celsius: temperature,
|
temperature_celsius: temperature,
|
||||||
health,
|
health,
|
||||||
wear_percent: smart.and_then(|s| s.wear_percent),
|
wear_percent: smart.and_then(|s| s.wear_percent),
|
||||||
@@ -611,6 +633,7 @@ impl DiskCollector {
|
|||||||
|
|
||||||
cm_dashboard_shared::PoolDriveData {
|
cm_dashboard_shared::PoolDriveData {
|
||||||
name: d.name.clone(),
|
name: d.name.clone(),
|
||||||
|
serial_number: smart.and_then(|s| s.serial_number.clone()),
|
||||||
temperature_celsius: temperature,
|
temperature_celsius: temperature,
|
||||||
health,
|
health,
|
||||||
wear_percent: smart.and_then(|s| s.wear_percent),
|
wear_percent: smart.and_then(|s| s.wear_percent),
|
||||||
@@ -620,10 +643,19 @@ impl DiskCollector {
|
|||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
// Calculate overall pool health string and status
|
// Calculate overall pool health string and status
|
||||||
let (pool_health, health_status) = match (failed_data, failed_parity) {
|
// SnapRAID logic: can tolerate up to N parity drive failures (where N = number of parity drives)
|
||||||
(0, 0) => ("healthy".to_string(), cm_dashboard_shared::Status::Ok),
|
// If data drives fail AND we've lost parity protection, that's critical
|
||||||
(1, 0) | (0, 1) => ("degraded".to_string(), cm_dashboard_shared::Status::Warning),
|
let (pool_health, health_status) = if failed_data == 0 && failed_parity == 0 {
|
||||||
_ => ("critical".to_string(), cm_dashboard_shared::Status::Critical),
|
("healthy".to_string(), cm_dashboard_shared::Status::Ok)
|
||||||
|
} else if failed_data == 0 && failed_parity > 0 {
|
||||||
|
// Parity failed but no data loss - degraded (reduced protection)
|
||||||
|
("degraded".to_string(), cm_dashboard_shared::Status::Warning)
|
||||||
|
} else if failed_data == 1 && failed_parity == 0 {
|
||||||
|
// One data drive failed, parity intact - degraded (recoverable)
|
||||||
|
("degraded".to_string(), cm_dashboard_shared::Status::Warning)
|
||||||
|
} else {
|
||||||
|
// Multiple data drives failed OR data+parity failed = data loss risk
|
||||||
|
("critical".to_string(), cm_dashboard_shared::Status::Critical)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Calculate pool usage status using config thresholds
|
// Calculate pool usage status using config thresholds
|
||||||
@@ -808,6 +840,7 @@ impl Collector for DiskCollector {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct SmartData {
|
struct SmartData {
|
||||||
health: String,
|
health: String,
|
||||||
|
serial_number: Option<String>,
|
||||||
temperature_celsius: Option<f32>,
|
temperature_celsius: Option<f32>,
|
||||||
wear_percent: Option<f32>,
|
wear_percent: Option<f32>,
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ pub mod cpu;
|
|||||||
pub mod disk;
|
pub mod disk;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod memory;
|
pub mod memory;
|
||||||
|
pub mod network;
|
||||||
pub mod nixos;
|
pub mod nixos;
|
||||||
pub mod systemd;
|
pub mod systemd;
|
||||||
|
|
||||||
|
|||||||
224
agent/src/collectors/network.rs
Normal file
224
agent/src/collectors/network.rs
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
use async_trait::async_trait;
|
||||||
|
use cm_dashboard_shared::{AgentData, NetworkInterfaceData, Status};
|
||||||
|
use std::process::Command;
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
|
use super::{Collector, CollectorError};
|
||||||
|
use crate::config::NetworkConfig;
|
||||||
|
|
||||||
|
/// Network interface collector with physical/virtual classification and link status
|
||||||
|
pub struct NetworkCollector {
|
||||||
|
_config: NetworkConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NetworkCollector {
|
||||||
|
pub fn new(config: NetworkConfig) -> Self {
|
||||||
|
Self { _config: config }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if interface is physical (not virtual)
|
||||||
|
fn is_physical_interface(name: &str) -> bool {
|
||||||
|
// Physical interface patterns
|
||||||
|
matches!(
|
||||||
|
&name[..],
|
||||||
|
s if s.starts_with("eth")
|
||||||
|
|| s.starts_with("ens")
|
||||||
|
|| s.starts_with("enp")
|
||||||
|
|| s.starts_with("wlan")
|
||||||
|
|| s.starts_with("wlp")
|
||||||
|
|| s.starts_with("eno")
|
||||||
|
|| s.starts_with("enx")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get link status for an interface
|
||||||
|
fn get_link_status(interface: &str) -> Status {
|
||||||
|
let operstate_path = format!("/sys/class/net/{}/operstate", interface);
|
||||||
|
|
||||||
|
match std::fs::read_to_string(&operstate_path) {
|
||||||
|
Ok(state) => {
|
||||||
|
let state = state.trim();
|
||||||
|
match state {
|
||||||
|
"up" => Status::Ok,
|
||||||
|
"down" => Status::Inactive,
|
||||||
|
"unknown" => Status::Warning,
|
||||||
|
_ => Status::Unknown,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => Status::Unknown,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the primary physical interface (the one with default route)
|
||||||
|
fn get_primary_physical_interface() -> Option<String> {
|
||||||
|
match Command::new("ip").args(["route", "show", "default"]).output() {
|
||||||
|
Ok(output) if output.status.success() => {
|
||||||
|
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||||
|
// Parse: "default via 192.168.1.1 dev eno1 ..."
|
||||||
|
for line in output_str.lines() {
|
||||||
|
if line.starts_with("default") {
|
||||||
|
if let Some(dev_pos) = line.find(" dev ") {
|
||||||
|
let after_dev = &line[dev_pos + 5..];
|
||||||
|
if let Some(space_pos) = after_dev.find(' ') {
|
||||||
|
let interface = &after_dev[..space_pos];
|
||||||
|
// Only return if it's a physical interface
|
||||||
|
if Self::is_physical_interface(interface) {
|
||||||
|
return Some(interface.to_string());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No space after interface name (end of line)
|
||||||
|
let interface = after_dev.trim();
|
||||||
|
if Self::is_physical_interface(interface) {
|
||||||
|
return Some(interface.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parse VLAN configuration from /proc/net/vlan/config
|
||||||
|
/// Returns a map of interface name -> VLAN ID
|
||||||
|
fn parse_vlan_config() -> std::collections::HashMap<String, u16> {
|
||||||
|
let mut vlan_map = std::collections::HashMap::new();
|
||||||
|
|
||||||
|
if let Ok(contents) = std::fs::read_to_string("/proc/net/vlan/config") {
|
||||||
|
for line in contents.lines().skip(2) { // Skip header lines
|
||||||
|
let parts: Vec<&str> = line.split('|').collect();
|
||||||
|
if parts.len() >= 2 {
|
||||||
|
let interface_name = parts[0].trim();
|
||||||
|
let vlan_id_str = parts[1].trim();
|
||||||
|
|
||||||
|
if let Ok(vlan_id) = vlan_id_str.parse::<u16>() {
|
||||||
|
vlan_map.insert(interface_name.to_string(), vlan_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vlan_map
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Collect network interfaces using ip command
|
||||||
|
async fn collect_interfaces(&self) -> Vec<NetworkInterfaceData> {
|
||||||
|
let mut interfaces = Vec::new();
|
||||||
|
|
||||||
|
// Parse VLAN configuration
|
||||||
|
let vlan_map = Self::parse_vlan_config();
|
||||||
|
|
||||||
|
match Command::new("ip").args(["-j", "addr"]).output() {
|
||||||
|
Ok(output) if output.status.success() => {
|
||||||
|
let json_str = String::from_utf8_lossy(&output.stdout);
|
||||||
|
|
||||||
|
if let Ok(json_data) = serde_json::from_str::<serde_json::Value>(&json_str) {
|
||||||
|
if let Some(ifaces) = json_data.as_array() {
|
||||||
|
for iface in ifaces {
|
||||||
|
let name = iface["ifname"].as_str().unwrap_or("").to_string();
|
||||||
|
|
||||||
|
// Skip loopback, empty names, and ifb* interfaces
|
||||||
|
if name.is_empty() || name == "lo" || name.starts_with("ifb") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse parent interface from @parent notation (e.g., lan@enp0s31f6)
|
||||||
|
let (interface_name, parent_interface) = if let Some(at_pos) = name.find('@') {
|
||||||
|
let (child, parent) = name.split_at(at_pos);
|
||||||
|
(child.to_string(), Some(parent[1..].to_string()))
|
||||||
|
} else {
|
||||||
|
(name.clone(), None)
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut ipv4_addresses = Vec::new();
|
||||||
|
let mut ipv6_addresses = Vec::new();
|
||||||
|
|
||||||
|
// Extract IP addresses
|
||||||
|
if let Some(addr_info) = iface["addr_info"].as_array() {
|
||||||
|
for addr in addr_info {
|
||||||
|
if let Some(family) = addr["family"].as_str() {
|
||||||
|
if let Some(local) = addr["local"].as_str() {
|
||||||
|
match family {
|
||||||
|
"inet" => ipv4_addresses.push(local.to_string()),
|
||||||
|
"inet6" => {
|
||||||
|
// Skip link-local IPv6 addresses (fe80::)
|
||||||
|
if !local.starts_with("fe80:") {
|
||||||
|
ipv6_addresses.push(local.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine if physical and get status
|
||||||
|
let is_physical = Self::is_physical_interface(&interface_name);
|
||||||
|
|
||||||
|
// Only filter out virtual interfaces without IPs
|
||||||
|
// Physical interfaces should always be shown even if down/no IPs
|
||||||
|
if !is_physical && ipv4_addresses.is_empty() && ipv6_addresses.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let link_status = if is_physical {
|
||||||
|
Self::get_link_status(&name)
|
||||||
|
} else {
|
||||||
|
Status::Unknown // Virtual interfaces don't have meaningful link status
|
||||||
|
};
|
||||||
|
|
||||||
|
// Look up VLAN ID from the map (use original name before @ parsing)
|
||||||
|
let vlan_id = vlan_map.get(&name).copied();
|
||||||
|
|
||||||
|
interfaces.push(NetworkInterfaceData {
|
||||||
|
name: interface_name,
|
||||||
|
ipv4_addresses,
|
||||||
|
ipv6_addresses,
|
||||||
|
is_physical,
|
||||||
|
link_status,
|
||||||
|
parent_interface,
|
||||||
|
vlan_id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
debug!("Failed to execute ip command: {}", e);
|
||||||
|
}
|
||||||
|
Ok(output) => {
|
||||||
|
debug!("ip command failed with status: {}", output.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign primary physical interface as parent to virtual interfaces without explicit parent
|
||||||
|
let primary_interface = Self::get_primary_physical_interface();
|
||||||
|
if let Some(primary) = primary_interface {
|
||||||
|
for interface in interfaces.iter_mut() {
|
||||||
|
// Only assign parent to virtual interfaces that don't already have one
|
||||||
|
if !interface.is_physical && interface.parent_interface.is_none() {
|
||||||
|
interface.parent_interface = Some(primary.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaces
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Collector for NetworkCollector {
|
||||||
|
async fn collect_structured(&self, agent_data: &mut AgentData) -> Result<(), CollectorError> {
|
||||||
|
debug!("Collecting network interface data");
|
||||||
|
|
||||||
|
// Collect all network interfaces
|
||||||
|
let interfaces = self.collect_interfaces().await;
|
||||||
|
|
||||||
|
agent_data.system.network.interfaces = interfaces;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,21 +5,18 @@ use std::process::Command;
|
|||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use super::{Collector, CollectorError};
|
use super::{Collector, CollectorError};
|
||||||
use crate::config::NixOSConfig;
|
|
||||||
|
|
||||||
/// NixOS system information collector with structured data output
|
/// NixOS system information collector with structured data output
|
||||||
///
|
///
|
||||||
/// This collector gathers NixOS-specific information like:
|
/// This collector gathers NixOS-specific information like:
|
||||||
/// - System generation/build information
|
/// - System generation/build information
|
||||||
/// - Version information
|
/// - Version information
|
||||||
/// - Agent version from Nix store path
|
/// - Agent version from Nix store path
|
||||||
pub struct NixOSCollector {
|
pub struct NixOSCollector;
|
||||||
config: NixOSConfig,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NixOSCollector {
|
impl NixOSCollector {
|
||||||
pub fn new(config: NixOSConfig) -> Self {
|
pub fn new(_config: crate::config::NixOSConfig) -> Self {
|
||||||
Self { config }
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Collect NixOS system information and populate AgentData
|
/// Collect NixOS system information and populate AgentData
|
||||||
@@ -83,14 +80,25 @@ impl NixOSCollector {
|
|||||||
std::env::var("CM_DASHBOARD_VERSION").unwrap_or_else(|_| "unknown".to_string())
|
std::env::var("CM_DASHBOARD_VERSION").unwrap_or_else(|_| "unknown".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get NixOS system generation (build) information
|
/// Get NixOS system generation (build) information from git commit
|
||||||
async fn get_nixos_generation(&self) -> Option<String> {
|
async fn get_nixos_generation(&self) -> Option<String> {
|
||||||
match Command::new("nixos-version").output() {
|
// Try to read git commit hash from file written during rebuild
|
||||||
Ok(output) => {
|
let commit_file = "/var/lib/cm-dashboard/git-commit";
|
||||||
let version_str = String::from_utf8_lossy(&output.stdout);
|
match fs::read_to_string(commit_file) {
|
||||||
Some(version_str.trim().to_string())
|
Ok(content) => {
|
||||||
|
let commit_hash = content.trim();
|
||||||
|
if commit_hash.len() >= 7 {
|
||||||
|
debug!("Found git commit hash: {}", commit_hash);
|
||||||
|
Some(commit_hash.to_string())
|
||||||
|
} else {
|
||||||
|
debug!("Git commit hash too short: {}", commit_hash);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
debug!("Failed to read git commit file {}: {}", commit_file, e);
|
||||||
|
None
|
||||||
}
|
}
|
||||||
Err(_) => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ pub struct SystemdCollector {
|
|||||||
struct ServiceCacheState {
|
struct ServiceCacheState {
|
||||||
/// Last collection time for performance tracking
|
/// Last collection time for performance tracking
|
||||||
last_collection: Option<Instant>,
|
last_collection: Option<Instant>,
|
||||||
/// Cached service data
|
|
||||||
services: Vec<ServiceInfo>,
|
|
||||||
/// Cached complete service data with sub-services
|
/// Cached complete service data with sub-services
|
||||||
cached_service_data: Vec<ServiceData>,
|
cached_service_data: Vec<ServiceData>,
|
||||||
/// Interesting services to monitor (cached after discovery)
|
/// Interesting services to monitor (cached after discovery)
|
||||||
@@ -50,20 +48,10 @@ struct ServiceStatusInfo {
|
|||||||
sub_state: String,
|
sub_state: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Internal service information
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
struct ServiceInfo {
|
|
||||||
name: String,
|
|
||||||
status: String, // "active", "inactive", "failed", etc.
|
|
||||||
memory_mb: f32, // Memory usage in MB
|
|
||||||
disk_gb: f32, // Disk usage in GB
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SystemdCollector {
|
impl SystemdCollector {
|
||||||
pub fn new(config: SystemdConfig) -> Self {
|
pub fn new(config: SystemdConfig) -> Self {
|
||||||
let state = ServiceCacheState {
|
let state = ServiceCacheState {
|
||||||
last_collection: None,
|
last_collection: None,
|
||||||
services: Vec::new(),
|
|
||||||
cached_service_data: Vec::new(),
|
cached_service_data: Vec::new(),
|
||||||
monitored_services: Vec::new(),
|
monitored_services: Vec::new(),
|
||||||
service_status_cache: std::collections::HashMap::new(),
|
service_status_cache: std::collections::HashMap::new(),
|
||||||
@@ -73,7 +61,7 @@ impl SystemdCollector {
|
|||||||
last_nginx_check_time: None,
|
last_nginx_check_time: None,
|
||||||
nginx_check_interval_seconds: config.nginx_check_interval_seconds,
|
nginx_check_interval_seconds: config.nginx_check_interval_seconds,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
state: RwLock::new(state),
|
state: RwLock::new(state),
|
||||||
config,
|
config,
|
||||||
@@ -95,7 +83,6 @@ impl SystemdCollector {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Collect service data for each monitored service
|
// Collect service data for each monitored service
|
||||||
let mut services = Vec::new();
|
|
||||||
let mut complete_service_data = Vec::new();
|
let mut complete_service_data = Vec::new();
|
||||||
for service_name in &monitored_services {
|
for service_name in &monitored_services {
|
||||||
match self.get_service_status(service_name) {
|
match self.get_service_status(service_name) {
|
||||||
@@ -131,27 +118,42 @@ impl SystemdCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if service_name.contains("docker") && active_status == "active" {
|
if service_name.contains("docker") && active_status == "active" {
|
||||||
|
debug!("Collecting Docker sub-services for service: {}", service_name);
|
||||||
|
|
||||||
let docker_containers = self.get_docker_containers();
|
let docker_containers = self.get_docker_containers();
|
||||||
|
debug!("Found {} Docker containers", docker_containers.len());
|
||||||
for (container_name, container_status) in docker_containers {
|
for (container_name, container_status) in docker_containers {
|
||||||
// For now, docker containers have no additional metrics
|
// For now, docker containers have no additional metrics
|
||||||
// Future: could add memory_mb, cpu_percent, restart_count, etc.
|
// Future: could add memory_mb, cpu_percent, restart_count, etc.
|
||||||
let metrics = Vec::new();
|
let metrics = Vec::new();
|
||||||
|
|
||||||
sub_services.push(SubServiceData {
|
sub_services.push(SubServiceData {
|
||||||
name: container_name.clone(),
|
name: container_name.clone(),
|
||||||
service_status: self.calculate_service_status(&container_name, &container_status),
|
service_status: self.calculate_service_status(&container_name, &container_status),
|
||||||
metrics,
|
metrics,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let service_info = ServiceInfo {
|
// Add Docker images
|
||||||
name: service_name.clone(),
|
let docker_images = self.get_docker_images();
|
||||||
status: active_status.clone(),
|
debug!("Found {} Docker images", docker_images.len());
|
||||||
memory_mb,
|
for (image_name, image_status, image_size) in docker_images {
|
||||||
disk_gb,
|
let mut metrics = Vec::new();
|
||||||
};
|
metrics.push(SubServiceMetric {
|
||||||
services.push(service_info);
|
label: "size".to_string(),
|
||||||
|
value: 0.0, // Size as string in name instead
|
||||||
|
unit: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
sub_services.push(SubServiceData {
|
||||||
|
name: format!("{} ({})", image_name, image_size),
|
||||||
|
service_status: self.calculate_service_status(&image_name, &image_status),
|
||||||
|
metrics,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("Total Docker sub-services added: {}", sub_services.len());
|
||||||
|
}
|
||||||
|
|
||||||
// Create complete service data
|
// Create complete service data
|
||||||
let service_data = ServiceData {
|
let service_data = ServiceData {
|
||||||
@@ -172,12 +174,11 @@ impl SystemdCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update cached state
|
// Update cached state
|
||||||
{
|
{
|
||||||
let mut state = self.state.write().unwrap();
|
let mut state = self.state.write().unwrap();
|
||||||
state.last_collection = Some(start_time);
|
state.last_collection = Some(start_time);
|
||||||
state.services = services;
|
|
||||||
state.cached_service_data = complete_service_data;
|
state.cached_service_data = complete_service_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,25 +484,6 @@ impl SystemdCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get service memory usage (if available)
|
|
||||||
fn get_service_memory(&self, service: &str) -> Option<f32> {
|
|
||||||
let output = Command::new("systemctl")
|
|
||||||
.args(&["show", &format!("{}.service", service), "--property=MemoryCurrent"])
|
|
||||||
.output()
|
|
||||||
.ok()?;
|
|
||||||
|
|
||||||
let output_str = String::from_utf8(output.stdout).ok()?;
|
|
||||||
for line in output_str.lines() {
|
|
||||||
if line.starts_with("MemoryCurrent=") {
|
|
||||||
let memory_str = line.strip_prefix("MemoryCurrent=")?;
|
|
||||||
if let Ok(memory_bytes) = memory_str.parse::<u64>() {
|
|
||||||
return Some(memory_bytes as f32 / (1024.0 * 1024.0)); // Convert to MB
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Calculate service status, taking user-stopped services into account
|
/// Calculate service status, taking user-stopped services into account
|
||||||
fn calculate_service_status(&self, service_name: &str, active_status: &str) -> Status {
|
fn calculate_service_status(&self, service_name: &str, active_status: &str) -> Status {
|
||||||
match active_status.to_lowercase().as_str() {
|
match active_status.to_lowercase().as_str() {
|
||||||
@@ -549,7 +531,7 @@ impl SystemdCollector {
|
|||||||
/// Check if service collection cache should be updated
|
/// Check if service collection cache should be updated
|
||||||
fn should_update_cache(&self) -> bool {
|
fn should_update_cache(&self) -> bool {
|
||||||
let state = self.state.read().unwrap();
|
let state = self.state.read().unwrap();
|
||||||
|
|
||||||
match state.last_collection {
|
match state.last_collection {
|
||||||
None => true,
|
None => true,
|
||||||
Some(last) => {
|
Some(last) => {
|
||||||
@@ -559,16 +541,6 @@ impl SystemdCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get cached service data if available and fresh
|
|
||||||
fn get_cached_services(&self) -> Option<Vec<ServiceInfo>> {
|
|
||||||
if !self.should_update_cache() {
|
|
||||||
let state = self.state.read().unwrap();
|
|
||||||
Some(state.services.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get cached complete service data with sub-services if available and fresh
|
/// Get cached complete service data with sub-services if available and fresh
|
||||||
fn get_cached_complete_services(&self) -> Option<Vec<ServiceData>> {
|
fn get_cached_complete_services(&self) -> Option<Vec<ServiceData>> {
|
||||||
if !self.should_update_cache() {
|
if !self.should_update_cache() {
|
||||||
@@ -807,9 +779,10 @@ impl SystemdCollector {
|
|||||||
fn get_docker_containers(&self) -> Vec<(String, String)> {
|
fn get_docker_containers(&self) -> Vec<(String, String)> {
|
||||||
let mut containers = Vec::new();
|
let mut containers = Vec::new();
|
||||||
|
|
||||||
// Check if docker is available
|
// Check if docker is available (use sudo for permissions)
|
||||||
let output = Command::new("docker")
|
// Use -a to show ALL containers (running and stopped)
|
||||||
.args(&["ps", "--format", "{{.Names}},{{.Status}}"])
|
let output = Command::new("sudo")
|
||||||
|
.args(&["docker", "ps", "-a", "--format", "{{.Names}},{{.Status}}"])
|
||||||
.output();
|
.output();
|
||||||
|
|
||||||
let output = match output {
|
let output = match output {
|
||||||
@@ -834,10 +807,10 @@ impl SystemdCollector {
|
|||||||
|
|
||||||
let container_status = if status_str.contains("Up") {
|
let container_status = if status_str.contains("Up") {
|
||||||
"active"
|
"active"
|
||||||
} else if status_str.contains("Exited") {
|
} else if status_str.contains("Exited") || status_str.contains("Created") {
|
||||||
"warning" // Match original: Exited → Warning, not inactive
|
"inactive" // Stopped/created containers are inactive
|
||||||
} else {
|
} else {
|
||||||
"failed" // Other states → failed
|
"failed" // Other states (restarting, paused, dead) → failed
|
||||||
};
|
};
|
||||||
|
|
||||||
containers.push((format!("docker_{}", container_name), container_status.to_string()));
|
containers.push((format!("docker_{}", container_name), container_status.to_string()));
|
||||||
@@ -846,6 +819,60 @@ impl SystemdCollector {
|
|||||||
|
|
||||||
containers
|
containers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get docker images as sub-services
|
||||||
|
fn get_docker_images(&self) -> Vec<(String, String, String)> {
|
||||||
|
let mut images = Vec::new();
|
||||||
|
|
||||||
|
debug!("Collecting Docker images");
|
||||||
|
|
||||||
|
// Check if docker is available (use sudo for permissions)
|
||||||
|
let output = Command::new("sudo")
|
||||||
|
.args(&["docker", "images", "--format", "{{.Repository}}:{{.Tag}},{{.Size}}"])
|
||||||
|
.output();
|
||||||
|
|
||||||
|
let output = match output {
|
||||||
|
Ok(out) if out.status.success() => out,
|
||||||
|
Ok(out) => {
|
||||||
|
debug!("Docker images command failed with status: {}", out.status);
|
||||||
|
return images;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
debug!("Docker images command error: {}", e);
|
||||||
|
return images;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let output_str = match String::from_utf8(output.stdout) {
|
||||||
|
Ok(s) => s,
|
||||||
|
Err(_) => return images,
|
||||||
|
};
|
||||||
|
|
||||||
|
for line in output_str.lines() {
|
||||||
|
if line.trim().is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let parts: Vec<&str> = line.split(',').collect();
|
||||||
|
if parts.len() >= 2 {
|
||||||
|
let image_name = parts[0].trim();
|
||||||
|
let size = parts[1].trim();
|
||||||
|
|
||||||
|
// Skip <none>:<none> images (dangling images)
|
||||||
|
if image_name.contains("<none>") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
images.push((
|
||||||
|
format!("image_{}", image_name),
|
||||||
|
"active".to_string(), // Images are always "active" (present)
|
||||||
|
size.to_string()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
images
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
// This file is now empty - all configuration values come from config files
|
|
||||||
// No hardcoded defaults are used
|
|
||||||
@@ -8,7 +8,6 @@ mod collectors;
|
|||||||
mod communication;
|
mod communication;
|
||||||
mod config;
|
mod config;
|
||||||
mod notifications;
|
mod notifications;
|
||||||
mod service_tracker;
|
|
||||||
|
|
||||||
use agent::Agent;
|
use agent::Agent;
|
||||||
|
|
||||||
|
|||||||
@@ -1,164 +0,0 @@
|
|||||||
use anyhow::Result;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::fs;
|
|
||||||
use std::path::Path;
|
|
||||||
use std::sync::{Arc, Mutex, OnceLock};
|
|
||||||
use tracing::{debug, info, warn};
|
|
||||||
|
|
||||||
/// Shared instance for global access
|
|
||||||
static GLOBAL_TRACKER: OnceLock<Arc<Mutex<UserStoppedServiceTracker>>> = OnceLock::new();
|
|
||||||
|
|
||||||
/// Tracks services that have been stopped by user action
|
|
||||||
/// These services should be treated as OK status instead of Warning
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct UserStoppedServiceTracker {
|
|
||||||
/// Set of services stopped by user action
|
|
||||||
user_stopped_services: HashSet<String>,
|
|
||||||
/// Path to persistent storage file
|
|
||||||
storage_path: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Serializable data structure for persistence
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
struct UserStoppedData {
|
|
||||||
services: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl UserStoppedServiceTracker {
|
|
||||||
/// Create new tracker with default storage path
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self::with_storage_path("/var/lib/cm-dashboard/user-stopped-services.json")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initialize global instance (called by agent)
|
|
||||||
pub fn init_global() -> Result<Self> {
|
|
||||||
let tracker = Self::new();
|
|
||||||
|
|
||||||
// Set global instance
|
|
||||||
let global_instance = Arc::new(Mutex::new(tracker));
|
|
||||||
if GLOBAL_TRACKER.set(global_instance).is_err() {
|
|
||||||
warn!("Global service tracker was already initialized");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a new instance for the agent to use
|
|
||||||
Ok(Self::new())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if a service is user-stopped (global access for collectors)
|
|
||||||
pub fn is_service_user_stopped(service_name: &str) -> bool {
|
|
||||||
if let Some(global) = GLOBAL_TRACKER.get() {
|
|
||||||
if let Ok(tracker) = global.lock() {
|
|
||||||
tracker.is_user_stopped(service_name)
|
|
||||||
} else {
|
|
||||||
debug!("Failed to lock global service tracker");
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug!("Global service tracker not initialized");
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Update global tracker (called by agent when tracker state changes)
|
|
||||||
pub fn update_global(updated_tracker: &UserStoppedServiceTracker) {
|
|
||||||
if let Some(global) = GLOBAL_TRACKER.get() {
|
|
||||||
if let Ok(mut tracker) = global.lock() {
|
|
||||||
tracker.user_stopped_services = updated_tracker.user_stopped_services.clone();
|
|
||||||
} else {
|
|
||||||
debug!("Failed to lock global service tracker for update");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug!("Global service tracker not initialized for update");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create new tracker with custom storage path
|
|
||||||
pub fn with_storage_path<P: AsRef<Path>>(storage_path: P) -> Self {
|
|
||||||
let storage_path = storage_path.as_ref().to_string_lossy().to_string();
|
|
||||||
let mut tracker = Self {
|
|
||||||
user_stopped_services: HashSet::new(),
|
|
||||||
storage_path,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Load existing data from storage
|
|
||||||
if let Err(e) = tracker.load_from_storage() {
|
|
||||||
warn!("Failed to load user-stopped services from storage: {}", e);
|
|
||||||
info!("Starting with empty user-stopped services list");
|
|
||||||
}
|
|
||||||
|
|
||||||
tracker
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Clear user-stopped flag for a service (when user starts it)
|
|
||||||
pub fn clear_user_stopped(&mut self, service_name: &str) -> Result<()> {
|
|
||||||
if self.user_stopped_services.remove(service_name) {
|
|
||||||
info!("Cleared user-stopped flag for service '{}'", service_name);
|
|
||||||
self.save_to_storage()?;
|
|
||||||
debug!("Service '{}' user-stopped flag cleared and saved to storage", service_name);
|
|
||||||
} else {
|
|
||||||
debug!("Service '{}' was not marked as user-stopped", service_name);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if a service is marked as user-stopped
|
|
||||||
pub fn is_user_stopped(&self, service_name: &str) -> bool {
|
|
||||||
let is_stopped = self.user_stopped_services.contains(service_name);
|
|
||||||
debug!("Service '{}' user-stopped status: {}", service_name, is_stopped);
|
|
||||||
is_stopped
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Save current state to persistent storage
|
|
||||||
fn save_to_storage(&self) -> Result<()> {
|
|
||||||
// Create parent directory if it doesn't exist
|
|
||||||
if let Some(parent_dir) = Path::new(&self.storage_path).parent() {
|
|
||||||
if !parent_dir.exists() {
|
|
||||||
fs::create_dir_all(parent_dir)?;
|
|
||||||
debug!("Created parent directory: {}", parent_dir.display());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let data = UserStoppedData {
|
|
||||||
services: self.user_stopped_services.iter().cloned().collect(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let json_data = serde_json::to_string_pretty(&data)?;
|
|
||||||
fs::write(&self.storage_path, json_data)?;
|
|
||||||
|
|
||||||
debug!(
|
|
||||||
"Saved {} user-stopped services to {}",
|
|
||||||
data.services.len(),
|
|
||||||
self.storage_path
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Load state from persistent storage
|
|
||||||
fn load_from_storage(&mut self) -> Result<()> {
|
|
||||||
if !Path::new(&self.storage_path).exists() {
|
|
||||||
debug!("Storage file {} does not exist, starting fresh", self.storage_path);
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let json_data = fs::read_to_string(&self.storage_path)?;
|
|
||||||
let data: UserStoppedData = serde_json::from_str(&json_data)?;
|
|
||||||
|
|
||||||
self.user_stopped_services = data.services.into_iter().collect();
|
|
||||||
|
|
||||||
info!(
|
|
||||||
"Loaded {} user-stopped services from {}",
|
|
||||||
self.user_stopped_services.len(),
|
|
||||||
self.storage_path
|
|
||||||
);
|
|
||||||
|
|
||||||
if !self.user_stopped_services.is_empty() {
|
|
||||||
debug!("User-stopped services: {:?}", self.user_stopped_services);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
1001
agent_stream.log
1001
agent_stream.log
@@ -1,1001 +0,0 @@
|
|||||||
warning: fields `total_services`, `backup_disk_filesystem_label`, `services_completed_count`, `services_failed_count`, and `services_disabled_count` are never read
|
|
||||||
--> dashboard/src/ui/widgets/backup.rs:22:5
|
|
||||||
|
|
|
||||||
14 | pub struct BackupWidget {
|
|
||||||
| ------------ fields in this struct
|
|
||||||
...
|
|
||||||
22 | total_services: Option<i64>,
|
|
||||||
| ^^^^^^^^^^^^^^
|
|
||||||
...
|
|
||||||
36 | backup_disk_filesystem_label: Option<String>,
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
37 | /// Number of completed services
|
|
||||||
38 | services_completed_count: Option<i64>,
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
39 | /// Number of failed services
|
|
||||||
40 | services_failed_count: Option<i64>,
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
41 | /// Number of disabled services
|
|
||||||
42 | services_disabled_count: Option<i64>,
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: `BackupWidget` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
|
|
||||||
= note: `#[warn(dead_code)]` on by default
|
|
||||||
|
|
||||||
warning: field `exit_code` is never read
|
|
||||||
--> dashboard/src/ui/widgets/backup.rs:53:5
|
|
||||||
|
|
|
||||||
50 | struct ServiceMetricData {
|
|
||||||
| ----------------- field in this struct
|
|
||||||
...
|
|
||||||
53 | exit_code: Option<i64>,
|
|
||||||
| ^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: `ServiceMetricData` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis
|
|
||||||
|
|
||||||
warning: associated function `extract_service_name` is never used
|
|
||||||
--> dashboard/src/ui/widgets/backup.rs:115:8
|
|
||||||
|
|
|
||||||
58 | impl BackupWidget {
|
|
||||||
| ----------------- associated function in this implementation
|
|
||||||
...
|
|
||||||
115 | fn extract_service_name(metric_name: &str) -> Option<String> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: method `update_from_metrics` is never used
|
|
||||||
--> dashboard/src/ui/widgets/backup.rs:157:8
|
|
||||||
|
|
|
||||||
156 | impl BackupWidget {
|
|
||||||
| ----------------- method in this implementation
|
|
||||||
157 | fn update_from_metrics(&mut self, metrics: &[&Metric]) {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: associated function `extract_service_info` is never used
|
|
||||||
--> dashboard/src/ui/widgets/services.rs:50:8
|
|
||||||
|
|
|
||||||
38 | impl ServicesWidget {
|
|
||||||
| ------------------- associated function in this implementation
|
|
||||||
...
|
|
||||||
50 | fn extract_service_info(metric_name: &str) -> Option<(String, Option<String>)> {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: method `update_from_metrics` is never used
|
|
||||||
--> dashboard/src/ui/widgets/services.rs:285:8
|
|
||||||
|
|
|
||||||
284 | impl ServicesWidget {
|
|
||||||
| ------------------- method in this implementation
|
|
||||||
285 | fn update_from_metrics(&mut self, metrics: &[&Metric]) {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: field `health_status` is never read
|
|
||||||
--> dashboard/src/ui/widgets/system.rs:53:5
|
|
||||||
|
|
|
||||||
43 | struct StoragePool {
|
|
||||||
| ----------- field in this struct
|
|
||||||
...
|
|
||||||
53 | health_status: Status, // Separate status for pool health vs usage
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: `StoragePool` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
|
|
||||||
|
|
||||||
warning: `cm-dashboard` (bin "cm-dashboard") generated 7 warnings
|
|
||||||
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
|
|
||||||
Running `target/debug/cm-dashboard --headless --raw-data`
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936501,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.82,
|
|
||||||
"load_5min": 2.1,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3743.09,
|
|
||||||
"temperature_celsius": 55.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 27.183601,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.3445206,
|
|
||||||
"available_gb": 16.994995,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.094376,
|
|
||||||
"used_gb": 0.3018875,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.582031,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936502,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.82,
|
|
||||||
"load_5min": 2.1,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3743.09,
|
|
||||||
"temperature_celsius": 55.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 27.183601,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.3445206,
|
|
||||||
"available_gb": 16.994995,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.094376,
|
|
||||||
"used_gb": 0.3018875,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.582031,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936503,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.82,
|
|
||||||
"load_5min": 2.1,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3743.09,
|
|
||||||
"temperature_celsius": 55.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 27.183601,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.3445206,
|
|
||||||
"available_gb": 16.994995,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.094376,
|
|
||||||
"used_gb": 0.3018875,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.582031,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936505,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.75,
|
|
||||||
"load_5min": 2.08,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3600.005,
|
|
||||||
"temperature_celsius": 56.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 26.780334,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.2504005,
|
|
||||||
"available_gb": 17.089115,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.095139,
|
|
||||||
"used_gb": 0.30190277,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.59375,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936506,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.75,
|
|
||||||
"load_5min": 2.08,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3600.005,
|
|
||||||
"temperature_celsius": 56.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 26.780334,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.2504005,
|
|
||||||
"available_gb": 17.089115,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.095139,
|
|
||||||
"used_gb": 0.30190277,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.59375,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936507,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.75,
|
|
||||||
"load_5min": 2.08,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3600.005,
|
|
||||||
"temperature_celsius": 56.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 26.780334,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.2504005,
|
|
||||||
"available_gb": 17.089115,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.095139,
|
|
||||||
"used_gb": 0.30190277,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.59375,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936508,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.75,
|
|
||||||
"load_5min": 2.08,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3600.005,
|
|
||||||
"temperature_celsius": 56.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 26.780334,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.2504005,
|
|
||||||
"available_gb": 17.089115,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.095139,
|
|
||||||
"used_gb": 0.30190277,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.59375,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936509,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.75,
|
|
||||||
"load_5min": 2.08,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3638.71,
|
|
||||||
"temperature_celsius": 56.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 27.014532,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.3050613,
|
|
||||||
"available_gb": 17.034454,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.095139,
|
|
||||||
"used_gb": 0.30190277,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.59375,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936509,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 0.0,
|
|
||||||
"load_5min": 0.0,
|
|
||||||
"load_15min": 0.0,
|
|
||||||
"frequency_mhz": 0.0,
|
|
||||||
"temperature_celsius": null
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 0.0,
|
|
||||||
"total_gb": 0.0,
|
|
||||||
"used_gb": 0.0,
|
|
||||||
"available_gb": 0.0,
|
|
||||||
"swap_total_gb": 0.0,
|
|
||||||
"swap_used_gb": 0.0,
|
|
||||||
"tmpfs": []
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936510,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.75,
|
|
||||||
"load_5min": 2.08,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3638.71,
|
|
||||||
"temperature_celsius": 56.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 27.014532,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.3050613,
|
|
||||||
"available_gb": 17.034454,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.095139,
|
|
||||||
"used_gb": 0.30190277,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.59375,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936511,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.75,
|
|
||||||
"load_5min": 2.08,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3638.71,
|
|
||||||
"temperature_celsius": 56.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 27.014532,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.3050613,
|
|
||||||
"available_gb": 17.034454,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.095139,
|
|
||||||
"used_gb": 0.30190277,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.59375,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
RAW AGENT DATA FROM cmbox:
|
|
||||||
{
|
|
||||||
"hostname": "cmbox",
|
|
||||||
"agent_version": "v0.1.133",
|
|
||||||
"timestamp": 1763936512,
|
|
||||||
"system": {
|
|
||||||
"cpu": {
|
|
||||||
"load_1min": 1.75,
|
|
||||||
"load_5min": 2.08,
|
|
||||||
"load_15min": 2.1,
|
|
||||||
"frequency_mhz": 3638.71,
|
|
||||||
"temperature_celsius": 56.0
|
|
||||||
},
|
|
||||||
"memory": {
|
|
||||||
"usage_percent": 27.014532,
|
|
||||||
"total_gb": 23.339516,
|
|
||||||
"used_gb": 6.3050613,
|
|
||||||
"available_gb": 17.034454,
|
|
||||||
"swap_total_gb": 14.634708,
|
|
||||||
"swap_used_gb": 0.17599106,
|
|
||||||
"tmpfs": [
|
|
||||||
{
|
|
||||||
"mount": "/tmp",
|
|
||||||
"usage_percent": 15.095139,
|
|
||||||
"used_gb": 0.30190277,
|
|
||||||
"total_gb": 2.0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"storage": {
|
|
||||||
"drives": [
|
|
||||||
{
|
|
||||||
"name": "nvme0n1",
|
|
||||||
"health": "PASSED",
|
|
||||||
"temperature_celsius": 28.0,
|
|
||||||
"wear_percent": 1.0,
|
|
||||||
"filesystems": [
|
|
||||||
{
|
|
||||||
"mount": "root",
|
|
||||||
"usage_percent": 24.404377,
|
|
||||||
"used_gb": 226.51398,
|
|
||||||
"total_gb": 928.1695
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"mount": "boot",
|
|
||||||
"usage_percent": 10.666672,
|
|
||||||
"used_gb": 0.10645676,
|
|
||||||
"total_gb": 0.9980316
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"pools": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"name": "tailscaled",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 25.59375,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "sshd",
|
|
||||||
"status": "active",
|
|
||||||
"memory_mb": 4.3085938,
|
|
||||||
"disk_gb": 0.0,
|
|
||||||
"user_stopped": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"backup": {
|
|
||||||
"status": "unknown",
|
|
||||||
"last_run": null,
|
|
||||||
"next_scheduled": null,
|
|
||||||
"total_size_gb": null,
|
|
||||||
"repository_health": null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
|
||||||
Terminated
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.153"
|
version = "0.1.175"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -20,13 +20,12 @@ pub struct Dashboard {
|
|||||||
tui_app: Option<TuiApp>,
|
tui_app: Option<TuiApp>,
|
||||||
terminal: Option<Terminal<CrosstermBackend<io::Stdout>>>,
|
terminal: Option<Terminal<CrosstermBackend<io::Stdout>>>,
|
||||||
headless: bool,
|
headless: bool,
|
||||||
raw_data: bool,
|
|
||||||
initial_commands_sent: std::collections::HashSet<String>,
|
initial_commands_sent: std::collections::HashSet<String>,
|
||||||
config: DashboardConfig,
|
config: DashboardConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Dashboard {
|
impl Dashboard {
|
||||||
pub async fn new(config_path: Option<String>, headless: bool, raw_data: bool) -> Result<Self> {
|
pub async fn new(config_path: Option<String>, headless: bool) -> Result<Self> {
|
||||||
info!("Initializing dashboard");
|
info!("Initializing dashboard");
|
||||||
|
|
||||||
// Load configuration - try default path if not specified
|
// Load configuration - try default path if not specified
|
||||||
@@ -120,7 +119,6 @@ impl Dashboard {
|
|||||||
tui_app,
|
tui_app,
|
||||||
terminal,
|
terminal,
|
||||||
headless,
|
headless,
|
||||||
raw_data,
|
|
||||||
initial_commands_sent: std::collections::HashSet::new(),
|
initial_commands_sent: std::collections::HashSet::new(),
|
||||||
config,
|
config,
|
||||||
})
|
})
|
||||||
@@ -205,13 +203,6 @@ impl Dashboard {
|
|||||||
.insert(agent_data.hostname.clone());
|
.insert(agent_data.hostname.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show raw data if requested (before processing)
|
|
||||||
if self.raw_data {
|
|
||||||
println!("RAW AGENT DATA FROM {}:", agent_data.hostname);
|
|
||||||
println!("{}", serde_json::to_string_pretty(&agent_data).unwrap_or_else(|e| format!("Serialization error: {}", e)));
|
|
||||||
println!("{}", "─".repeat(80));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store structured data directly
|
// Store structured data directly
|
||||||
self.metric_store.store_agent_data(agent_data);
|
self.metric_store.store_agent_data(agent_data);
|
||||||
|
|
||||||
|
|||||||
@@ -51,10 +51,6 @@ struct Cli {
|
|||||||
/// Run in headless mode (no TUI, just logging)
|
/// Run in headless mode (no TUI, just logging)
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
headless: bool,
|
headless: bool,
|
||||||
|
|
||||||
/// Show raw agent data in headless mode
|
|
||||||
#[arg(long)]
|
|
||||||
raw_data: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
@@ -90,7 +86,7 @@ async fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create and run dashboard
|
// Create and run dashboard
|
||||||
let mut dashboard = Dashboard::new(cli.config, cli.headless, cli.raw_data).await?;
|
let mut dashboard = Dashboard::new(cli.config, cli.headless).await?;
|
||||||
|
|
||||||
// Setup graceful shutdown
|
// Setup graceful shutdown
|
||||||
let ctrl_c = async {
|
let ctrl_c = async {
|
||||||
|
|||||||
@@ -225,9 +225,6 @@ impl Layout {
|
|||||||
pub const LEFT_PANEL_WIDTH: u16 = 45;
|
pub const LEFT_PANEL_WIDTH: u16 = 45;
|
||||||
/// Right panel percentage (services)
|
/// Right panel percentage (services)
|
||||||
pub const RIGHT_PANEL_WIDTH: u16 = 55;
|
pub const RIGHT_PANEL_WIDTH: u16 = 55;
|
||||||
/// System vs backup split (equal)
|
|
||||||
pub const SYSTEM_PANEL_HEIGHT: u16 = 50;
|
|
||||||
pub const BACKUP_PANEL_HEIGHT: u16 = 50;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Typography system
|
/// Typography system
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
// This file is intentionally left minimal - CPU functionality is handled by the SystemWidget
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
// This file is intentionally left minimal - Memory functionality is handled by the SystemWidget
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
use cm_dashboard_shared::AgentData;
|
use cm_dashboard_shared::AgentData;
|
||||||
|
|
||||||
pub mod cpu;
|
|
||||||
pub mod memory;
|
|
||||||
pub mod services;
|
pub mod services;
|
||||||
pub mod system;
|
pub mod system;
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,16 @@ use ratatui::{
|
|||||||
|
|
||||||
use crate::ui::theme::{StatusIcons, Typography};
|
use crate::ui::theme::{StatusIcons, Typography};
|
||||||
|
|
||||||
/// System widget displaying NixOS info, CPU, RAM, and Storage in unified layout
|
/// System widget displaying NixOS info, Network, CPU, RAM, and Storage in unified layout
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SystemWidget {
|
pub struct SystemWidget {
|
||||||
// NixOS information
|
// NixOS information
|
||||||
nixos_build: Option<String>,
|
nixos_build: Option<String>,
|
||||||
agent_hash: Option<String>,
|
agent_hash: Option<String>,
|
||||||
|
|
||||||
|
// Network interfaces
|
||||||
|
network_interfaces: Vec<cm_dashboard_shared::NetworkInterfaceData>,
|
||||||
|
|
||||||
// CPU metrics
|
// CPU metrics
|
||||||
cpu_load_1min: Option<f32>,
|
cpu_load_1min: Option<f32>,
|
||||||
cpu_load_5min: Option<f32>,
|
cpu_load_5min: Option<f32>,
|
||||||
@@ -89,6 +92,7 @@ impl SystemWidget {
|
|||||||
Self {
|
Self {
|
||||||
nixos_build: None,
|
nixos_build: None,
|
||||||
agent_hash: None,
|
agent_hash: None,
|
||||||
|
network_interfaces: Vec::new(),
|
||||||
cpu_load_1min: None,
|
cpu_load_1min: None,
|
||||||
cpu_load_5min: None,
|
cpu_load_5min: None,
|
||||||
cpu_load_15min: None,
|
cpu_load_15min: None,
|
||||||
@@ -164,6 +168,9 @@ impl Widget for SystemWidget {
|
|||||||
// Extract build version
|
// Extract build version
|
||||||
self.nixos_build = agent_data.build_version.clone();
|
self.nixos_build = agent_data.build_version.clone();
|
||||||
|
|
||||||
|
// Extract network interfaces
|
||||||
|
self.network_interfaces = agent_data.system.network.interfaces.clone();
|
||||||
|
|
||||||
// Extract CPU data directly
|
// Extract CPU data directly
|
||||||
let cpu = &agent_data.system.cpu;
|
let cpu = &agent_data.system.cpu;
|
||||||
self.cpu_load_1min = Some(cpu.load_1min);
|
self.cpu_load_1min = Some(cpu.load_1min);
|
||||||
@@ -239,8 +246,11 @@ impl SystemWidget {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Add drive info
|
// Add drive info
|
||||||
|
let display_name = drive.serial_number.as_ref()
|
||||||
|
.map(|s| truncate_serial(s))
|
||||||
|
.unwrap_or(drive.name.clone());
|
||||||
let storage_drive = StorageDrive {
|
let storage_drive = StorageDrive {
|
||||||
name: drive.name.clone(),
|
name: display_name,
|
||||||
temperature: drive.temperature_celsius,
|
temperature: drive.temperature_celsius,
|
||||||
wear_percent: drive.wear_percent,
|
wear_percent: drive.wear_percent,
|
||||||
status: Status::Ok,
|
status: Status::Ok,
|
||||||
@@ -310,9 +320,12 @@ impl SystemWidget {
|
|||||||
} else {
|
} else {
|
||||||
Status::Unknown
|
Status::Unknown
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let display_name = drive.serial_number.as_ref()
|
||||||
|
.map(|s| truncate_serial(s))
|
||||||
|
.unwrap_or(drive.name.clone());
|
||||||
let storage_drive = StorageDrive {
|
let storage_drive = StorageDrive {
|
||||||
name: drive.name.clone(),
|
name: display_name,
|
||||||
temperature: drive.temperature_celsius,
|
temperature: drive.temperature_celsius,
|
||||||
wear_percent: drive.wear_percent,
|
wear_percent: drive.wear_percent,
|
||||||
status: drive_status,
|
status: drive_status,
|
||||||
@@ -332,9 +345,12 @@ impl SystemWidget {
|
|||||||
} else {
|
} else {
|
||||||
Status::Unknown
|
Status::Unknown
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let display_name = drive.serial_number.as_ref()
|
||||||
|
.map(|s| truncate_serial(s))
|
||||||
|
.unwrap_or(drive.name.clone());
|
||||||
let storage_drive = StorageDrive {
|
let storage_drive = StorageDrive {
|
||||||
name: drive.name.clone(),
|
name: display_name,
|
||||||
temperature: drive.temperature_celsius,
|
temperature: drive.temperature_celsius,
|
||||||
wear_percent: drive.wear_percent,
|
wear_percent: drive.wear_percent,
|
||||||
status: drive_status,
|
status: drive_status,
|
||||||
@@ -359,12 +375,8 @@ impl SystemWidget {
|
|||||||
// Pool header line with type and health
|
// Pool header line with type and health
|
||||||
let pool_label = if pool.pool_type == "drive" {
|
let pool_label = if pool.pool_type == "drive" {
|
||||||
// For physical drives, show the drive name with temperature and wear percentage if available
|
// For physical drives, show the drive name with temperature and wear percentage if available
|
||||||
// Look for any drive with temp/wear data (physical drives may have drives named after the pool)
|
// Physical drives only have one drive entry
|
||||||
let drive_info = pool.drives.iter()
|
if let Some(drive) = pool.drives.first() {
|
||||||
.find(|d| d.name == pool.name)
|
|
||||||
.or_else(|| pool.drives.first());
|
|
||||||
|
|
||||||
if let Some(drive) = drive_info {
|
|
||||||
let mut drive_details = Vec::new();
|
let mut drive_details = Vec::new();
|
||||||
if let Some(temp) = drive.temperature {
|
if let Some(temp) = drive.temperature {
|
||||||
drive_details.push(format!("T: {}°C", temp as i32));
|
drive_details.push(format!("T: {}°C", temp as i32));
|
||||||
@@ -372,18 +384,18 @@ impl SystemWidget {
|
|||||||
if let Some(wear) = drive.wear_percent {
|
if let Some(wear) = drive.wear_percent {
|
||||||
drive_details.push(format!("W: {}%", wear as i32));
|
drive_details.push(format!("W: {}%", wear as i32));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !drive_details.is_empty() {
|
if !drive_details.is_empty() {
|
||||||
format!("{} {}", pool.name, drive_details.join(" "))
|
format!("{} {}", drive.name, drive_details.join(" "))
|
||||||
} else {
|
} else {
|
||||||
pool.name.clone()
|
drive.name.clone()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pool.name.clone()
|
pool.name.clone()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// For mergerfs pools, show pool name with format like "mergerfs (2+1):"
|
// For mergerfs pools, show pool type with mount point
|
||||||
format!("{}:", pool.pool_type)
|
format!("mergerfs {}:", pool.mount_point)
|
||||||
};
|
};
|
||||||
|
|
||||||
let pool_spans = StatusIcons::create_status_spans(pool.status.clone(), &pool_label);
|
let pool_spans = StatusIcons::create_status_spans(pool.status.clone(), &pool_label);
|
||||||
@@ -422,7 +434,7 @@ impl SystemWidget {
|
|||||||
// └─ Mount: /srv/media
|
// └─ Mount: /srv/media
|
||||||
|
|
||||||
// Pool total usage
|
// Pool total usage
|
||||||
let total_text = format!("Total: {:.0}% {:.1}GB/{:.1}GB",
|
let total_text = format!("{:.0}% {:.1}GB/{:.1}GB",
|
||||||
pool.usage_percent.unwrap_or(0.0),
|
pool.usage_percent.unwrap_or(0.0),
|
||||||
pool.used_gb.unwrap_or(0.0),
|
pool.used_gb.unwrap_or(0.0),
|
||||||
pool.total_gb.unwrap_or(0.0)
|
pool.total_gb.unwrap_or(0.0)
|
||||||
@@ -433,22 +445,37 @@ impl SystemWidget {
|
|||||||
total_spans.extend(StatusIcons::create_status_spans(Status::Ok, &total_text));
|
total_spans.extend(StatusIcons::create_status_spans(Status::Ok, &total_text));
|
||||||
lines.push(Line::from(total_spans));
|
lines.push(Line::from(total_spans));
|
||||||
|
|
||||||
// Data Disks section
|
// Data drives - at same level as parity
|
||||||
if !pool.data_drives.is_empty() {
|
let has_parity = !pool.parity_drives.is_empty();
|
||||||
lines.push(Line::from(vec![
|
for (i, drive) in pool.data_drives.iter().enumerate() {
|
||||||
Span::styled(" ├─ ", Typography::tree()),
|
let is_last_data = i == pool.data_drives.len() - 1;
|
||||||
Span::styled("Data Disks:", Typography::secondary())
|
let mut drive_details = Vec::new();
|
||||||
]));
|
if let Some(temp) = drive.temperature {
|
||||||
for (i, drive) in pool.data_drives.iter().enumerate() {
|
drive_details.push(format!("T: {}°C", temp as i32));
|
||||||
let is_last = i == pool.data_drives.len() - 1;
|
|
||||||
let tree_symbol = if is_last { " │ └─ " } else { " │ ├─ " };
|
|
||||||
render_mergerfs_drive(drive, tree_symbol, &mut lines);
|
|
||||||
}
|
}
|
||||||
|
if let Some(wear) = drive.wear_percent {
|
||||||
|
drive_details.push(format!("W: {}%", wear as i32));
|
||||||
|
}
|
||||||
|
|
||||||
|
let drive_text = if !drive_details.is_empty() {
|
||||||
|
format!("Data_{}: {} {}", i + 1, drive.name, drive_details.join(" "))
|
||||||
|
} else {
|
||||||
|
format!("Data_{}: {}", i + 1, drive.name)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Last data drive uses └─ if there's no parity, otherwise ├─
|
||||||
|
let tree_symbol = if is_last_data && !has_parity { " └─ " } else { " ├─ " };
|
||||||
|
let mut data_spans = vec![
|
||||||
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
|
];
|
||||||
|
data_spans.extend(StatusIcons::create_status_spans(drive.status.clone(), &drive_text));
|
||||||
|
lines.push(Line::from(data_spans));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parity section
|
// Parity drives - last item(s)
|
||||||
if !pool.parity_drives.is_empty() {
|
if !pool.parity_drives.is_empty() {
|
||||||
for drive in &pool.parity_drives {
|
for (i, drive) in pool.parity_drives.iter().enumerate() {
|
||||||
|
let is_last = i == pool.parity_drives.len() - 1;
|
||||||
let mut drive_details = Vec::new();
|
let mut drive_details = Vec::new();
|
||||||
if let Some(temp) = drive.temperature {
|
if let Some(temp) = drive.temperature {
|
||||||
drive_details.push(format!("T: {}°C", temp as i32));
|
drive_details.push(format!("T: {}°C", temp as i32));
|
||||||
@@ -456,27 +483,21 @@ impl SystemWidget {
|
|||||||
if let Some(wear) = drive.wear_percent {
|
if let Some(wear) = drive.wear_percent {
|
||||||
drive_details.push(format!("W: {}%", wear as i32));
|
drive_details.push(format!("W: {}%", wear as i32));
|
||||||
}
|
}
|
||||||
|
|
||||||
let drive_text = if !drive_details.is_empty() {
|
let drive_text = if !drive_details.is_empty() {
|
||||||
format!("{} {}", drive.name, drive_details.join(" "))
|
format!("Parity: {} {}", drive.name, drive_details.join(" "))
|
||||||
} else {
|
} else {
|
||||||
drive.name.clone()
|
format!("Parity: {}", drive.name)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||||
let mut parity_spans = vec![
|
let mut parity_spans = vec![
|
||||||
Span::styled(" ├─ ", Typography::tree()),
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
Span::styled("Parity: ", Typography::secondary()),
|
|
||||||
];
|
];
|
||||||
parity_spans.extend(StatusIcons::create_status_spans(drive.status.clone(), &drive_text));
|
parity_spans.extend(StatusIcons::create_status_spans(drive.status.clone(), &drive_text));
|
||||||
lines.push(Line::from(parity_spans));
|
lines.push(Line::from(parity_spans));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount point
|
|
||||||
lines.push(Line::from(vec![
|
|
||||||
Span::styled(" └─ Mount: ", Typography::tree()),
|
|
||||||
Span::styled(&pool.mount_point, Typography::secondary())
|
|
||||||
]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,53 +505,14 @@ impl SystemWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to render a drive in a MergerFS pool
|
/// Truncate serial number to last 8 characters
|
||||||
fn render_mergerfs_drive<'a>(drive: &StorageDrive, tree_symbol: &'a str, lines: &mut Vec<Line<'a>>) {
|
fn truncate_serial(serial: &str) -> String {
|
||||||
let mut drive_details = Vec::new();
|
let len = serial.len();
|
||||||
if let Some(temp) = drive.temperature {
|
if len > 8 {
|
||||||
drive_details.push(format!("T: {}°C", temp as i32));
|
serial[len - 8..].to_string()
|
||||||
}
|
|
||||||
if let Some(wear) = drive.wear_percent {
|
|
||||||
drive_details.push(format!("W: {}%", wear as i32));
|
|
||||||
}
|
|
||||||
|
|
||||||
let drive_text = if !drive_details.is_empty() {
|
|
||||||
format!("{} {}", drive.name, drive_details.join(" "))
|
|
||||||
} else {
|
} else {
|
||||||
drive.name.clone()
|
serial.to_string()
|
||||||
};
|
|
||||||
|
|
||||||
let mut drive_spans = vec![
|
|
||||||
Span::styled(tree_symbol, Typography::tree()),
|
|
||||||
];
|
|
||||||
drive_spans.extend(StatusIcons::create_status_spans(drive.status.clone(), &drive_text));
|
|
||||||
lines.push(Line::from(drive_spans));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Helper function to render a drive in a storage pool
|
|
||||||
fn render_pool_drive(drive: &StorageDrive, is_last: bool, lines: &mut Vec<Line<'_>>) {
|
|
||||||
let tree_symbol = if is_last { " └─" } else { " ├─" };
|
|
||||||
|
|
||||||
let mut drive_details = Vec::new();
|
|
||||||
if let Some(temp) = drive.temperature {
|
|
||||||
drive_details.push(format!("T: {}°C", temp as i32));
|
|
||||||
}
|
}
|
||||||
if let Some(wear) = drive.wear_percent {
|
|
||||||
drive_details.push(format!("W: {}%", wear as i32));
|
|
||||||
}
|
|
||||||
|
|
||||||
let drive_text = if !drive_details.is_empty() {
|
|
||||||
format!("● {} {}", drive.name, drive_details.join(" "))
|
|
||||||
} else {
|
|
||||||
format!("● {}", drive.name)
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut drive_spans = vec![
|
|
||||||
Span::styled(tree_symbol, Typography::tree()),
|
|
||||||
Span::raw(" "),
|
|
||||||
];
|
|
||||||
drive_spans.extend(StatusIcons::create_status_spans(drive.status.clone(), &drive_text));
|
|
||||||
lines.push(Line::from(drive_spans));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SystemWidget {
|
impl SystemWidget {
|
||||||
@@ -540,6 +522,7 @@ impl SystemWidget {
|
|||||||
|
|
||||||
// First line: serial number with temperature and wear
|
// First line: serial number with temperature and wear
|
||||||
if let Some(serial) = &self.backup_disk_serial {
|
if let Some(serial) = &self.backup_disk_serial {
|
||||||
|
let truncated_serial = truncate_serial(serial);
|
||||||
let mut details = Vec::new();
|
let mut details = Vec::new();
|
||||||
if let Some(temp) = self.backup_disk_temperature {
|
if let Some(temp) = self.backup_disk_temperature {
|
||||||
details.push(format!("T: {}°C", temp as i32));
|
details.push(format!("T: {}°C", temp as i32));
|
||||||
@@ -549,9 +532,9 @@ impl SystemWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let disk_text = if !details.is_empty() {
|
let disk_text = if !details.is_empty() {
|
||||||
format!("{} {}", serial, details.join(" "))
|
format!("{} {}", truncated_serial, details.join(" "))
|
||||||
} else {
|
} else {
|
||||||
serial.clone()
|
truncated_serial
|
||||||
};
|
};
|
||||||
|
|
||||||
let backup_status = match self.backup_status.as_str() {
|
let backup_status = match self.backup_status.as_str() {
|
||||||
@@ -597,45 +580,205 @@ impl SystemWidget {
|
|||||||
lines
|
lines
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format time ago from timestamp
|
/// Compress IPv4 addresses from same subnet
|
||||||
fn format_time_ago(&self, timestamp: u64) -> String {
|
/// Example: "192.168.30.1, 192.168.30.100" -> "192.168.30.1, 100"
|
||||||
let now = chrono::Utc::now().timestamp() as u64;
|
fn compress_ipv4_addresses(addresses: &[String]) -> String {
|
||||||
let seconds_ago = now.saturating_sub(timestamp);
|
if addresses.is_empty() {
|
||||||
|
return String::new();
|
||||||
let hours = seconds_ago / 3600;
|
|
||||||
let minutes = (seconds_ago % 3600) / 60;
|
|
||||||
|
|
||||||
if hours > 0 {
|
|
||||||
format!("{}h ago", hours)
|
|
||||||
} else if minutes > 0 {
|
|
||||||
format!("{}m ago", minutes)
|
|
||||||
} else {
|
|
||||||
"now".to_string()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if addresses.len() == 1 {
|
||||||
|
return addresses[0].clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut result = Vec::new();
|
||||||
|
let mut last_prefix = String::new();
|
||||||
|
|
||||||
|
for addr in addresses {
|
||||||
|
let parts: Vec<&str> = addr.split('.').collect();
|
||||||
|
if parts.len() == 4 {
|
||||||
|
let prefix = format!("{}.{}.{}", parts[0], parts[1], parts[2]);
|
||||||
|
|
||||||
|
if prefix == last_prefix {
|
||||||
|
// Same subnet, show only last octet
|
||||||
|
result.push(parts[3].to_string());
|
||||||
|
} else {
|
||||||
|
// Different subnet, show full IP
|
||||||
|
result.push(addr.clone());
|
||||||
|
last_prefix = prefix;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Invalid IP format, show as-is
|
||||||
|
result.push(addr.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.join(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format time until from future timestamp
|
/// Render network section for display with physical/virtual grouping
|
||||||
fn format_time_until(&self, timestamp: u64) -> String {
|
fn render_network(&self) -> Vec<Line<'_>> {
|
||||||
let now = chrono::Utc::now().timestamp() as u64;
|
let mut lines = Vec::new();
|
||||||
if timestamp <= now {
|
|
||||||
return "overdue".to_string();
|
if self.network_interfaces.is_empty() {
|
||||||
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
let seconds_until = timestamp - now;
|
// Separate physical and virtual interfaces
|
||||||
let hours = seconds_until / 3600;
|
let physical: Vec<_> = self.network_interfaces.iter().filter(|i| i.is_physical).collect();
|
||||||
let minutes = (seconds_until % 3600) / 60;
|
let virtual_interfaces: Vec<_> = self.network_interfaces.iter().filter(|i| !i.is_physical).collect();
|
||||||
|
|
||||||
if hours > 0 {
|
// Find standalone virtual interfaces (those without a parent)
|
||||||
format!("in {}h", hours)
|
let mut standalone_virtual: Vec<_> = virtual_interfaces.iter()
|
||||||
} else if minutes > 0 {
|
.filter(|i| i.parent_interface.is_none())
|
||||||
format!("in {}m", minutes)
|
.collect();
|
||||||
} else {
|
|
||||||
"soon".to_string()
|
// Sort standalone virtual: VLANs first (by VLAN ID), then others alphabetically
|
||||||
|
standalone_virtual.sort_by(|a, b| {
|
||||||
|
match (a.vlan_id, b.vlan_id) {
|
||||||
|
(Some(vlan_a), Some(vlan_b)) => vlan_a.cmp(&vlan_b),
|
||||||
|
(Some(_), None) => std::cmp::Ordering::Less,
|
||||||
|
(None, Some(_)) => std::cmp::Ordering::Greater,
|
||||||
|
(None, None) => a.name.cmp(&b.name),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Render physical interfaces with their children
|
||||||
|
for (phy_idx, interface) in physical.iter().enumerate() {
|
||||||
|
let is_last_physical = phy_idx == physical.len() - 1 && standalone_virtual.is_empty();
|
||||||
|
|
||||||
|
// Physical interface header with status icon
|
||||||
|
let mut header_spans = vec![];
|
||||||
|
header_spans.extend(StatusIcons::create_status_spans(
|
||||||
|
interface.link_status.clone(),
|
||||||
|
&format!("{}:", interface.name)
|
||||||
|
));
|
||||||
|
lines.push(Line::from(header_spans));
|
||||||
|
|
||||||
|
// Find child interfaces for this physical interface
|
||||||
|
let mut children: Vec<_> = virtual_interfaces.iter()
|
||||||
|
.filter(|vi| {
|
||||||
|
if let Some(parent) = &vi.parent_interface {
|
||||||
|
parent == &interface.name
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// Sort children: VLANs first (by VLAN ID), then others alphabetically
|
||||||
|
children.sort_by(|a, b| {
|
||||||
|
match (a.vlan_id, b.vlan_id) {
|
||||||
|
(Some(vlan_a), Some(vlan_b)) => vlan_a.cmp(&vlan_b),
|
||||||
|
(Some(_), None) => std::cmp::Ordering::Less,
|
||||||
|
(None, Some(_)) => std::cmp::Ordering::Greater,
|
||||||
|
(None, None) => a.name.cmp(&b.name),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Count total items under this physical interface (IPs + children)
|
||||||
|
let ip_count = interface.ipv4_addresses.len() + interface.ipv6_addresses.len();
|
||||||
|
let total_children = ip_count + children.len();
|
||||||
|
let mut child_index = 0;
|
||||||
|
|
||||||
|
// IPv4 addresses on the physical interface itself
|
||||||
|
for ipv4 in &interface.ipv4_addresses {
|
||||||
|
child_index += 1;
|
||||||
|
let is_last = child_index == total_children && is_last_physical;
|
||||||
|
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||||
|
lines.push(Line::from(vec![
|
||||||
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
|
Span::styled(format!("ip: {}", ipv4), Typography::secondary()),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPv6 addresses on the physical interface itself
|
||||||
|
for ipv6 in &interface.ipv6_addresses {
|
||||||
|
child_index += 1;
|
||||||
|
let is_last = child_index == total_children && is_last_physical;
|
||||||
|
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||||
|
lines.push(Line::from(vec![
|
||||||
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
|
Span::styled(format!("ip: {}", ipv6), Typography::secondary()),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Child virtual interfaces (VLANs, etc.)
|
||||||
|
for child in children {
|
||||||
|
child_index += 1;
|
||||||
|
let is_last = child_index == total_children && is_last_physical;
|
||||||
|
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||||
|
|
||||||
|
let ip_text = if !child.ipv4_addresses.is_empty() {
|
||||||
|
Self::compress_ipv4_addresses(&child.ipv4_addresses)
|
||||||
|
} else if !child.ipv6_addresses.is_empty() {
|
||||||
|
child.ipv6_addresses.join(", ")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
|
||||||
|
// Format: "name (vlan X): IP" or "name: IP"
|
||||||
|
let child_text = if let Some(vlan_id) = child.vlan_id {
|
||||||
|
if !ip_text.is_empty() {
|
||||||
|
format!("{} (vlan {}): {}", child.name, vlan_id, ip_text)
|
||||||
|
} else {
|
||||||
|
format!("{} (vlan {}):", child.name, vlan_id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if !ip_text.is_empty() {
|
||||||
|
format!("{}: {}", child.name, ip_text)
|
||||||
|
} else {
|
||||||
|
format!("{}:", child.name)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
lines.push(Line::from(vec![
|
||||||
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
|
Span::styled(child_text, Typography::secondary()),
|
||||||
|
]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render standalone virtual interfaces (those without a parent)
|
||||||
|
for (virt_idx, interface) in standalone_virtual.iter().enumerate() {
|
||||||
|
let is_last = virt_idx == standalone_virtual.len() - 1;
|
||||||
|
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||||
|
|
||||||
|
// Virtual interface with IPs
|
||||||
|
let ip_text = if !interface.ipv4_addresses.is_empty() {
|
||||||
|
Self::compress_ipv4_addresses(&interface.ipv4_addresses)
|
||||||
|
} else if !interface.ipv6_addresses.is_empty() {
|
||||||
|
interface.ipv6_addresses.join(", ")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
|
||||||
|
// Format: "name (vlan X): IP" or "name: IP"
|
||||||
|
let interface_text = if let Some(vlan_id) = interface.vlan_id {
|
||||||
|
if !ip_text.is_empty() {
|
||||||
|
format!("{} (vlan {}): {}", interface.name, vlan_id, ip_text)
|
||||||
|
} else {
|
||||||
|
format!("{} (vlan {}):", interface.name, vlan_id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if !ip_text.is_empty() {
|
||||||
|
format!("{}: {}", interface.name, ip_text)
|
||||||
|
} else {
|
||||||
|
format!("{}:", interface.name)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
lines.push(Line::from(vec![
|
||||||
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
|
Span::styled(interface_text, Typography::secondary()),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
lines
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render system widget
|
/// Render system widget
|
||||||
pub fn render(&mut self, frame: &mut Frame, area: Rect, hostname: &str, config: Option<&crate::config::DashboardConfig>) {
|
pub fn render(&mut self, frame: &mut Frame, area: Rect, hostname: &str, _config: Option<&crate::config::DashboardConfig>) {
|
||||||
let mut lines = Vec::new();
|
let mut lines = Vec::new();
|
||||||
|
|
||||||
// NixOS section
|
// NixOS section
|
||||||
@@ -652,30 +795,19 @@ impl SystemWidget {
|
|||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled(format!("Agent: {}", agent_version_text), Typography::secondary())
|
Span::styled(format!("Agent: {}", agent_version_text), Typography::secondary())
|
||||||
]));
|
]));
|
||||||
|
|
||||||
// Display detected connection IP
|
|
||||||
if let Some(config) = config {
|
|
||||||
if let Some(host_details) = config.hosts.get(hostname) {
|
|
||||||
let detected_ip = host_details.get_connection_ip(hostname);
|
|
||||||
lines.push(Line::from(vec![
|
|
||||||
Span::styled(format!("IP: {}", detected_ip), Typography::secondary())
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// CPU section
|
// CPU section
|
||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled("CPU:", Typography::widget_title())
|
Span::styled("CPU:", Typography::widget_title())
|
||||||
]));
|
]));
|
||||||
|
|
||||||
let load_text = self.format_cpu_load();
|
let load_text = self.format_cpu_load();
|
||||||
let cpu_spans = StatusIcons::create_status_spans(
|
let cpu_spans = StatusIcons::create_status_spans(
|
||||||
self.cpu_status.clone(),
|
self.cpu_status.clone(),
|
||||||
&format!("Load: {}", load_text)
|
&format!("Load: {}", load_text)
|
||||||
);
|
);
|
||||||
lines.push(Line::from(cpu_spans));
|
lines.push(Line::from(cpu_spans));
|
||||||
|
|
||||||
let freq_text = self.format_cpu_frequency();
|
let freq_text = self.format_cpu_frequency();
|
||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled(" └─ ", Typography::tree()),
|
Span::styled(" └─ ", Typography::tree()),
|
||||||
@@ -686,7 +818,7 @@ impl SystemWidget {
|
|||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled("RAM:", Typography::widget_title())
|
Span::styled("RAM:", Typography::widget_title())
|
||||||
]));
|
]));
|
||||||
|
|
||||||
let memory_text = self.format_memory_usage();
|
let memory_text = self.format_memory_usage();
|
||||||
let memory_spans = StatusIcons::create_status_spans(
|
let memory_spans = StatusIcons::create_status_spans(
|
||||||
self.memory_status.clone(),
|
self.memory_status.clone(),
|
||||||
@@ -698,16 +830,16 @@ impl SystemWidget {
|
|||||||
for (i, tmpfs) in self.tmpfs_mounts.iter().enumerate() {
|
for (i, tmpfs) in self.tmpfs_mounts.iter().enumerate() {
|
||||||
let is_last = i == self.tmpfs_mounts.len() - 1;
|
let is_last = i == self.tmpfs_mounts.len() - 1;
|
||||||
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||||
|
|
||||||
let usage_text = if tmpfs.total_gb > 0.0 {
|
let usage_text = if tmpfs.total_gb > 0.0 {
|
||||||
format!("{:.0}% {:.1}GB/{:.1}GB",
|
format!("{:.0}% {:.1}GB/{:.1}GB",
|
||||||
tmpfs.usage_percent,
|
tmpfs.usage_percent,
|
||||||
tmpfs.used_gb,
|
tmpfs.used_gb,
|
||||||
tmpfs.total_gb)
|
tmpfs.total_gb)
|
||||||
} else {
|
} else {
|
||||||
"— —/—".to_string()
|
"— —/—".to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut tmpfs_spans = vec![
|
let mut tmpfs_spans = vec![
|
||||||
Span::styled(tree_symbol, Typography::tree()),
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
];
|
];
|
||||||
@@ -718,6 +850,16 @@ impl SystemWidget {
|
|||||||
lines.push(Line::from(tmpfs_spans));
|
lines.push(Line::from(tmpfs_spans));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Network section
|
||||||
|
if !self.network_interfaces.is_empty() {
|
||||||
|
lines.push(Line::from(vec![
|
||||||
|
Span::styled("Network:", Typography::widget_title())
|
||||||
|
]));
|
||||||
|
|
||||||
|
let network_lines = self.render_network();
|
||||||
|
lines.extend(network_lines);
|
||||||
|
}
|
||||||
|
|
||||||
// Storage section
|
// Storage section
|
||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled("Storage:", Typography::widget_title())
|
Span::styled("Storage:", Typography::widget_title())
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.153"
|
version = "0.1.175"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -16,11 +16,30 @@ pub struct AgentData {
|
|||||||
/// System-level monitoring data
|
/// System-level monitoring data
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct SystemData {
|
pub struct SystemData {
|
||||||
|
pub network: NetworkData,
|
||||||
pub cpu: CpuData,
|
pub cpu: CpuData,
|
||||||
pub memory: MemoryData,
|
pub memory: MemoryData,
|
||||||
pub storage: StorageData,
|
pub storage: StorageData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Network interface monitoring data
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct NetworkData {
|
||||||
|
pub interfaces: Vec<NetworkInterfaceData>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Individual network interface data
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct NetworkInterfaceData {
|
||||||
|
pub name: String,
|
||||||
|
pub ipv4_addresses: Vec<String>,
|
||||||
|
pub ipv6_addresses: Vec<String>,
|
||||||
|
pub is_physical: bool,
|
||||||
|
pub link_status: Status,
|
||||||
|
pub parent_interface: Option<String>,
|
||||||
|
pub vlan_id: Option<u16>,
|
||||||
|
}
|
||||||
|
|
||||||
/// CPU monitoring data
|
/// CPU monitoring data
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct CpuData {
|
pub struct CpuData {
|
||||||
@@ -66,6 +85,7 @@ pub struct StorageData {
|
|||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct DriveData {
|
pub struct DriveData {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub serial_number: Option<String>,
|
||||||
pub health: String,
|
pub health: String,
|
||||||
pub temperature_celsius: Option<f32>,
|
pub temperature_celsius: Option<f32>,
|
||||||
pub wear_percent: Option<f32>,
|
pub wear_percent: Option<f32>,
|
||||||
@@ -104,6 +124,7 @@ pub struct PoolData {
|
|||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct PoolDriveData {
|
pub struct PoolDriveData {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub serial_number: Option<String>,
|
||||||
pub temperature_celsius: Option<f32>,
|
pub temperature_celsius: Option<f32>,
|
||||||
pub wear_percent: Option<f32>,
|
pub wear_percent: Option<f32>,
|
||||||
pub health: String,
|
pub health: String,
|
||||||
@@ -169,6 +190,9 @@ impl AgentData {
|
|||||||
build_version: None,
|
build_version: None,
|
||||||
timestamp: chrono::Utc::now().timestamp() as u64,
|
timestamp: chrono::Utc::now().timestamp() as u64,
|
||||||
system: SystemData {
|
system: SystemData {
|
||||||
|
network: NetworkData {
|
||||||
|
interfaces: Vec::new(),
|
||||||
|
},
|
||||||
cpu: CpuData {
|
cpu: CpuData {
|
||||||
load_1min: 0.0,
|
load_1min: 0.0,
|
||||||
load_5min: 0.0,
|
load_5min: 0.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user