Add info-level logging for SMART data collection debugging
All checks were successful
Build and Release / build-and-release (push) Successful in 1m19s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m19s
This commit is contained in:
@@ -385,8 +385,9 @@ 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
|
||||
let mut all_drives = std::collections::HashSet::new();
|
||||
for drive in physical_drives {
|
||||
@@ -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()
|
||||
@@ -423,13 +436,13 @@ impl DiskCollector {
|
||||
|
||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
let error_str = String::from_utf8_lossy(&output.stderr);
|
||||
|
||||
|
||||
// Debug logging for SMART command results
|
||||
debug!("SMART output for {}: status={}, stdout_len={}, stderr={}",
|
||||
debug!("SMART output for {}: status={}, stdout_len={}, stderr={}",
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user