Created
September 20, 2020 13:46
-
-
Save ngandrass/f28d5d35ff9f18662ddadbef398022c4 to your computer and use it in GitHub Desktop.
FreeNAS / camcontrol disk spindown check shell script with logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
########################################################################### | |
# spincheck.sh | |
# | |
# Determines the power status of given disks without waking them through | |
# usage of smartctl. | |
# | |
# Author: Niels Gandrass | |
# Version: 1.0 | |
# Since: 15.05.2017 | |
########################################################################### | |
##### BEGIN Config parameters ##### | |
# Determines where the output log is written to | |
spinlogfile="spincheck.log" | |
#spinlogfile="/dev/null" | |
# Command used to log output | |
log_output="tee -a $spinlogfile" | |
# Prefix used for device matching | |
device_prefix="ada" | |
# Time between checks in seconds | |
interval=600 | |
#### END Config parameters ##### | |
# Clear logfile | |
#echo "" > $spinlogfile | |
# Get devicelist | |
devices=`camcontrol devlist | grep ada | sed "s/.*(.*,\($device_prefix[0-9]*\))/\1/"` | |
# Print devicelist-header | |
printf "%20s" "" | $log_output | |
for device in $devices; do | |
printf "%5s" $device | $log_output | |
done | |
printf "\n" | $log_output | |
# Main loop | |
while [ 1 ]; do | |
printf "%20s" "`date +"%d.%m.%Y %H:%M:%S"`" | $log_output | |
for device in $devices; do | |
printf "%5s" "`camcontrol cmd $device -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | cut -d " " -f 10 | sed "s/FF/1/" | sed "s/00/0/"`" | $log_output | |
done | |
printf "\n" | $log_output | |
sleep $interval | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment