Fetches SMART data from Scrutiny's InfluxDB and calculates failure probabilities using the exact BackBlaze tables from SnapRAID source. Key features: - Calculates both v12 (with attr 193) and v13 (without attr 193) algorithms - v12 matches SnapRAID pre-v13.0 (includes Load Cycle Count) - v13 matches modern SnapRAID v13.0+ (excludes Load Cycle Count) - Stores both values for trending and comparison - Correctly applies bit masks (16-bit for 187/188, 32-bit for others) - Annualizes monthly rates and applies Poisson distribution - Logs to PostgreSQL with device metadata Solved the mystery: SnapRAID v12 uses attribute 193 which was removed in v13.0. Load cycle count has massive impact on failure predictions for some drives (80% vs 4% difference). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
91 lines
3.1 KiB
Python
91 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Test attribute 193 calculation"""
|
|
|
|
import math
|
|
|
|
SMART_193_R = [
|
|
0.0000, 0.0016, 0.0032, 0.0036, 0.0039,
|
|
0.0042, 0.0046, 0.0049, 0.0052, 0.0054,
|
|
0.0057, 0.0060, 0.0062, 0.0065, 0.0068,
|
|
0.0071, 0.0074, 0.0077, 0.0080, 0.0083,
|
|
0.0086, 0.0091, 0.0094, 0.0098, 0.0101,
|
|
0.0104, 0.0108, 0.0111, 0.0119, 0.0122,
|
|
0.0127, 0.0130, 0.0134, 0.0137, 0.0141,
|
|
0.0144, 0.0146, 0.0152, 0.0155, 0.0159,
|
|
0.0163, 0.0165, 0.0168, 0.0172, 0.0176,
|
|
0.0179, 0.0184, 0.0188, 0.0190, 0.0194,
|
|
0.0197, 0.0201, 0.0204, 0.0207, 0.0209,
|
|
0.0213, 0.0215, 0.0219, 0.0221, 0.0225,
|
|
0.0229, 0.0234, 0.0241, 0.0246, 0.0253,
|
|
0.0263, 0.0278, 0.0286, 0.0293, 0.0298,
|
|
0.0302, 0.0306, 0.0311, 0.0315, 0.0319,
|
|
0.0322, 0.0329, 0.0334, 0.0338, 0.0343,
|
|
0.0348, 0.0352, 0.0358, 0.0362, 0.0367,
|
|
0.0371, 0.0374, 0.0378, 0.0383, 0.0388,
|
|
0.0393, 0.0397, 0.0401, 0.0404, 0.0410,
|
|
0.0416, 0.0422, 0.0428, 0.0436, 0.0443,
|
|
0.0449, 0.0454, 0.0457, 0.0462, 0.0468,
|
|
0.0473, 0.0479, 0.0483, 0.0488, 0.0491,
|
|
0.0493, 0.0497, 0.0500, 0.0504, 0.0507,
|
|
0.0510, 0.0514, 0.0519, 0.0523, 0.0528,
|
|
0.0533, 0.0538, 0.0542, 0.0547, 0.0551,
|
|
0.0556, 0.0560, 0.0565, 0.0572, 0.0577,
|
|
0.0584, 0.0590, 0.0594, 0.0599, 0.0603,
|
|
0.0607, 0.0611, 0.0616, 0.0621, 0.0626,
|
|
0.0632, 0.0639, 0.0647, 0.0655, 0.0661,
|
|
0.0669, 0.0676, 0.0683, 0.0691, 0.0699,
|
|
0.0708, 0.0713, 0.0719, 0.0724, 0.0730,
|
|
0.0736, 0.0745, 0.0751, 0.0759, 0.0769,
|
|
0.0779, 0.0787, 0.0796, 0.0804, 0.0815,
|
|
0.0825, 0.0833, 0.0840, 0.0847, 0.0854,
|
|
0.0859, 0.0865, 0.0873, 0.0881, 0.0890,
|
|
0.0900, 0.0912, 0.0919, 0.0929, 0.0942,
|
|
0.0956, 0.0965, 0.0976, 0.0986, 0.0995,
|
|
0.1006, 0.1019, 0.1031, 0.1038, 0.1045,
|
|
0.1051, 0.1058, 0.1066, 0.1072, 0.1077,
|
|
0.1084, 0.1091, 0.1099, 0.1104, 0.1111,
|
|
0.1118, 0.1127, 0.1135, 0.1142, 0.1149,
|
|
0.1157, 0.1163, 0.1168, 0.1173, 0.1179,
|
|
0.1184, 0.1189, 0.1195, 0.1203, 0.1208,
|
|
0.1213, 0.1223, 0.1231, 0.1240, 0.1246,
|
|
0.1252, 0.1260, 0.1269, 0.1276, 0.1287,
|
|
0.1303, 0.1311, 0.1319, 0.1328, 0.1335,
|
|
0.1341, 0.1348, 0.1362, 0.1373, 0.1380,
|
|
0.1387, 0.1392, 0.1398, 0.1403, 0.1408,
|
|
0.1412, 0.1418, 0.1422, 0.1428, 0.1434,
|
|
0.1439, 0.1445, 0.1451, 0.1457, 0.1464,
|
|
0.1469, 0.1475, 0.1480, 0.1486, 0.1491,
|
|
0.1498,
|
|
]
|
|
|
|
SMART_193_STEP = 649
|
|
|
|
# User's drive data
|
|
raw_value = 150091
|
|
|
|
# Calculate table index
|
|
table_index = raw_value // SMART_193_STEP
|
|
print(f"Attribute 193 RAW_VALUE: {raw_value}")
|
|
print(f"STEP: {SMART_193_STEP}")
|
|
print(f"Table index: {raw_value} // {SMART_193_STEP} = {table_index}")
|
|
|
|
# Get monthly rate
|
|
if table_index >= len(SMART_193_R):
|
|
table_index = len(SMART_193_R) - 1
|
|
|
|
monthly_rate = SMART_193_R[table_index]
|
|
print(f"Monthly failure rate (SMART_193_R[{table_index}]): {monthly_rate}")
|
|
|
|
# Annualize
|
|
afr = (365.0 / 30.0) * monthly_rate
|
|
print(f"Annualized: (365/30) * {monthly_rate} = {afr:.4f}")
|
|
|
|
# Apply Poisson
|
|
prob = (1 - math.exp(-afr)) * 100
|
|
print(f"Poisson P(failure): (1 - e^(-{afr:.4f})) * 100 = {prob:.2f}%")
|
|
|
|
print("\n" + "="*60)
|
|
print(f"SnapRAID reports: 81%")
|
|
print(f"Our calculation: {prob:.2f}%")
|
|
print("="*60)
|