How to monitor cpu temperature with MRTG on FreeBSD

Have you ever wanted to monitor the cpu temperature on your server with MRTG and FreeBSD? Of course you wanted that if you have a server running in a closet or some other special place. By following my steps you can have a nice graph like below. It is really relaxing to have all vital stats from your server available online.

This small tutorial works if you have the same processor as I have (Athlon 64). The only thing besides MRTG that you need is the k8temp program which is described as ”k8temp is a utility to read the temperature sensors provided by AMD K8 and K10 processors, including most Athlon 64’s and Opterons.” If you don’t have a Athlon 64 cpu there are other programs that should be ok to get the temperature as well.

You should have MRTG installed and be somewhat familiar the concept to get this working…

Check your cpu (if you dont have a clue)
> dmesg | grep Processor
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 5000+ (2599.72-MHz K8-class CPU)

Install k8temp
> cd /usr/ports/sysutils/k8temp/
> make install clean

Then setup mrtg to use k8temp. This is my mrtg-config file: cputemp.cfg

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

# Sysload
Target[cputemp]: `/usr/local/etc/mrtg/`
MaxBytes[cputemp]: 100
Options[cputemp]: integer,gauge,nopercent
YLegend[cputemp]: Temp (C)
ShortLegend[cputemp]: (C)
Legend1[cputemp]: CPU 0:1
Legend2[cputemp]: CPU 0:2
LegendI[cputemp]: CPU 0:1
LegendO[cputemp]: CPU 0:2
Title[cputemp]: CPU Temperature

CPU temperature

By running the ”k8temp” program you get a list of available sensors. Find the temperatures that you are interested in and edit the script below. This is the script ”” that the mrtg-config-file uses to get the cpu-temperature:

/usr/local/sbin/k8temp -n 0:0:1
/usr/local/sbin/k8temp -n 0:1:1
echo ""
echo ""

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

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

En kommentar till “How to monitor cpu temperature with MRTG on FreeBSD”

  1. You don’t actually need k8temp :) you can get the values you need from sysctl:

    ams01# sysctl hw.acpi.thermal.tz0.temperature hw.acpi.thermal.tz1.temperature
    hw.acpi.thermal.tz0.temperature: 38.0C
    hw.acpi.thermal.tz1.temperature: 34.0C

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.