"Red Bear Alert!" - The Hudson Bear Lamps

Skip to end of metadata
Go to start of metadata

Xtreme feedback devices can really help to introduce the concept of continous integration to a team of programmers.

At a customer's site, I installed three colored lamps in the form of cute gummibears (about 40cm in height) hooked up to Ethernet-controlled power sockets. The lamps are placed on a widely visible shelf.

Hudson signature color scheme

 

See the movie! Hudson Bear Lamps on YouTube!

First we followed the official blue-yellow-red "Hudson signature color scheme" with the following meaning of the colors:

Blue bear All projects built successfully.
Yellow bear At least one project is unstable, but not project failed.
Red bear At least one project failed.
Any blinking At least one build in progress.

While in theory this corresponds nicely with the on-screen display of Hudson, in practice it drives programmers nuts, having blinking bears in their field of view for minutes (depening on the build duration).

Traffic light color scheme

So we came up with a more conservative "traffic light" scheme without blinking bears:

Green bear All projects built successfully.
Yellow bear At least one build in progress.
Red bear At least one project failed or is unstable.

Yes, this slightly differs from the official blue-yellow-red "Hudson signature colors" - but the "traffic light" scheme is understood almost intuitively.

The science behind the bears

No matter who sees the bears for the first time: The reaction identifies him or her either as gal, guy, or geek.

Gals

  • Cuuuuuute!
  • I want one of these at my desk, too! Can I adopt one? (Geek in the background: No!)
  • Hey, can you make the red bear light up too? (Same geek in the background: Nooooooo!)

Guys

  • You geeks - what are these girly bears good for?
    Customers / Managers / Colleagues sometimes ask about the meaning of the fancy bears - especially when witnessing a color switch. This is an ideal opportunity to explain how much your company cares about software quality... ;O)

Geeks

  • How do you switch the power?
  • How do you get status information from Hudson?
  • How much did it cost?

O.k. You've read so far. So you qualified as geek and deserve answers.

How do you switch the power?

Ethernet-controlled power sockets are power sockets with typically 2-8 outlets and an embedded web server running on an own IP address. Usually the sockets offer some sort of CGI-based control options. For example, the following URLs switch on/off a specific power outlet (the actual parameters vary from manufacturer to manufacturer):

http://your.socket?F1=0        // Switch socket outlet 1 on.
http://your.socket?F2=1        // Switch socket outlet 2 off.
etc.

If you are more software inclined than a hardware geek, the nice thing about these ready-made power sockets is that you can buy them safety-certified. Then you don't have to worry about burning down your house when running your unit tests and switching high voltage currents...

There are also USB-controlled power sockets. Currently, they are a way cheaper alternative to Ethernet-controlled sockets.

On the other hand, they will require a PC with an USB port running all the time if you can't connect the USB-controlled socket directly to the Hudson server. Even if you have an outdated PC or laptop that you can recycle for this purpose, the energy cost savings for Ethernet-controlled sockets (they typically need just 3-5 Watts) will charge off within the first year.

How do you get status information from Hudson?

Is there a specific "bears plugin" needed for Hudson? Not at all! Hooking up Hudson is actually the simplest part. While Hudson exposes the outcome of terminated builds (successful or not) as RSS feed, it also offers an XML-based API for status information out of the box. Basically you just append /api/xml to the URL of the page you are viewing in your browser. Then you get the same information in an XML-based, machine-processable format.

For example, the following URL will return you the dashboard as XML file:

http://your.hudson.server/api/xml

All you have to do, is to get this URL periodically, scan for status colors and send the corresponding command URLs to your Ethernet-controlled socket. We use an extended version of the short PHP script below that runs continously on the Hudson server (we added logging and error handling in the real thing - but to get the idea, a shorter example serves better).

<?
// URL to Hudson server dashboard (redered as XML)
define("HUDSON_XML_URL", "http://your.hudson.server/api/xml");
// URL to Ethernet-based power socket
define("NETCONTROL_URL", "http://your.socket");

// Power socket configuration
define("GREEN_BEAR", 1);
define("YELLOW_BEAR", 2);
define("RED_BEAR", 3);
define("SWITCH_ON", 0);
define("SWITCH_OFF", 1);

