Graphing data from TEMPer USB probes in Cacti, v2.0

I graph the temperature of my server cabinet (at home) and colocation room (at work) in Cacti, using TEMPer USB thermometers. I wrote a handy guide to doing this last year. Unfortunately that guide, and the software I wrote, only worked to query one device. Today I modified it to graph more than one device, and started graphing the ambient temperature of my house.

As you can see, we’re having an unusually warm day in London:


This guide replaces the original one.

1a. Install temper-mon, all dependencies, and udev rules

Users of Debian wheezy/sid or Ubuntu precise should add my precise repository, and run:

sudo apt-get update
sudo apt-get install temper-mon

That’s it. You now have all the required dependencies, the temper-mon program, and a udev rule that allows unprivileged users to query TEMPer devices. You can also download the .deb package directly if you want to try it on another distribution.

Alternatively …

1b. Install temper-mon, all dependencies, and udev rules

If you don’t use a recent Debian/Ubuntu release or don’t want to install my package, however, you’ve got more work to do. Follow steps 1-3 of the original guide. However, use this updated version of temper-mon, and copy it to /usr/bin/temper-mon.

2. Verify that temper-mon can read your device

Now disconnect and reconnect the TEMPer. Verify that you have the correct device with lsusb:

# lsusb
Bus 005 Device 004: ID 1130:660c Tenx Technology, Inc. Foot Pedal/Thermometer

Make sure your device has ID 1130:660c, or temper-mon won’t work for you. This USB device must have “rw-rw-rw-” permissions. The udev rule installed by my package ensures this. Verify with:

# ls -la /dev/bus/usb/005/004 
crw-rw-rw- 1 root root 189, 515 Jul 25 21:46 /dev/bus/usb/005/004

Now check that the web server user can run temper-mon:

sudo -u www-data temper-mon

If you get a reading, you’re ready to move on to the next step. If you have more than one device, test each of them as well:

sudo -u www-data temper-mon 2

or:

sudo -u www-data temper-mon -a

3. Import Cacti templates

Import my “Local – Ambient Temperature” template into Cacti. A copy is also installed by my package in /usr/share/temper-mon.

If you want to modify this template, such as for graphing in degrees in Fahrenheit, see this how-to for graphing data from a script in Cacti.

4. Create Cacti graphs

We are finally ready to create a graph.

  1. “Management” -> “Devices” -> Select your Cacti server
  2. Click “Create Graphs for this Host”
  3. “Graph Templates” -> “Create:” -> select “Local – Ambient Temperature” from pull-down
  4. Under “Custom Data”, Set “Number of device (default is 1)” to the number of the device. If you have one device, leave this blank or set it to 1. For other devices use 2 and up, as you found in step 2 above.
  5. Press “Create”

That’s it! You now have a temperature graph. I recommend using the threshold plugin to issue a warning alert if your server area gets too hot.

