Verified Commit 917ef350 authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

Fix smart data collection

Resolve issues when a smart self test is in progress and a disk is nvme
which has no ata smart table.
parent a0526102
Pipeline #14819 passed with stage
in 46 seconds
......@@ -44,12 +44,23 @@ for ((i=0; i < $devices_total; i++)); do
echo "smart_device_smart_healthy{disk=\"${disk}\"} 0" >> $TMP_FILE
# NVME ssd's don't have an ata_smart_data table
if [[ "$info" == *"\"ata_smart_data\":"* ]]; then
progress=$(echo $info | jq '.ata_smart_data.self_test.status.string')
# When a self test in progress, smartctl omits the status key which is a bug in smartctl but we'll work around it.
if [[ "$progress" == *"in progress"* ]]; then
echo "smart_device_self_test{disk=\"${disk}\"} 1" >> $TMP_FILE
status=$(echo $info | jq '.ata_smart_data.self_test.status.passed')
if [[ "$status" == "true" ]]; then
echo "smart_device_self_test{disk=\"${disk}\"} 1" >> $TMP_FILE
echo "smart_device_self_test{disk=\"${disk}\"} 0" >> $TMP_FILE
echo "smart_device_self_test{disk=\"${disk}\"} 1" >> $TMP_FILE
echo "smart_temperature_celsius{disk=\"${disk}\"} $(echo $info | jq '.temperature.current')" >> $TMP_FILE
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment