I recently bought a cheap USB thermometer on eBay, to measure the room temperature in the garage where my home server lives. When it finally arrived from Hong Kong, the parcel contained the thermometer, an extension cable and a CD for the Windows drivers and utilities.

HID TEMPer USB thermometer box contents

My server runs Ubuntu 10.10, so the CD went in the bin, and I grabbed the Device::USB::PCSensor::HidTEMPer module from CPAN so I could take temperature readings with a simple Perl script.

As I already run Munin on my server, I set about writing a plugin to graph the temperature from the USB thermometer. Following the Munin plugin-writing guide I came up with this:

Download: Munin plugin for HID TEMPer USB thermometer

To get it working, first install the CPAN module and its dependencies by running the following as root:

aptitude install libusb-dev
cpan Inline::MakeMaker
cpan Device::USB::PCSensor::HidTEMPer

then copy my plugin script to the plugins directory (/etc/munin/plugins on Ubuntu) and make it executable. Next, configure Munin so that this plugin is run as root (required for access to the USB device) by adding the following to the existing config file at /etc/munin/plugin-conf.d/munin-node:

[temperature]
user root

then finally

service munin-node restart

This should work with multiple thermometers if you have more than one, and record values from both the internal and external sensor of each unit. I only have one unit, which only has an internal sensor, as you can see from this screenshot of the Munin output.

Screenshot of temperature graph from Munin plugin for USB thermometers

Hopefully it will continue to get warmer over the coming weeks