Tags: , , , ,

  1. Karel’s avatar

    This guide looks to be EXACTLY what I need, however I cannot seem to locate the ‘temper-mon’ package for the Raspberry Pi, and the cpan method didn’t work.

    Do you have plans to update the Temper-mon Package to allow it to function on the Raspberry Pi? The ability to run more than one sensor from a single PC is awesome!

    Karel

    Reply

    1. Tyler Wagner’s avatar

      That’s a great idea. I’ve just added the temper-mon package to my wheezy repository for Raspberry Pi. I’m not in a position to test with a Temper device right now. The dependencies install, however. Would you mind testing?

      Reply

      1. Karel’s avatar

        I do, and it installed successfully, however for some reason I do not get the device appearing when I run the lsusb command, I may have a different version…. Checking the logs mine is a different version to what yours is/was :(

        usb 1-1.3: new low-speed USB device number 48 using dwc_otg
        usb 1-1.3: New USB device found, idVendor=0c45, idProduct=7401
        usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
        usb 1-1.3: Product: TEMPerV1.4
        usb 1-1.3: Manufacturer: RDing
        input: RDing TEMPerV1.4 as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3:1.0/input/input168

        I may have a look at modifying the code and seeing if I can get it to work anyway

        Reply

        1. Tyler Wagner’s avatar

          My code doesn’t do any of the USB work. It just uses the existing HIDtemper perl libraries. If they don’t support your device, temper-mon won’t.

          Reply

        2. Tyler Wagner’s avatar

          I tested the TEMPer (1130:660c) with my Raspberry Pi, and it works:

          root@raspberrypi:~# temper-mon 
          30.50

          Good luck with the USB HID support for model 0c45:7401. Did you check the changelog for the HIDtemper perl libraries to see if it is supported? You might need to get the latest build with CPAN. It’s not a fun task, but there are guides to help you.

          Reply

        3. CRIMUVI’s avatar

          I did your tutarial and it wors, but now only give me 0 every time, please help (sorry about my english)

          Reply

          1. Tyler Wagner’s avatar

            I’m glad it worked. This hardware isn’t particularly reliable. Try unplugging and reinserting the device.

            Reply

          2. Andrew Gladwell’s avatar

            Very clear guide *except* that the sources for Trusty which I have added to /etc/apt/sources.list do not find temper-mon and the manual download link for the new version pulls down temper-mon.pl not the executable binary.

            Please let me know when the temper-mon program is available.

            Ta.

            Reply

            1. Tyler Wagner’s avatar

              I haven’t tested the package on trusty. Here is the precise .deb. If it works for you, please let me know and I’ll add it to the trusty repo.

              Reply

            2. Tyler Wagner’s avatar

              I’ve added temper-mon to trusty, as it seems to work with one error:

              Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/Device/USB.pm line 10.

              This bug is in Perl’s USB library, but you can work around it with a wrapper script:

              #!/bin/sh
              export CFLAGS=''
              export LDFLAGS=''
              export CPPFLAGS=''
              /usr/bin/temper-mon "$@"

              Unfortunately, setting those environment variables in temper-mon itself via the $ENV{'CFLAGS'}, etc, doesn’t work. If anyone can tell me why, or how I can get around it, please post.

              Reply

            3. Necromago’s avatar

              Dear,

              I have a problem on this step:
              <code class="root@Debian:/usr/local/bin# sudo -u www-data temper-mon
              Can't call method "internal" on an undefined value at /usr/local/bin/temper-mon line 37, line 1.”

              Could you help me ?

              Reply

              1. Tyler Wagner’s avatar

                I can’t help without more information. Are you using my package? If so, on what distribution?

                Please give me details of your Linux distribution, and versions of perl, Device::USB, and Device::USB::PCSensor::HidTEMPer libraries. I also need to know what USB device you have and if permissions were set up correctly.

                Run the following to give me everything, and paste it here:

                cat /etc/issue
                dpkg -l perl libusb-dev libinline-perl libdevice-usb-pcsensor-hidtemper-perl
                lsusb
                find /dev/bus/usb/ -type c -exec ls -l {} \;

                Reply

              2. Necromago’s avatar

                # cat /etc/issue
                Debian GNU/Linux 7 \n \l

                # dpkg -l perl libusb-dev libinline-perl libdevice-usb-pcsensor-hidtemper-perl
                Souhait=inconnU/Installé/suppRimé/Purgé/H=à garder
                | État=Non/Installé/fichier-Config/dépaqUeté/échec-conFig/H=semi-installé/W=attend-traitement-déclenchements
                |/ Err?=(aucune)/besoin Réinstallation (État,Err: majuscule=mauvais)
                ||/ Nom Version Architecture Description
                +++-==========================-==================-==================-==========================================================
                ii libdevice-usb-pcsensor-hid 0.0201-2 i386 Perl module to interface to the HidTEMPer thermometers
                ii libinline-perl 0.50-1 all module for producing simple Foreign Function Interfaces
                ii libusb-dev 2:0.1.12-20+nmu1 i386 userspace USB programming library development files
                ii perl 5.14.2-21+deb7u1 i386 Larry Wall’s Practical Extraction and Report Language

                # lsusb
                Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
                Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
                Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
                Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
                Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
                Bus 003 Device 002: ID 049f:0070 Compaq Computer Corp.
                Bus 003 Device 006: ID 0c45:7401 Microdia

                # find /dev/bus/usb/ -type c -exec ls -l {} \;
                crw-rw-r-T 1 root root 189, 512 juil. 25 08:06 /dev/bus/usb/005/001
                crw-rw-r-T 1 root root 189, 384 juil. 25 08:06 /dev/bus/usb/004/001
                crw-rw-rwT 1 root root 189, 261 juil. 25 10:44 /dev/bus/usb/003/006
                crw-rw-r-T 1 root root 189, 257 juil. 25 08:06 /dev/bus/usb/003/002
                crw-rw-r-T 1 root root 189, 256 juil. 25 08:06 /dev/bus/usb/003/001
                crw-rw-r-T 1 root root 189, 128 juil. 25 08:06 /dev/bus/usb/002/001
                crw-rw-r-T 1 root root 189, 0 juil. 25 08:06 /dev/bus/usb/001/001

                Reply

                1. Tyler Wagner’s avatar

                  Please see this part of my post:

                  Make sure your device has ID 1130:660c, or temper-mon won’t work for you.

                  You don’t have a TEMPer device, you have a Microdia device. Sorry, it’s not supported.

                  Reply

                2. Tyler Wagner’s avatar

                  However, if you are willing to send me a device to work with, I’ll try to add Microdia support. I can’t guarantee that it’s possible, but I’ll try.

                  Reply

                3. Necromago’s avatar

                  Thank you ;)

                  Reply

                4. David’s avatar

                  Nice guide! I have a Temper2 and use another driver to poll the temperature than you use on a Raspi. Did some ugly pipes and renamed it to temper-mon. I think it works the same way as your driver. Cacti is up and running fine, but today I ran into a problem. The temperature I measuring went below 0 C. My Cacti graph will only show 0 and no values below zero. Is this because of how you made the graph templates or something else? Here is a screenshot from my server. https://www.dropbox.com/s/f29ybf833cb7piw/Screenshot%202015-11-27%2013.52.27.jpg?dl=0

                  Keep up the good work :)

                  Reply

                  1. Tyler Wagner’s avatar

                    Yes, the template is configured to lock the minimum at 0 because I use this for internal monitoring and relative graphs (ranged from min to max values read) look really silly to me.

                    Edit the graph template and see the alt-autoscale and lower-limit options. You can edit and save these, and immediately reload the graph to see the changes.

                    Reply

                    1. David’s avatar

                      Thank you. Up and running now :)

                      Reply

Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.