// Enter infinite loop.
while (true) {
  // Retrieve XML data from Hudson.
  $myxml = file(HUDSON_XML_URL);

  // Scan for status colors. Note: No real XML parsing necessary here ;O).
  $isBuilding = strpos(implode($myxml), "_anime</color>") > 0  ? true : false ;
  $isBroken = strpos(implode($myxml), "<color>red") > 0  ? true : false ;

  // Set yellow "Is Building" status light.
  if($isBuilding) {
    switchSocket(YELLOW_BEAR, SWITCH_ON);
  } else {
    switchSocket(YELLOW_BEAR, SWITCH_OFF);
  }

  // Set green/red "Build Outcome" status lights.
  if($isBroken) {
    switchSocket(GREEN_BEAR, SWITCH_OFF);
    switchSocket(RED_BEAR, SWITCH_ON);
  } else {
    switchSocket(RED_BEAR, SWITCH_OFF);
    switchSocket(GREEN_BEAR, SWITCH_ON);
  }

  // Sleep some time...
  sleep(30);
}

function switchSocket($socket, $command) {
  // Use syntax of your specific socket manufacturer here.
  file(NETCONTROL_URL . "?F$socket=$command");
}

?>

How much did it cost?

  • The bear lamps are some 10 EUR each,
  • an Ethernet-controlled socket (3 outlets) some 120 EUR,
  • Hudson is free,
  • and the fun... priceless!
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. May 15, 2008

    Anders Sveen says:

    Where can I find the ethernet-controlled sockets? I'd really like to test those....

    Where can I find the ethernet-controlled sockets? I'd really like to test those.

    1. Jul 09, 2008

      Simon Wiest says:

      Hi Anders, the bears were "en vogue" in the early 90ies in Germany - thus ther...

      Hi Anders,

      the bears were "en vogue" in the early 90ies in Germany - thus there are always some auctions running on the German eBay web site. Unfortunately it's rather difficult to get three identical bears in suitable colors the same time.

      The original design of the bears was done (as far as I know) by a German design studio called "Flötotto". The bears itself are sold under the brand name "Lumibär" - and are quite expensive, about 100 EUR a bear!
      http://www.amazon.de/Lumib%C3%A4r-gr%C3%BCn-H-43-Polypropylen/dp/B000YH3984

      I bought my bears in a German candy store via Internet. The bears were *much* cheaper (15 EUR each). I don't know if they ship internationally and the store website seems to be in German only - but you can try sending them emails in English or I can assist you with the translation if you need to know anything of special interest.
      http://www.baeren-paradies-dessau.de/index.php?cat=c18_Baeren-Leuchten-Hoehe--35-cm.html

      The Ethernet-based controller was bought here:
      http://www.anel-elektronik.de/deutsch/Produkte/NET-PwrCtrl_PRO/net-pwrctrl_pro.html
      (8 sockets = 200 EUR, - that's the equipment I am using. There's also a cheaper 3 socket version, if you really need 3 sockets only.)

      A USB-based controller can be found here:
      http://www.anel-elektronik.de/deutsch/Produkte/USB-PwrCtrl_HOME/usb-pwrctrl_home.html
      (3 sockets = 60 EUR).

      I strongly advise you *not* to buy the very, very cheapest sockets you can get. I've seen lousily manufactured USB sockets starting at 20 EUR - I would not sleep very well operating them out of my line-of-sight... Buy something you trust, i.e. ask the dealer for safety certifications.

      Hope that helps,
      Simon.

      PS: Would you mind sending me a photo of your bears, once they are up and running? I'm planning to create some sort of a "Hudson Bears Gallery" - so I would really appreciate a submission from you ;O

      PPS: I'm not affiliated in any way with the suppliers mentioned above. There may be better/faster/less expensive products and suppliers, but it worked out well for me.

  2. May 16, 2009

    Johannes Schneider says:

    I have created a very small project that implements that functionallity in Java....

    I have created a very small project that implements that functionallity in Java.

    Feel free to use/improve it...

    http://cedarsoft.org/bears/

  3. Sep 15, 2010

    opyate - says:

    Folks who live in London can buy lamps from these guys: http://www.skk.net/fun-...

    Folks who live in London can buy lamps from these guys:

    http://www.skk.net/fun-lights/