Use direct smartctl with CAP_SYS_RAWIO instead of sudo
All checks were successful
Build and Release / build-and-release (push) Successful in 1m9s

This commit is contained in:
2025-11-27 13:22:13 +01:00
parent bbc8b7b1cb
commit bd22ce265b
5 changed files with 9 additions and 8 deletions

View File

@@ -426,8 +426,9 @@ impl DiskCollector {
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)])
// Use direct smartctl (no sudo) - service has CAP_SYS_RAWIO capability
let output = Command::new("smartctl")
.args(&["-a", &format!("/dev/{}", drive_name)])
.output()
.map_err(|e| CollectorError::SystemRead {
path: format!("SMART data for {}", drive_name),