#!/bin/bash for device in $(smartctl --scan | cut -d' ' -f1) do temp=$(smartctl -n idle -A --json=c $device | jq .temperature.current) if [[ $temp == ?(-)+([0-9]) ]] then echo "smartctl,host=${node.name},device=$device temperature=$temp $(date --utc +%s%N)" elif [[ $temp == null ]] then # hdd might be sleeping continue else # hdd might be unsupported continue fi done