#!/bin/bash
set -e

[ -z "$1" ] && {
	echo "need one or more args:"
	echo "  sdb,nametag1"
	echo "  sdc,nametag2"
	echo
	exit 1
}

while true
do
	ts="$(date +%Y-%m%d-%H%M%S)"
	for pair in "$@"
	do
		dev="${pair%%,*}"
		tag="${pair##*,}"
		fn="$tag-$ts"
		
		smartctl -x /dev/$dev > "$fn" ||
			true
			#echo "smart failed for $fn (code $?)"

		grep Temperature_Celsius "$fn"
	done
	sleep 60
done

