SMART Disk Monitoring
Monitor disk health with AI-powered false positive reduction
Overview
SMART (Self-Monitoring, Analysis, and Reporting Technology) provides critical disk health information, but monitoring SMART reports can be challenging due to false positives. Telemetry.host’s AI-powered log analysis helps distinguish real problems from normal SMART metrics.
Basic SMART Monitoring
Simple Daily Check
#!/bin/bash
# smart-check.sh
# Run SMART self-test and get results
smartctl -a /dev/sda | curl -X POST \
https://telemetry.host/ping/PROJECT_KEY/timeout/26h/disk-sda-health?create=1 \
-H "Content-Type: text/plain" \
--data-binary @-
Add to crontab:
# Daily SMART check at 3 AM
0 3 * * * /usr/local/bin/smart-check.sh
Multiple Disks
#!/bin/bash
# smart-check-all.sh
for disk in /dev/sd[a-z]; do
[ -e "$disk" ] || continue
DISK_NAME=$(basename "$disk")
smartctl -a "$disk" | curl -X POST \
"https://telemetry.host/ping/PROJECT_KEY/timeout/26h/disk-$DISK_NAME?create=1" \
-H "Content-Type: text/plain" \
--data-binary @-
done
Understanding SMART Metrics
SMART reports contain various attributes that look like errors but aren’t:
False Positive Examples
These are normal and don’t indicate problems:
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 584) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: (1102) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0x50bd) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 081 064 044 Pre-fail Always - 134493480
3 Spin_Up_Time 0x0003 091 091 000 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 100 100 020 Old_age Always - 34
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 072 060 045 Pre-fail Always - 14223679
9 Power_On_Hours 0x0032 096 096 000 Old_age Always - 3623
10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 020 Old_age Always - 7
184 End-to-End_Error 0x0032 100 100 099 Old_age Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
188 Command_Timeout 0x0032 100 099 000 Old_age Always - 4295032833
190 Airflow_Temperature_Cel 0x0022 063 052 040 Old_age Always - 37 (Min/Max 21/45)
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 120
193 Load_Cycle_Count 0x0032 100 100 000 Old_age Always - 152
194 Temperature_Celsius 0x0022 037 048 000 Old_age Always - 37 (0 21 0 0 0)
195 Hardware_ECC_Recovered 0x001a 023 009 000 Old_age Always - 134493480
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0023 100 100 001 Pre-fail Always - 0
240 Head_Flying_Hours 0x0000 100 253 000 Old_age Offline - 2953 (7 183 0)
241 Total_LBAs_Written 0x0000 100 253 000 Old_age Offline - 10356940746
242 Total_LBAs_Read 0x0000 100 253 000 Old_age Offline - 1281966970
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
The names contain “error”, “fail”, and “uncorrectable” but the RAW_VALUE of 0 means no issues.
AI-Powered False Positive Reduction
Telemetry.host’s AI understands SMART output context and won’t alert on these patterns. It analyzes:
- Attribute names vs actual values
- Threshold violations vs normal reporting
- Historical trends vs one-time spikes
What Triggers Real Alerts
The AI looks for genuine problems:
# Reallocated sectors increasing
5 Reallocated_Sector_Ct 0x0033 095 095 010 Pre-fail Always - 42
# Current pending sectors (disk waiting to reallocate)
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 8
# SMART overall health failing
SMART overall-health self-assessment test result: FAILING_NOW
# Temperature too high
194 Temperature_Celsius 0x0022 045 055 000 Old_age Always - 55 (Max 70)
Advanced Monitoring Patterns
With Error Detection
Add basic error detection before AI analysis:
#!/bin/bash
# smart-check-errors.sh
DISK="/dev/sda"
OUTPUT=$(smartctl -a "$DISK")
# Check overall health
if echo "$OUTPUT" | grep -q "PASSED"; then
STATUS="success"
MESSAGE="Disk health check passed"
else
STATUS="warning"
MESSAGE="Disk health check did not pass - check details"
fi
# Send full output for AI analysis
echo "$OUTPUT" | curl -X POST \
https://telemetry.host/ping/YOUR_MONITOR_ID \
-H "Content-Type: application/json" \
-d "{
\"status\": \"$STATUS\",
\"message\": \"$MESSAGE\"
}" \
--data-binary @-
NVMe Disks
NVMe disks have different SMART attributes:
#!/bin/bash
# nvme-smart-check.sh
DISK="/dev/nvme0n1"
# Get NVMe SMART data
nvme smart-log "$DISK" | curl -X POST \
https://telemetry.host/ping/PROJECT_KEY/timeout/26h/nvme-health?create=1 \
-H "Content-Type: text/plain" \
--data-binary @-
RAID Arrays
Monitor RAID health alongside individual disks:
#!/bin/bash
# raid-smart-check.sh
# Check RAID status
RAID_STATUS=$(cat /proc/mdstat)
# Check individual disks in RAID
for disk in $(grep -o 'sd[a-z]' /proc/mdstat | sort -u); do
smartctl -a "/dev/$disk" >> "/tmp/raid-smart.log"
done
# Send combined report
{
echo "=== RAID Status ==="
echo "$RAID_STATUS"
echo ""
echo "=== Individual Disk SMART ==="
cat "/tmp/raid-smart.log"
} | curl -X POST \
https://telemetry.host/ping/YOUR_MONITOR_ID \
-H "Content-Type: text/plain" \
--data-binary @-
rm "/tmp/raid-smart.log"
Monitoring Specific Attributes
Critical Attributes to Watch
#!/bin/bash
# smart-critical-attrs.sh
DISK="/dev/sda"
# Get specific critical attributes
REALLOCATED=$(smartctl -A "$DISK" | grep Reallocated_Sector_Ct | awk '{print $10}')
PENDING=$(smartctl -A "$DISK" | grep Current_Pending_Sector | awk '{print $10}')
UNCORRECTABLE=$(smartctl -A "$DISK" | grep Offline_Uncorrectable | awk '{print $10}')
# Check if any are non-zero
if [ "$REALLOCATED" -gt 0 ] || [ "$PENDING" -gt 0 ] || [ "$UNCORRECTABLE" -gt 0 ]; then
STATUS="warning"
MESSAGE="Disk showing signs of wear: Reallocated=$REALLOCATED, Pending=$PENDING, Uncorrectable=$UNCORRECTABLE"
else
STATUS="success"
MESSAGE="All critical SMART attributes normal"
fi
curl -X POST https://telemetry.host/ping/YOUR_MONITOR_ID \
-H "Content-Type: application/json" \
-d "{
\"status\": \"$STATUS\",
\"message\": \"$MESSAGE\",
\"metadata\": {
\"reallocated_sectors\": $REALLOCATED,
\"pending_sectors\": $PENDING,
\"uncorrectable_sectors\": $UNCORRECTABLE
}
}"
Temperature Monitoring
#!/bin/bash
# disk-temp-check.sh
DISK="/dev/sda"
TEMP=$(smartctl -A "$DISK" | grep Temperature_Celsius | awk '{print $10}')
if [ "$TEMP" -gt 50 ]; then
STATUS="warning"
MESSAGE="Disk temperature high: ${TEMP}°C"
elif [ "$TEMP" -gt 60 ]; then
STATUS="error"
MESSAGE="Disk temperature critical: ${TEMP}°C"
else
STATUS="success"
MESSAGE="Disk temperature normal: ${TEMP}°C"
fi
curl -X POST https://telemetry.host/ping/YOUR_MONITOR_ID \
-d "{\"status\":\"$STATUS\",\"message\":\"$MESSAGE\"}"
Running SMART Tests
Short Test
# Start short test (takes 1-2 minutes)
smartctl -t short /dev/sda
# Wait for completion
sleep 120
# Get results
smartctl -l selftest /dev/sda | curl -X POST \
https://telemetry.host/ping/YOUR_MONITOR_ID \
-H "Content-Type: text/plain" \
--data-binary @-
Long Test (Weekly)
#!/bin/bash
# weekly-smart-long-test.sh
DISK="/dev/sda"
# Start long test
smartctl -t long "$DISK"
# Long test takes hours - check status
echo "SMART long test started for $DISK"
# Schedule result check for later (e.g., 6 hours)
at now + 6 hours <<EOF
smartctl -l selftest "$DISK" | curl -X POST \
https://telemetry.host/ping/YOUR_MONITOR_ID \
-H "Content-Type: text/plain" \
--data-binary @-
EOF
Add to crontab for weekly runs:
# Weekly long SMART test on Sunday at 2 AM
0 2 * * 0 /usr/local/bin/weekly-smart-long-test.sh
Cloud/VM Considerations
AWS EBS Volumes
AWS doesn’t expose SMART data for EBS volumes. Monitor using CloudWatch metrics instead or use instance store volumes.
Other Cloud Providers
Check if SMART data is available:
# Test if SMART is available
if smartctl -i /dev/sda > /dev/null 2>&1; then
echo "SMART available"
else
echo "SMART not available on this VM"
fi
Best Practices
1. Daily Monitoring
Run daily checks to catch degrading disks early:
0 3 * * * /usr/local/bin/smart-check.sh
2. Let AI Handle False Positives
Send full SMART output - the AI will filter out false positives:
# ✅ Good: Send full output for AI analysis
smartctl -a /dev/sda | curl -X POST {MONITOR_URL}
# ❌ Bad: Try to filter yourself
smartctl -a /dev/sda | grep -v "Error" | curl -X POST {MONITOR_URL}
3. Monitor All Disks
Don’t forget about secondary disks:
for disk in $(lsblk -d -n -o NAME | grep -E '^sd|^nvme'); do
smartctl -a "/dev/$disk" | curl ...
done
4. Track Trends Over Time
The monitoring dashboard shows historical trends to spot gradual degradation.
5. Set Up Notifications
Configure Discord or email notifications for disk warnings - these are time-sensitive.
Troubleshooting
smartctl Command Not Found
Install smartmontools:
# Ubuntu/Debian
sudo apt-get install smartmontools
# RHEL/CentOS
sudo yum install smartmontools
# macOS
brew install smartmontools
Permission Denied
Run with sudo or add to sudoers:
# Run with sudo in cron
0 3 * * * sudo /usr/local/bin/smart-check.sh
# Or add to sudoers (be careful!)
echo "username ALL=(ALL) NOPASSWD: /usr/sbin/smartctl" | sudo tee -a /etc/sudoers.d/smartctl
SMART Not Supported
Some disks don’t support SMART:
smartctl -i /dev/sda | grep "SMART support"
If not supported, consider monitoring at a different level (RAID controller, etc.)
Example Real-World Alerts
✅ True Positive (Real Problem)
Critical Warning: Reallocated sector count increased from 5 to 47 in the last week.
Action: Replace disk immediately, backup data.
❌ False Positive (Not a Problem)
SMART Attribute: Offline_Uncorrectable
Current Value: 100
Threshold: 0
Raw Value: 0
AI Analysis: This is normal. Attribute name contains "uncorrectable" but raw value
is 0, indicating no actual uncorrectable sectors.
Next Steps
- Learn about Notifications
- See backup monitoring examples
- Explore cron job monitoring