Add info-level logging for SMART data collection debugging
All checks were successful
Build and Release / build-and-release (push) Successful in 1m19s

This commit is contained in:
Christoffer Martinsson 2025-11-27 13:15:53 +01:00
parent 5dd8cadef3
commit bbc8b7b1cb
5 changed files with 27 additions and 14 deletions

6
Cargo.lock generated
View File

@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]]
name = "cm-dashboard"
version = "0.1.178"
version = "0.1.179"
dependencies = [
"anyhow",
"chrono",
@ -301,7 +301,7 @@ dependencies = [
[[package]]
name = "cm-dashboard-agent"
version = "0.1.178"
version = "0.1.179"
dependencies = [
"anyhow",
"async-trait",
@ -324,7 +324,7 @@ dependencies = [
[[package]]
name = "cm-dashboard-shared"
version = "0.1.178"
version = "0.1.179"
dependencies = [
"chrono",
"serde",

View File

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

View File

@ -385,6 +385,7 @@ impl DiskCollector {
/// Get SMART data for drives
async fn get_smart_data_for_drives(&self, physical_drives: &[PhysicalDrive], mergerfs_pools: &[MergerfsPool]) -> HashMap<String, SmartData> {
use tracing::info;
let mut smart_data = HashMap::new();
// Collect all drive names
@ -401,18 +402,30 @@ impl DiskCollector {
}
}
info!("Collecting SMART data for {} drives", all_drives.len());
// Get SMART data for each drive
for drive_name in all_drives {
if let Ok(data) = self.get_smart_data(&drive_name).await {
smart_data.insert(drive_name, data);
for drive_name in &all_drives {
match self.get_smart_data(drive_name).await {
Ok(data) => {
info!("SMART data collected for {}: serial={:?}, temp={:?}, health={}",
drive_name, data.serial_number, data.temperature_celsius, data.health);
smart_data.insert(drive_name.clone(), data);
}
Err(e) => {
info!("Failed to get SMART data for {}: {:?}", drive_name, e);
}
}
}
info!("SMART data collection complete: {}/{} drives successful", smart_data.len(), all_drives.len());
smart_data
}
/// Get SMART data for a single drive
async fn get_smart_data(&self, drive_name: &str) -> Result<SmartData, CollectorError> {
use tracing::info;
let output = Command::new("sudo")
.args(&["smartctl", "-a", &format!("/dev/{}", drive_name)])
.output()
@ -429,7 +442,7 @@ impl DiskCollector {
drive_name, output.status, output_str.len(), error_str);
if !output.status.success() {
debug!("SMART command failed for {}: {}", drive_name, error_str);
info!("SMART command failed for {}, status={}, stderr={}", drive_name, output.status, error_str);
// Return unknown data rather than failing completely
return Ok(SmartData {
health: "UNKNOWN".to_string(),

View File

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

View File

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