Skip to content

Instantly share code, notes, and snippets.

@jacobkossman
Created January 24, 2022 02:33
Show Gist options
  • Save jacobkossman/03095f67b02845a27a5602b51558b607 to your computer and use it in GitHub Desktop.
Save jacobkossman/03095f67b02845a27a5602b51558b607 to your computer and use it in GitHub Desktop.
HDD Drive Temps
#! /bin/sh
logslocation="/folderforlogshere/"
for i in $(sysctl -n kern.disks)
do
logfile="${logslocation}disk-${i}.log"
DiskSerNum=`smartctl -a /dev/$i | awk '/Serial Number:/{print $0}' | awk '{print $3}'`
DiskName=`smartctl -a /dev/$i | awk '/Device Model:/{print $0}' | awk '{print $3}'`
echo $DiskSerNum $DiskName >> $logfile
echo "-------------" >> $logfile
echo "" >> $logfile
done
#! /bin/sh
logslocation="/folderforlogshere/"
timestamp() {
date +"%Y-%m-%d %H-%M-%S"
}
for i in $(sysctl -n kern.disks)
do
logfile="${logslocation}disk-${i}.log"
DiskTemp=`smartctl -a /dev/$i | awk '/Temperature_Celsius/{print $0}' | awk '{print $10 "C"}'`
echo [$(timestamp)] $DiskTemp >> $logfile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment