Created
May 2, 2015 17:22
-
-
Save robinwl/65c58b07d8de5567225d to your computer and use it in GitHub Desktop.
HDD temperature in Munin with smartmontools
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/bash | |
# | |
# Configuration | |
# ------------- | |
# [smartctl_hddtemp_*] | |
# user root | |
# group root | |
# env.attribute 194 # Id of SMART attribute, you probably want to use 194. http://en.wikipedia.org/wiki/S.M.A.R.T.#Known_ATA_S.M.A.R.T._attributes | |
# env.warning 50 # The environment variables "warning" and "critical" sets the temperature from which Munin starts to warn. | |
# env.critical 55 | |
# | |
# Requirements | |
# ------------ | |
# - smartmontools installed | |
# - symlink containing target device eg. smartctl_hddtemp_ -> smartctl_hddtemp_sda | |
. $MUNIN_LIBDIR/plugins/plugin.sh | |
HDD=${0##*smartctl_hddtemp_} | |
if [ -n "$attribute" ] && [[ $warning =~ ^-?[0-9]+$ ]]; then | |
ATTRIBUTE_ID="$attribute" | |
else | |
ATTRIBUTE_ID="194" | |
fi | |
if [ "$1" = 'config' ]; then | |
echo "graph_args --lower-limit 0 --upper-limit 100 --rigid" | |
echo "graph_title HDD temperature $HDD" | |
echo "graph_category disk" | |
echo "graph_vlabel Degrees Celsius" | |
echo "temp.label $HDD" | |
echo "temp.draw AREA" | |
echo "temp.colour COLOUR20" | |
if [ -n "$warning" ] && [[ $warning =~ ^-?[0-9]+$ ]]; then | |
echo "temp.warning $warning" | |
fi | |
if [ -n "$critical" ] && [[ $critical =~ ^-?[0-9]+$ ]]; then | |
echo "temp.critical $critical" | |
fi | |
fi | |
TEMPERATURE=$(smartctl -d auto -A /dev/sdb |sed -n '/^.*START OF READ SMART DATA SECTION/,$p' |sed -n -e "s/^${ATTRIBUTE_ID} //p" |awk '{ print $3 }' |sed 's/^0*//') | |
echo "temp.value $TEMPERATURE" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the script. I spotted a few typos:
sdb
at line 48 to$HDD
for this script to run with the drive specified through the magic of the filename