On Wed, Jan 6, 2010 at 20:41, Mark Bennett <mark.benn...@public.co.nz> wrote: > Will, > > sorry for picking an old thread, That's okay---I liked this thread ;)
> but you mentioned a psu monitor to supplement the CSE-PTJBOD-CB1. > I have two of these and am interested in your design. > Oddly, the LSI backplane chipset supports 2 x i2c busses that Supermicro > didn't make use of for monitoring the psu's. Okay, here goes. Basically what I found is that the 4-pin cable which comes out of the power supply gives 5 volts (at a very low amperage) when both power supplies are present, and nothing otherwise (on either the leftmost or two rightmost pins; I don't remember and it depends on which way you define as up anyways. Dig out the voltmeter and plug and unplug power supplies until you find it). So the idea is to use that tiny supply to turn on a transistor, and send high-current (well, relatively) 5v from a normal Molex connector to operate a relay. This relay is connected in series with a serial cable, and the machine on the other end runs a small daemon which writes some stuff to the serial port (in this case, a multi-port serial interface left over from our SPARC boxes) and waits to see if it gets stuff back. The source code that I use (which you should probably rewrite, now that I look at it) is attached. The whole thing is a hack, but I can say it works fine in production. I can also draw a simple schematic and recommend parts from Radio Shack if you would like, but I don't have access to that machine until next week and I don't remember exactly how it went. Ask your friendly neighborhood EE and you should be able to get there quickly. Will
#include <sys/select.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> #define TheString "AReallyLongStringThatJustGoesOnAndOn" #define TheStringLength strlen(TheString) #define NAGIOS_UNKN -1 #define NAGIOS_OK 0 #define NAGIOS_WARN 1 #define NAGIOS_CRIT 2 int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %s <tty>\n", argv[0]); exit(NAGIOS_UNKN); } char *ttyName = argv[1]; int fdread = open(ttyName, O_NONBLOCK); if (fdread < 0) { fprintf(stderr, "Error opening %s for read: %s\n", ttyName, strerror(errno)); exit(NAGIOS_UNKN); } int fdwrite = open(ttyName, O_WRONLY); if (fdwrite < 0) { fprintf(stderr, "Error opening %s for write: %s\n", ttyName, strerror(errno)); exit(NAGIOS_UNKN); } struct timeval otimeout, timeout; otimeout.tv_sec = 2; otimeout.tv_usec = 0; // two seconds char temp[64]; #ifdef _LOOPMODE int count = 0; #endif fd_set fdr; FD_ZERO(&fdr); FD_SET(fdread, &fdr); timeout = otimeout; int fdsChanged = select(FD_SETSIZE, &fdr, NULL, NULL, &timeout); if (fdsChanged > 0) read(fdread, temp, 63); // Read anything that might be buffered and discard it outer: #ifdef _LOOPMODE while (1) #endif { FD_SET(fdread, &fdr); // Not sure why this is needed here... int bytesw = write(fdwrite, TheString, TheStringLength); while (bytesw > 0) { timeout = otimeout; fdsChanged = select(FD_SETSIZE, &fdr, NULL, NULL, &timeout); if (fdsChanged == 0) { #ifdef _LOOPMODE fprintf(stderr, "Error reading (try %d): timeout!\n", count); count++; if (count > 5) { fprintf(stderr, "Box is down!\n"); } goto outer; #else printf("Power supply down on Supermicro chassis\n"); exit(NAGIOS_CRIT); #endif } else { #ifdef _LOOPMODE count = 0; #else printf("Supermicro PSU okay\n"); exit(NAGIOS_OK); #endif } int bytesr = read(fdread, &temp, bytesw); if (bytesr < 0) goto outer; temp[bytesr] = '\0'; bytesw -= bytesr; } } }
_______________________________________________ zfs-discuss mailing list zfs-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/zfs-discuss