Graph FreeBSD cpu temps with ganglia

Just a quick post, here’s a simple script to inject FreeBSD cpu temps into Ganglia. I’ve only tested this in FreeBSD 8.x so I’m not sure if the sysctl calls are there for the older versions. Also you’ll need to kldload the coretemp module, I put the following in my /boot/loader.conf


# Freebsd gmetric CPU temp

CPU0TEMP=`sysctl dev.cpu.0.temperature |awk -F ':' '{print $2}'|cut -f1 -d 'C'`
/usr/local/bin/gmetric --conf=/usr/local/etc/gmond.conf --name=CPU0Temp --value=$CPU0TEMP --type=uint16 --units="Celsius"

Obviously there’s room for improvement, for example this only graphs your CPU 0. You can repeat this for as many CPU’s as your system has.