Friday, May 23, 2008

Monitoring HDD temperature with MRTG


I complain a lot about the weather in Bs As, so here is a little script to get the values inside a hard disk on a linux server... On the average, the temperature seems like a really, really torrid summer day around here, say towards the end of December.

In order to get this little script up & you'll need to have the hddtemp program, utility, installed.

The shell script, pretty, pretty simple:

#!/bin/sh

## mrtg-hddtemp.sh

PATH=/bin:/usr/bin:/usr/sbin
DISK='/dev/hdc'

uptime | cut -c 2-
hddtemp ${DISK} | awk '{print $4}'

# EoF #

And the snip from the mrtg.cfg file:

Target[local_hddtemp]: `/usr/local/etc/scripts/dataGathering/mrtg-hddtemp.sh`
Options[local_hddtemp]: nopercent,gauge,noinfo,nobanner,noi,nolegend
Title[local_hddtemp]: HDD temperature
PageTop[local_hddtemp]: HDD temperature
MaxBytes[local_hddtemp]: 100000
YLegend[local_hddtemp]: Degrees
ShortLegend[local_hddtemp]:  
LegendO[local_hddtemp]: Cent: 
Legend2[local_hddtemp]: HDD temperature
WithPeak[local_hddtemp]: wmy
Legend4[local_hddtemp]: Max HDD temperature

Labels: , , ,

6 Comments:

Blogger Rax said...

Hi,

It seems nice.. although it gives me an error

2008-08-05 13:35:21: ERROR: Target[local_hddtemp][_IN_] ' $target->[0]{$mode} ' evaluated to 'NaN' instead of a number

Script itself works and returns temp.

7:37 AM  
Blogger hictio said...

Hi,
Yeah, forgot to mention that, but, what I usually do, once all the mrtg.cfg has been tested, and it is producing such magnificent graphs is that I redirect the cron's output to /dev/null, just in case something goes awful wrong, say, a Saturday afternoon, and on op of the Nagios (or what ever alarms) you start to get an email every 5 minutes.

3:11 AM  
Blogger Sebastian said...

Hi,

you can use "hddtemp -n" to just get an integer of the temperature.

7:26 AM  
Blogger hictio said...

Thanks, Sebastian!
Nevertheless, I'll still redirect the cron's output to /dev/null (once tested, that is)

11:19 AM  
Anonymous Anonymous said...

Can anyone recommend the well-priced Remote Management & Monitoring program for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: N-able N-central configuration management
? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!

12:02 AM  
Anonymous Anonymous said...

"hddtemp --numeric ${DISK}" instead of "hddtemp ${DISK} | awk '{print $4}'" works well and without an error message.

11:14 AM  

Post a Comment

<< Home