feat: add disks to monitoring

This commit is contained in:
2025-12-05 21:57:58 +01:00
parent ada9db7942
commit 8e0e5c0d16
5 changed files with 518 additions and 32 deletions

View File

@@ -44,12 +44,16 @@ let
continue
fi
# Resolve symlink to get actual device
# Resolve symlink to get actual device (needed for hdparm/smartctl)
device=$(readlink -f "$disk")
short_name=$(basename "$device")
# Extract serial from disk ID for labels (part after last underscore)
serial=$(basename "$disk" | sed 's/.*_//')
# Extract model+serial from disk-by-id path for stable labeling
# ata-ST18000NM000J-2TV103_ZR52TBSB ST18000NM000J-2TV103-ZR52TBSB
# nvme-KIOXIA-EXCERIA_PLUS_G3_SSD_7FJKS1MAZ0E7 KIOXIA-EXCERIA_PLUS_G3_SSD-7FJKS1MAZ0E7
disk_id=$(basename "$disk")
serial=$(echo "$disk_id" | sed 's/.*_//')
model=$(echo "$disk_id" | sed 's/^[^-]*-//; s/_[^_]*$//')
short_name="$model-$serial"
# Check power state without waking disk
power_state=$(${pkgs.hdparm}/bin/hdparm -C "$device" 2>/dev/null | grep -oP '(standby|active/idle|active|idle)' | head -1 || echo "unknown")