Using MRTG to monitor CPU temperatures

OS / Drivers / BIOS
Post Reply
Perforex
Posts: 3
Joined: Fri Apr 22, 2005 12:35 pm
Location: United Kingdom

Using MRTG to monitor CPU temperatures

Post by Perforex »

I bought a couple of second hand BP6's recently to upgrade my very old servers. I run MRTG for monitoring network and CPU load and it got me thinking could I do the same for the CPU temperatures ? Since I didn't find anything on the forums I decided to do it myself. Here's what I did for anyone else who may be interested.

Install MRTG if you haven't already got it. You can find RPM's out there if you're running an RPM friendly distro or take a look at the MRTG site here.

You will also need lm_sensors installed and working as described somewhere on these forums (sorry I can't remember where).

Add the following section to your mrtg config file.



###
# CPU Temperature monitoring
###
Target[cputemp]: `cputemp-mrtg`
Step[cputemp]: 240
Options[cputemp]: nopercent,growright,nobanner,transparent,gauge
MaxBytes[cputemp]: 125
Unscaled[cputemp]: ym
Title[cputemp]: cputemp
PageTop[cputemp]:<H1>Bayleaf CPU Temperatures</H1>
ShortLegend[cputemp]:&
YLegend[cputemp]:Temp Celsius
Legend1[cputemp]:Temp of CPU 1
Legend2[cputemp]:Temp of CPU 2
Legend3[cputemp]:
Legend4[cputemp]:
LegendI[cputemp]:CPU 1
LegendO[cputemp]:CPU 2


Next put this perl script somewhere in the executable path (/usr/bin, usr/local/bin....etc) and call it cputemp-mrtg. Make it executable etc.


#! /usr/bin/perl
$cputemp = `sensors|grep -o "+.*C.*(" | grep -o "+[0-9]*.[0-9]"`;

$cputemp =~ s/^M//g;
$cputemp =~ s/\n/\-/g;
$cputemp =~ s/\+//g;

($cpu1,$cpu2,$board) = split("-",$cputemp);
$cpu1 = int($cpu1);
$cpu2 = int($cpu2);
$board = int($board);

print "$cpu1\n";
print "$cpu2\n";
print "$board\n";
print "Sensor Data \n";


Fire up MRTG and take a look at the results (you may have to wait some time for anything meaningful).

If I could work out how to put images in this post I'd show you what my graphs look like but I can't so pity my stupidity :)

Hope that helps/interests/amuses someone.
File server - Fedora Core 2 - C433@525
Backup server - Fedora Core 2 - C525@600

Rolid as a sock
Derek
Site Admin
Posts: 2489
Joined: Tue Jul 23, 2002 3:55 pm
Location: Canada
Contact:

HotSaNIC

Post by Derek »

Hi Perforex,

Great instructions! I suggest you take a good look at HotSaNIC as well: http://hotsanic.sourceforge.net/

Derek
You do not have the required permissions to view the files attached to this post.
-Derek
Perforex
Posts: 3
Joined: Fri Apr 22, 2005 12:35 pm
Location: United Kingdom

Post by Perforex »

Hi Derek,

Thanks for the link it looks like a really cool monitor. I'll have a play with that when I get some time (how many projects have I said that about).

If anyone else who's reading knows of other "easy to set up" monitors that they can recommend then post a reply. Always love to learn about new stuff. :)
File server - Fedora Core 2 - C433@525
Backup server - Fedora Core 2 - C525@600

Rolid as a sock
Post Reply