Jafner.net/homelab/fighter/config/monitoring/scripts/diskstatus.sh
Joey Hafner 6086222503
Reorganize root level of repo.
- Move homelab, Jafner.dev (now called blog) to root.
- Rename "archived projects" -> "archive"
- Rename "active projects" -> "projects"
- Rename "jafner-homebrew" -> "5ehomebrew"
- Rename "docker-llm-amd" -> "local-ai"
2024-07-16 12:17:55 -07:00

20 lines
538 B
Bash

#!/usr/bin/env sh
SMARTCTL=/usr/local/sbin/smartctl
DISKS=$(/sbin/sysctl -n kern.disks | cut -d= -f2)
for DISK in ${DISKS}
do
TEMP=$(${SMARTCTL} -l scttemp /dev/${DISK} | grep '^Current Temperature:' | awk '{print $3}')
HEALTH=$(${SMARTCTL} -H /dev/${DISK} | grep 'test result:' | cut -d: -f2 | sed 's/^[ \t]*//')
if [ -z != ${TEMP} ] && [ -z != ${HEALTH} ]
then
JSON=$(echo ${JSON}{\"disk\":\"${DISK}\",\"health\":\"${HEALTH}\",\"temperature\":${TEMP}},)
fi
done
JSON=$(echo ${JSON} | sed 's/,$//')
echo [${JSON}] >&1