Monitoring servers with an USB lamp

For some time now I have been looking for a light that can be easily controlled from a desktop computer or server. The original intention was to have a red lamp in the office hallway and light it up when the unit tests break.

One solution to that idea is using a network-controllable power outlet strip and plug a normal lamp in there. Problem here is the price tag, which is above 100€.

Another solution would be to solder a lamp with an USB connector myself; there are numerous tutorials about that on the internet. Since I am inherently lazy, this was only my last resort when there was no other way out.

A Linux Journal article from 2004(!) told me about a dedicated USB lamp from Delcom which is basically what I want - a USB controllable light - but with a huge price tag of 88 US$ upwards.

Some days ago I came across the DreamCheeky Webmail notifier which actually is a USB lamp with differently colored LEDs inside that can be controlled via USB. After discovering that there is also a linux driver for it, I bought it at the local thinkgeek instance for 15€.

Yesterday it arrived by mail, 5 minutes later the controller program was installed - which supports passing in hex color codes, i.e. usblamp '#FF8000' for a nice orange - and an hour later I had a cron script running that sets the color of the mail notifier according to the load of one of our development servers. The serverload-munin code is part of daniel's git repository now.

The script expects that munin-node (version 1.x) is installed and running on the server, since fetching the load value is really easy using netcat on munin-node's plain text protocol on port 4949.

Photo of the USB lamp in action

Update 2010-12-22: Linux kernel drivers on the way

I just got a mail forwarded by Melchior Franz, noting that Greg Kroah-Hartman accepted Melchior's patch into his usb-next kernel tree ! This means that in the next merge window the patch will get into the linux mainline kernel. Wow! That was really fast.

The kernel already had a USBLED driver for Delcom's USB Visual Signal Indicator, exposing virtual files for red, green and blue in the /sys/ file system. Now that driver has been extended to support Dream Cheeky's DL100B Webmail Notifier - which also brings us support for connecting multiple usb lamps to the computer! This one was lacking in the usblamp tool on github and I already considered implementing it. You've gotta love Open Source for such moments.

Update 2010-12-23: Pimped USB Lamp

Melchior sent a link to photos of his pimped lamp - he removed the original cover and replaced it with one from a bicycle lamp.

Oh, and Conrad sells the lamp for 10€ now.

Update 2011-10-15: Kernel driver usage

Ubuntu 11.10 (Oneiric) ships Linux 3.0.0 which has the drivers included. Multiple lamps are supported!

When attached, the log shows the following:

$ dmesg|tail -n3
[72465.130847] usb 2-1.2: USB disconnect, device number 6
[72468.909763] usb 2-1.2: new low speed USB device number 7 using ehci_hcd
[72469.025013] usbled 2-1.2:1.0: USB LED device now attached

Finding the lamp devices

$ find /sys -name green
/sys/devices/pci0000:00/0000:00:1a.7/usb1/1-1/1-1.3/1-1.3:1.0/green
/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.0/green

2 lamps are attached here.

Changing the color

You may use values from 0 to 255 in the files red, green and blue.

$ cd /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.2/2-1.2:1.0/
$ echo 255 > red
$ echo 255 > green
$ echo 255 > blue

For me, red 50 is the same as red 255.

Comments? Please send an e-mail.