How to monitor hard drive temperature with MRTG and FreeBSD

I really love to monitor my servers, so why shouldn’t I also monitor the temperatures of my hard drives? In my mind a cooler hard drive lives longer than a hot one. However, the google paper on failure trends of hard drives says that the hard drive temperatures doesn’t have an impact on a hard drives life length. But I want things to run cool in my server so here is how I monitor the hard drives with mrtg and FreeBSD.

To be able to get the hard drives temperatures we have to install SmartMonTools.

The smartmontools package contains two utility programs (smartctl and smartd) to control and monitor storage systems using the Self-Monitoring, Analysis and Reporting Technology System (SMART) built into most modern ATA and SCSI harddisks. In many cases, these utilities will provide advanced warning of disk degradation and failure.

Install SmartMonTools
# cd /usr/ports/sysutils/smartmontools
# make install clean

Check the temperature of the drives that you want to monitor
# smartctl -a /dev/ad4 | grep Temperature_Celsius
194 Temperature_Celsius 0x0022 113 103 000 Old_age Always – 34
# smartctl -a /dev/ad6 | grep Temperature_Celsius
194 Temperature_Celsius 0x0022 148 091 000 Old_age Always – 30

Create a script called that outputs the temperatures in a Mrtg friendly way.

/usr/local/sbin/smartctl -a /dev/ad6 | grep Temperature | awk '{print $10}' | tail -n 1
/usr/local/sbin/smartctl -a /dev/ad4 | grep Temperature | awk '{print $10}' | tail -n 1
echo "A long time"
echo ""

Then create a mrtg cfg file called disktemp.cfg:

### Global Config Options
WorkDir: /home/www/mrtg
Options[_]: growright, bits
EnableIPv6: no
Language: swedish

# Sysload
Target[disktemp]: `/usr/local/etc/mrtg/`
MaxBytes[disktemp]: 100
Options[disktemp]: integer,gauge,nopercent
YLegend[disktemp]: Temp (C)
ShortLegend[disktemp]: (C)
Legend1[disktemp]: /dev/ad4
Legend2[disktemp]: /dev/ad6
LegendI[disktemp]: /dev/ad4
LegendO[disktemp]: /dev/ad6
Title[disktemp]: Hard drive Temperature

Hard drive temperature

Run mrtg (a couple of times)
/usr/local/bin/mrtg /usr/local/etc/mrtg/disktemp.cfg

Check If everything seems to be working. If OK then add this to crontab…

The result should be looking like this (in your language):

2 reaktioner till “How to monitor hard drive temperature with MRTG and FreeBSD”

  1. Enkelt att göra. Stor tack!

    Beside hdd temperatures I would also like to add CPU temperature on the same plot. Strangely, but k8temp port does not detect my 6-core AMD BULLDOZER cpu :-(
    Neither sysctl does report any *temp* or *tz* variable even if coretemp.ko is loaded.
    Maybe I have outdated FreeBSD 9.2, need to find a time for upgrade…

Lämna ett svar

Din e-postadress kommer inte publiceras. Obligatoriska fält är märkta *

Denna webbplats använder Akismet för att minska skräppost. Lär dig hur din kommentardata bearbetas.