Jump to content

Request for paralet port output


Obi_One

Recommended Posts

Hello,

 

 

my server have 3 standard fans that run all the time.

would it be nice to have them turn off when all hard drive spin down ?

 

if some one can write a scrip or code to do just that it would be really great.

it would reduce 4W of power consumption and wear and tear on the fans and noise

 

There is a small relay that take about 2mA @5V to turn on. this relay could in turn use to turn on the hard drive cooling fan.

 

basic operation: 

when all hard drive have spin down then send all zero to LPT1.

if a hard drive spin up then send all 1 to LPT1.

 

 

it's that simple.

 

in return I can send you a circuit board fully populated with relay and connector to make you time worth while.

Link to comment

Try this:

 

But, verify first that these two commands turn your relay off and on:

 

echo -n -e '\xff' > /dev/lp0
echo -n -e '\x00' > /dev/lp0

 

Run it through user scripts on whatever cron schedule you want (every hour / 5 minutes / whatever)

 

#!/usr/bin/php
<?PHP
$spinDownAllowed = 0;   # Set this to the maximum number of drives allowed to be spundown in order to switch

function startsWith($haystack, $needle) {
  return $needle === "" || strripos($haystack, $needle, -strlen($haystack)) !== FALSE;
}

$disks = parse_ini_file("/var/local/emhttp/disks.ini",true);
foreach ($disks as $disk) {
  if ( startsWith($disk['color'],"grey") ) { continue; }
  if ( startsWith($disk['name'],"cache") ) { continue; }
  if ( ! strpos($disk['color'],"on") ) {
    ++$spunDown;
  }
}

if ( $spinDownAllowed >= $spunDown ) {
  exec("echo -n -e '\x00' > /dev/lp0");
} else {
  exec("echo -n -e '\xff' > /dev/lp0");
}
?>

 

Link to comment
  • 9 months later...

Hello Squid,

 

Thanks for the code.

 

Sorry about the belay response. I didn't have time to work on it until now.

 

I build the pcb board and ready to test it out. when I try you code above, echo -n -e '\xff' > /dev/lp0

nothing happen. the root@tower: command prompt return right away. So I figured that the parallel port was not enable in the BIOS.

I shut down the server and go into BIOS setup and enable LPT1 as standard LPT.

Reboot again. start the server and log on and run the echo script again. 

This time the command line hang and would not return root@tower:#

I have to do a control C for it to return.

 

any idea why ?.

 

thanks

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...