Hard Drive Temperature Monitoring with RRDTool - part 2
This page describes how to modify the HDD temperature monitoring scripts
to display the temperature of multiple HDDs on a single graph.
Refer to the
Hard Drive Temperature Monitoring with RRDTool page
for more details on installation and configuration of the base scripts to monitor
hard drive temperatures on a Linux server.
Screen Shots
Here's a screen shot of the summary page. This page displays the daily graphs
for each of the HDDs being monitored (in my case, only one HDD).

the hddtemp summary page (showing three HDD being monitored)
Script Modifications
If you have multiple HDDs in your linux server with temperature sensors,
the top of your rrd_hddtemp.pl script will
look something like this:
# process data for each specified HDD (add/delete as required)
&ProcessHDD("hda", "10GB Seagate");
&ProcessHDD("hdb", "40GB Seagate");
&ProcessHDD("hdc", "320GB Western Digital");
This will cause the script to periodically poll the temperature of each of the
specified HDDs, store it into a separate rrd database for each HDD,
and create a graph for each HDD for each time interval (day, week, month and year).
To display all HDD temperatures on a single graph, you'll need to make
the following changes to rrd_hddtemp.pl.
Delete or comment out the following lines at the end of the
ProcessHDD function:
# create graphs
&CreateGraph(, "day", );
&CreateGraph(, "week", );
&CreateGraph(, "month", );
&CreateGraph(, "year", );
(Lines of a perl script can be commented out by inserting a #
character at the beginning of the line.)
Insert the following lines immediately after the end of the
ProcessHDD function, and before the
CreateGraph function
(ie, after the the closing } of the ProcessHDD
function):
&CreateGraph("", "day");
&CreateGraph("", "week");
&CreateGraph("", "month");
&CreateGraph("", "year");
This will result in the CreateGraph function being called
once for each time interval when the script is run, rather than being called
once for each HDD for each time interval.
You now need to modify the CreateGraph function
to get it to graph multiple temperatures.
The code below shows an updated version of the CreateGraph
function, with modifications highlighted in
red text, and new lines highlighted in
green text:
sub CreateGraph
{
# creates graph
# inputs: $_[0]: no longer used
# $_[1]: interval (ie, day, week, month, year)
RRDs::graph "$img/hddtemp-$_[1].png",
"--lazy",
"-s -1$_[1]",
"-t hdd temperature :: hard disk drives",
"-h", "80", "-w", "600",
"-a", "PNG",
"-v degrees C",
"--slope-mode",
"DEF:hda=$rrd/hda.rrd:temp:AVERAGE",
"DEF:hdb=$rrd/hdb.rrd:temp:AVERAGE",
"DEF:hdc=$rrd/hdc.rrd:temp:AVERAGE",
"LINE2:hda#FF9900:10GB Seagate (/dev/hda) ",
"GPRINT:hda:MIN: Min\\: %2.lf",
"GPRINT:hda:MAX: Max\\: %2.lf",
"GPRINT:hda:AVERAGE: Avg\\: %4.1lf",
"GPRINT:hda:LAST: Current\\: %2.lf degrees C\\n",
"LINE2:hdb#CC00CC:40GB Seagate (/dev/hdb) ",
"GPRINT:hdb:MIN: Min\\: %2.lf",
"GPRINT:hdb:MAX: Max\\: %2.lf",
"GPRINT:hdb:AVERAGE: Avg\\: %4.1lf",
"GPRINT:hdb:LAST: Current\\: %2.lf degrees C\\n",
"LINE2:hdc#339900:320GB Western Digital (/dev/hdc)",
"GPRINT:hdc:MIN: Min\\: %2.lf",
"GPRINT:hdc:MAX: Max\\: %2.lf",
"GPRINT:hdc:AVERAGE: Avg\\: %4.1lf",
"GPRINT:hdc:LAST: Current\\: %2.lf degrees C\\n";
if ($ERROR = RRDs::error) { print "$0: unable to generate $_[1] graph: $ERROR\n"; }
}
The changes shown above can be summarised as follows:
- the first function parameter, $_[0], is no longer used
- the filename of the output image no longer references a specific HDD, but becomes
hddtemp-interval.png
- the title on the graph no longer references a specific HDD
- the first DEF has been renamed to hda
- the first DEF line references a specific rrd database file
- additional DEF lines have been added for each additional HDD
- additional LINE2 lines have been added for each additional HDD,
to display an additional trend on the graph
- additional GPRINT lines have been added for each additional HDD,
to display legend information for each graph (minimum, maximum, average, and current values)
Viewing the Graphs
To view the consolidated graph, you'll need to edit
/var/www/html/rrdtool/hddtemp.cgi,
and delete or comment out the following lines near the top:
# define hdds to display (add/remove as required)
push (@graphs, "hda");
push (@graphs, "hdb");
push (@graphs, "hdc");
#push (@graphs, "hdd");
and replace it with the following:
# define hdds to display (add/remove as required)
push (@graphs, "hddtemp");
That's it - you can now view multiple HDD temperatures on a single graph.
References
Installing RRDTool
Hard Drive Temperature Monitoring with RRDTool
hddtemp
About RRD Tool
RRD Tool Manual
last updated 27 Dec 2012
|