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)
> 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/cputemp.sh` 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 PageTop[cputemp]:
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 ”cputemp.sh” that the mrtg-config-file uses to get the cpu-temperature:
#!/bin/sh /usr/local/sbin/k8temp -n 0:0:1 /usr/local/sbin/k8temp -n 0:1:1 echo "" echo ""
Run mrtg (a couple of times)
Check If everything seems to be working. If OK then add this to crontab…