We are creating a lab of 16 servers here at NetAdminTools.com to test various configurations in a simulated enterprise environment. One of the first problems we needed to solve was remote power management. If you are running a data center, you should seriously consider a commercial product like the APC MasterSwitch. We don’t have that kind of money, though, so here is a way to roll your own. Make sure you discuss this with a qualified electrician first, before you proceed. Our solution uses a BASIC Stamp microcontroller and a relay card by Velleman. We used the optional 2803 transistor arrays with the board. All communication with the power management console is done through a comm port with no handshaking. This means that it is possible to attach this to a modem for remote power control without a CPU. You would have to ensure that there was a mechanism for logging on, though, so not everybody could shut down your servers remotely. 🙂 There are some options on the BASIC Stamp that would do this well. We plan to hook this up to console switch which we will also design using a BASIC Stamp. We will explore the security options for a modem hookup with the console project. I know you want to see this, so here is a picture:
Here is the schematic:
I drew this using xfig. Here is the fig file. Each of the outputs of the BASIC Stamp (P0-P15) connects to the 16 inputs on the Velleman relay board. Each input on the Velleman board simply goes into a 2803 transistor array, and then into a relay. Quite simple, but I found the Velleman board an easy way to get that many relays wired up. One trick I used was to put 7 1N4148 diodes in series to drop the power (VB) off of the Velleman board down to 14 volts or so to power the BASIC Stamp. The BASIC Stamp has a built in 5v voltage regulator and only needs about 7mA, so the funky diode trick works well. I also put 3300 microfarads worth of electrolytic capacitors on the board with the BASIC Stamp to smooth out the power a bit. The Velleman board doesn’t have very good filtering. Connect the transmit line and ground (pin 2 and 9 on the db25 connector in my schematic) to the transmit and ground pins of your comm port.
If you want to use your own relays and have an urge to wire up 16 of them youself, any ‘ole miniature 12v coil relay will work. Jameco has some (Jameco Part #144186) for $3. Just make sure you put a diode on the coil to protect your circuit. A 1N4148 will work fine. If you really want to do this on the cheap, you should be able to hack this together with a Z-80 CPU and a couple Z-80 PIOs. This will cut the cost of parts down to a few bucks, and you could get by with just one PIO if you just have 15 relays. You would have to write a routine to input the serial data. This is probably the cheapest way to get a bunch of i/o lines connected to a microprocessor. A more modern approach would be to use a PIC microcontroller or an Atmel 89C51 flash CPU.
For some insane Z-80 hacking and an opto-isolated parallel port interface, check out , my Z-80 homebrew computer construction site. To put my homebrew to good use, I actually did port both this and the serial console project to my homebrew computer. Details here.
Here is the program that is loaded into the BASIC Stamp. I’m sure there is a more elegant way to do this, but this works just fine at 9600 Baud. The BASIC Stamp inputs 3 digits, triggers the appropriate relay, and then does it all over again. The code to turn on relay 1 is 100. The code to turn off relay 16 is 215. To turn on relay two from a Linux shell:
echo 101 > /dev/ttyS2
(assuming that ttyS2 was hooked up to the BASIC Stamp, of course.) You could do this in many ways, all you have to do is send 3 digits out of a comm port hooked up to the power management console.
To control this, I wrote up a little TCL/TK app using Visual TCL. Here is how it looks.
Here is the TCL source for the above program. I used /dev/modem as the comm port.
Here is a simple perl script that will cycle the relays.
Note that the programs above all assume you are running this on Linux. I’m sure you could get this to work on other operating systems, but you might have some trouble with the comm port routines. I even used WINE to run the BASIC Stamp editor program. Stamp editor version 1.096, w/ WINE version 20010112 works just fab. If you use debug, you have to exit all the way out of the editor to use it again, though. 🙁 Other combinations of WINE and the editor don’t appear to work. I’m not sure that there *is* a version of the Stamp editor that works on Windows 2000. I tried without any luck. Jameco has all of the parts I used in this project. The Velleman board is Jameco Part No. 128910. One reader suggested Siteplayer to connect this to the network. Pretty cool device. You’d have to figure out the security implications, of course. Ya don’t want just anybody powering on and off your servers. Also, as I mentioned before, make sure you consult with a licensed electrician before you even consider using the above. Further, for a datacenter, you should probably spring for the APC product. 🙂