ewingr

UPS-> Auto Shutdown of Unraid Server?

46 posts in this topic Last Reply

Recommended Posts

I would like to put a UPS on my unraid server that will shut it down when there is a power outage. I think it should be possible to have it do that if the outage is over a time period.

 

Anyway, can anyone tell me what UPS will work with this system (hopefully reaonablly priced), and where I can find drivers/instructions for setup?

 

Share this post


Link to post

You do not need special "drivers" (that is a windows concept) the drivers needed to talk to the UPS are in  unRAID.

You do need to add a package to cleanly power down the server AND a package to monitor and control the UPS.

 

Easiest is the APC brand of ups, others will work, but you will need to work harder to get them recognized.  APC brand has a "apcupsd" package written just for them.

 

Threads are:

http://lime-technology.com/forum/index.php?topic=2293.0  (pointing to the beginning of the next thread

here) But don't get confused.  It was a thread started before any USB communication was possible.  Look starting at here...  http://lime-technology.com/forum/index.php?topic=1528.msg31925#msg31925

 

The specific commands needed for the apcupsd package are here if you don't want to use the unMENU package manager I wrote.  It also has a button to download and install the powerdown package... also needed to cleanly shut down the array before the power-off command is issued when the UPS batteries get near depletion in an extended outage.

 

Joe L.

Share this post


Link to post

Thanks! I'll get an APC, and then check out those threads and see if I can git'er going.

Share this post


Link to post

I can testify that with the correct shutdown scripts (mentioned in those posts) it the apcupsd works great. I have it on 3 machines, the UPS talking to only one and the software talks to the other 2. We had an extended power outage a couple of weeks ago and all 3 machines (2 windows, 1 unRaid) shutdown gracefully.

Share this post


Link to post

I recently did the same thing using a APC UPS.

 

Here is the thread - http://lime-technology.com/forum/index.php?topic=3688.0

 

I'm hoping to get a tutorial of the steps I took completed soon. (Everything required is in the thread though).

 

If I could change one thing, it would be the ability to shut the server down after a user specified time period.  As it is, the server will drain the USP before shutting down.

Share this post


Link to post

 

If I could change one thing, it would be the ability to shut the server down after a user specified time period.  As it is, the server will drain the USP before shutting down.

 

Sounding good. I have ordered an APC UPS.

 

I'm confused about your last sentence. Does't sound like it is working. 

 

It sounds like I should expect that any power blip, whether short or not, will have the sytsem shutdown.

 

 

Share this post


Link to post

I'm confused about your last sentence. Does't sound like it is working. 

THe config file installed by the package has many setable parameters.  As supplied, it will shut down the server when approx 5% of capacity remains, or 5 minutes of run time remain (I'm not home right now, so I might be a tiny bit off, but you get the idea)

 

A short power outage will not power down the server... it takes an extended outage.  If power returns, the server stays on-line and does not shut down at all.  This gets me though most short power blips during summer thunderstorms.

 

You can edit the .conf file for apcupsd, exactly as the install instructions do to set whatever run-time parameters are best for you.  The current .conf file has the paramaters set as I described.  An example on how to edit it using "sed" is given to set the port to the USB port rather than the serial port.

 

The UPS is actually pretty smart, and it monitors battery voltage and current drawn by your server.  I did not have any need to edit the script to shut the server down earlier...

 

The capability he is looking for exists... he just did not edit the apcupsd config file to implement a shorter run-interval.

 

Joe L.

Share this post


Link to post
The capability he is looking for exists... he just did not edit the apcupsd config file to implement a shorter run-interval.

 

I did examine the config file, but to be honest it was well passed my understanding.  I consulted the apcuspd manual as a way to help also, but that only ended up confusing me more.

 

Is it possible you could tell me how to achieve this - say automatic shut-down after a 5min time frame?

 

 

Share this post


Link to post

The capability he is looking for exists... he just did not edit the apcupsd config file to implement a shorter run-interval.

 

I did examine the config file, but to be honest it was well passed my understanding.  I consulted the apcuspd manual as a way to help also, but that only ended up confusing me more.

 

Is it possible you could tell me how to achieve this - say automatic shut-down after a 5min time frame?

 

 

This is an excerpt from the apcupsd manual:

Configuration Directives used during Power Failures

 

In general, none of these directives are required. However, if you have a voltage-signalling (dumb) UPS with a cable that does not support the Low Battery signal, you must set the TIMEOUT directive to force a shutdown.

 

BATTERYLEVEL percent of battery

    If BATTERYLEVEL is specified, during a power failure, apcupsd will halt the system when the remaining battery charge falls below the specified percentage. The default is 5 percent. This directive is ignored for dumb (voltage-signalling) UPSes. To totally disable this counter, set BATTERYLEVEL -1 in your apcupsd.conf file.

MINUTES battery runtime in minutes

    If MINUTES is specified, during a power failure, apcupsd will shutdown the system when the remaining runtime on batteries as internally calculated by the UPS falls below the time specified. The default is 3. This directive is ignored for dumb (voltage-signalling) UPSes. It should be noted that some UPSes report an incorrect value for remaining runtime when the battery is fully charged. This can be checked by examining the TIMELEFT value as printed in the output of an 'apcaccess status' command. If the value is zero or otherwise unreasonable, your UPS is probably broken. In this case, we recommend that you disable this timer by setting MINUTES -1 in your apcupsd.conf file.

TIMEOUT time in seconds

    After a power failure, apcupsd will halt the system when TIMEOUT seconds have expired. A value of zero disables this timer. Normally for all Smart UPS models and dumb UPSes with cables that support low battery detection, this should be zero so that the shutdown time will be determined by the battery level and/or remaining runtime (see above) or in the case of a voltage-signalling UPS, when the battery is exhausted. This command is required for dumb UPSes that do not provide a battery exhausted signal (only testing can determine this point). For more information, see the Testing Apcupsd section of this manual. This timer can also be useful if you want some slave machines to shutdown before other machines to conserve battery power. It is also useful for testing apcupsd because you can force a rapid shutdown by setting a small value (e.g. 60) and pulling the plug to the UPS.

 

TIMEOUT, BATTERYLEVEL, and MINUTES can be set together without problems. apcupsd will react to the first case or test that is valid. Normally SmartUPS users will set TIMEOUT to zero so that the system is shutdown depending on the percentage battery charge remaining (BATTERYLEVEL) or the remaining battery runtime (MINUTES).

 

Now, in the apcupsd supplied config file, these values are pretty well described in the adjacent comments, and are set as shown here:

#

# Note: BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction, so

# the first that occurs will cause the initation of a shutdown.

#

 

# If during a power failure, the remaining battery percentage

# (as reported by the UPS) is below or equal to BATTERYLEVEL,

# apcupsd will initiate a system shutdown.

BATTERYLEVEL 5

 

# If during a power failure, the remaining runtime in minutes

# (as calculated internally by the UPS) is below or equal to MINUTES,

# apcupsd, will initiate a system shutdown.

MINUTES 3

 

# If during a power failure, the UPS has run on batteries for TIMEOUT

# many seconds or longer, apcupsd will initiate a system shutdown.

# A value of 0 disables this timer.

#

#  Note, if you have a Smart UPS, you will most likely want to disable

#    this timer by setting it to zero. That way, you UPS will continue

#    on batteries until either the % charge remaing drops to or below BATTERYLEVEL,

#    or the remaining battery runtime drops to or below MINUTES.  Of course,

#    if you are testing, setting this to 60 causes a quick system shutdown

#    if you pull the power plug.

#  If you have an older dumb UPS, you will want to set this to less than

#    the time you know you can run on batteries.

TIMEOUT 0

 

So... to force a shutdown in 5 minutes, all you need do is set TIMEOUT to 300  (300 seconds) instead of the 0 default value.  As said in the comment in the apcupsd.conf file, this value is usually only used with older "dumb" UPS supplies that are unable to monitor their battery and load capacity, but that does not mean you can't use it... it just means you might shut down earlier than you really need.

 

You can do this by adding one more line to the others used to edit the /etc/apcupsd/apcupsd.conf file.

sed -i -e "s/^TIMEOUT 0/TIMEOUT 300/" /etc/apcupsd/apcupsd.conf

 

 

Note... the other two conditions still apply, if run time drops below 3 minutes, or if there is less than 5% battery capacity left, it will still shut down.

 

Joe L.

 

Share this post


Link to post

Thx Joe for this.  I'm still somewhat confused about this comment,

You can do this by adding one more line to the others used to edit the /etc/apcupsd/apcupsd.conf file.

...and the location of, and the number of files that actually need the line added.

 

I cannot find a file called "/etc/apcupsd/apcupsd.conf" within the apcuspd tgz package.

 

There is one called "/etc/apcupsd/apcupsd.conf.new", but this seems to contain comments more than anything. There is one in the "sbin" folder called "apcuspd", but it doesn't have an extension.

 

The only other one that seems to connect with apcupsd is "apcupsd-unmenu-package.conf" located in the packages folder on the flash.

 

Also, does this new line "sed -i -e "s/^TIMEOUT 0/TIMEOUT 300/" /etc/apcupsd/apcupsd.conf" need to address the powerdown script?? Or, does this line connect with another line that already exists and uses powerdown??

 

Sorry to be so painful  ::)

Share this post


Link to post

Thx Joe for this.  I'm still somewhat confused about this comment,

You can do this by adding one more line to the others used to edit the /etc/apcupsd/apcupsd.conf file.

...and the location of, and the number of files that actually need the line added.

 

I cannot find a file called "/etc/apcupsd/apcupsd.conf" within the apcuspd tgz package.

You do not need to change the .tgz package... leave it as it is.

 

It has within it a script to install itself.  That script copies the apcupsd.conf file into place to /etc/apcupsd/apcupsd.conf  It does this with the following code in doinstall.sh

# Install new conf files if an old version does not exist.
[ -f etc/apcupsd/apcupsd.conf ] && echo Leaving file etc/apcupsd/apcupsd.conf intact || cp etc/apcupsd/apcupsd.conf.new etc/apcupsd
/apcupsd.conf

The apcupsd.conf.new file is the one copied into place... to /etc/apcupsd/apcupsd.conf  but only if the file does not already exist...

 

So... the file will not exist until you run

installpkg  apcupsd-3.14.3-i486-1kjz.tgz

There is one called "/etc/apcupsd/apcupsd.conf.new", but this seems to contain comments more than anything.

Yes... those are the same comments you did not understand, or did not read... commenting the few lines that configure the apcupsd.  It is the default .conf file.

There is one in the "sbin" folder called "apcuspd", but it doesn't have an extension.

Yes, it is the actual program that controls the UPS, it has no extension.

The only other one that seems to connect with apcupsd is "apcupsd-unmenu-package.conf" located in the packages folder on the flash.

Yes, that file is the one I created for the unMENU package manager plugin.  It contains the instructions needed to download and install and configure apcupsd through the unMENU packae manager. 

 

If you are using unMENU, then this whole process is vastly simplified.  If not, you have to do all this at the command line.

 

Are you using unMENU?  Did you use the package manager to install apcupsd?  Or are you trying to do it all on your own?

Also, does this new line "sed -i -e "s/^TIMEOUT 0/TIMEOUT 300/" /etc/apcupsd/apcupsd.conf" need to address the powerdown script??

It modifies the line in apcupsd.conf to set the timeout to 5 minutes.  It is not looked at at all by the powerdown script.

Or, does this line connect with another line that already exists and uses powerdown??

 

The apcupsd program runs and reads /etc/apcupsd/apcupad.conf when it starts.  It is there where it gets its parameters for TIMEOUT, etc.

 

apcupsd monitors the UPS, from the USB connection you connected from the UPS to the unRAID server.  This communication link lets the apcupsd program know when power is lost.

 

When power is lost, and one of the three PARAMETERS in apcupsd.conf are met, then apcupsd invokes a script it looks for in /etc/apcupsd/doshutdown

 

That script was created by the unMENU package installation .conf instructions.  It is that script that calls "powerdown"

 

So, there is a series of process and scripts, all involved.  The extra line I gave you to set the timeout can be executed on the command line, or, you can add it to the lines in the file used by the package manager in unMENU.

 

I strongly suggest you use unMENU to install and configure the apcupsd package.  Once you have unMENU installed, you can even use its built-in config file view/edit page to edit the apcupsd-unmenu-package.conf file to add the one line for TIMEOUT so it looks like this:

[pre]

PACKAGE_NAME apcupsd - A daemon for controlling APC UPS devices

PACKAGE_DESCR Apcupsd can be used for power management and controlling most

PACKAGE_DESCR of APC's UPS models on Unix and Windows machines. <br>Apcupsd works with most of APC's

PACKAGE_DESCR Smart-UPS models as well as most simple signalling models such as Back-UPS and BackUPS-Office.

#PACKAGE_URL http://www.linuxpackages.net/redirect.php?id=12025&url=http://www.linuxpackages.net/download.php?id=12025

PACKAGE_URL http://linuxpackages.cs.utah.edu//Slackware-12.0/ken/apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_FILE apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_INSTALLED /sbin/apcaccess

PACKAGE_DEPENDENCIES /usr/bin/mail, /sbin/powerdown

PACKAGE_MD5 98ef68509ed27848f3a8782784d42c42

PACKAGE_INSTALLATION installpkg apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_INSTALLATION sed -i -e "s/^TIMEOUT 0/TIMEOUT 300/" /etc/apcupsd/apcupsd.conf

PACKAGE_INSTALLATION sed -i -e "s/^DEVICE \/dev\/ttyS0/#DEVICE \/dev\/ttyS0/" /etc/apcupsd/apcupsd.conf

PACKAGE_INSTALLATION sed -i -e "s/WALL=wall/WALL=\"mail -s 'unRAID_Server_UPS_Alert'\"/" /etc/apcupsd/apccontrol

PACKAGE_INSTALLATION /sbin/apcupsd

PACKAGE_INSTALLATION #Now, put into place the shutdown script replacement

PACKAGE_INSTALLATION echo "/sbin/powerdown" >/etc/apcupsd/doshutdown

PACKAGE_INSTALLATION echo "exit 99" >>/etc/apcupsd/doshutdown

PACKAGE_INSTALLATION chmod 755 /etc/apcupsd/doshutdown

PACKAGE_INSTALLATION sed -i -e "s/\/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower; \/sbin\/poweroff/" /etc/rc.d/rc.6

PACKAGE_VERSION_TEST apcaccess status 2>&1 | grep RELEASE | awk '{print $3}'

PACKAGE_VERSION_STRING 3.14.3

PACKAGE_MEMORY_USAGE Light (10K to 500K)

[/pre]

 

I added the line in BLUE above...as an extra command to run on installation.

Sorry to be so painful  ::)

you have a lot to learn... the package manager in unMENU tries to make it easier...  Your instance on changing the defaults without taking the time to read the config file that pretty much describes in detail what needs to be edited is what seems painful.

 

You do realize that the TIMEOUT parameter is for a dumb UPS that is unable to monitor its batteries...???  It is not needed with more modern UPS.  In any case, you can see in the PACKAGE_INSTALLATION lines above that /etc/rc.d/rc.6 is also edited to have the apccontrol program shut off the UPS as one of the last things it does upon shutdown.  (it issues a "apccontrol killpower" command to the UPS.  When the UPS gets this command, it shuts down about 30 seconds later... preserving the last of its batteries.  If you did not do this, the server would shut down, but the UPS would continue to run until its batteries were depleted.

 

 

Share this post


Link to post

Wow...thanks for that awesome explanation Joe. I doubt I would have sorted it out for myself.

 

Yes... those are the same comments you did not understand, or did not read...

 

you have a lot to learn... the package manager in unMENU tries to make it easier...  Your instance on changing the defaults without taking the time to read the config file that pretty much describes in detail what needs to be edited is what seems painful.

 

Sorry for being so inexperienced.  I unfortunately grew up in a time when computers were only something used in a lab.  I never had the chance to play with one until late in life, so I've had to struggle to even understand some of the basics. Most of the stuff I have achieved is done so by following step-by-step instructions (using the internet and patient users like yourself willing to help).  If a step is missed, or something basic that is assumed to be known is left-out, I really get stuck. One other factor is that my short-term memory has been damaged by exposure to a chemical spray (something our government said was safe).  This means I have to write everything down to keep up with things - made even more difficult by time constraints. Life presents some interesting things at times - but I've had to accept this type of stuff is not my forte. So when I say I appreciate the help - I REALLY mean it!

 

As for unMenu - Yes...I did use it to install apcuspd.  I'll work through your comments to add the line you've suggested.

 

You do realize that the TIMEOUT parameter is for a dumb UPS that is unable to monitor its batteries...Huh

 

This is my thinking as to shutting things down after 5 mins.

 

I don't want the UPS to have it's batteries drained before it shuts down the server because I have my satellite receiver also attached to it (a power loss means stuffed-up/partial recordings). If I shutdown the server quickly, there is ample battery time remaining to power the satellite receiver for several hours. As I can't use the server during a power-cut (no power for TV/Amp/XBMC etc), I may as well shut it down to conserve the batteries for the sat box and not miss whatever I'm recording.

 

Is my thinking correct for this scenario?

 

Thx again.

 

 

 

 

Share this post


Link to post

This is my thinking as to shutting things down after 5 mins.

 

I don't want the UPS to have it's batteries drained before it shuts down the server because I have my satellite receiver also attached to it (a power loss means stuffed-up/partial recordings). If I shutdown the server quickly, there is ample battery time remaining to power the satellite receiver for several hours. As I can't use the server during a power-cut (no power for TV/Amp/XBMC etc), I may as well shut it down to conserve the batteries for the sat box and not miss whatever I'm recording.

 

Is my thinking correct for this scenario?

 

Thx again.

Your reasoning is sound, but there is a snag... that line I described in the last post that issues an

apccontrol killpower

command TO THE UPS will cause the UPS to power itself off.  This will not let you use it for the satellite receiver as desired since the UPS will shut itself down shortly after the server shuts down.

 

For your intended use, you do not want to have the line that edits rc.6

Share this post


Link to post

However... the reason it is usually necessary to shut down the UPS is so the unRAID server will restart itself when power is restored.

 

If you do not shut down the UPS, and a 15 minute outage occurs, your unRAID server would shut down at 5 minutes, but until you power it up it will  not power itself back up when power is restored.

 

Joe L.

Share this post


Link to post
Your reasoning is sound, but there is a snag... that line I described in the last post that issues an

apccontrol killpower

command TO THE UPS will cause the UPS to power itself off.  This will not let you use it for the satellite receiver as desired since the UPS will shut itself down shortly after the server shuts down.

 

For your intended use, you do not want to have the line that edits rc.6

 

I knew you were going to say that  :'( - hence the reason I posted my line of thinking and how I wanted to use the UPS.

 

Okay, if the "killpower" is removed, then I guess I could have the possibility of running the UPS batteries completely flat if there was an extended power outage and the sat box is recording.  Does this damage the UPS battery?

 

If I went ahead with this, then I assume I completely remove the line I've marked in RED.

 

PACKAGE_NAME apcupsd - A daemon for controlling APC UPS devices

PACKAGE_DESCR Apcupsd can be used for power management and controlling most

PACKAGE_DESCR of APC's UPS models on Unix and Windows machines. <br>Apcupsd works with most of APC's

PACKAGE_DESCR Smart-UPS models as well as most simple signalling models such as Back-UPS and BackUPS-Office.

#PACKAGE_URL http://www.linuxpackages.net/redirect.php?id=12025&url=http://www.linuxpackages.net/download.php?id=12025

PACKAGE_URL http://linuxpackages.cs.utah.edu//Slackware-12.0/ken/apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_FILE apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_INSTALLED /sbin/apcaccess

PACKAGE_DEPENDENCIES /usr/bin/mail, /sbin/powerdown

PACKAGE_MD5 98ef68509ed27848f3a8782784d42c42

PACKAGE_INSTALLATION installpkg apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_INSTALLATION sed -i -e "s/^TIMEOUT 0/TIMEOUT 300/" /etc/apcupsd/apcupsd.conf

PACKAGE_INSTALLATION sed -i -e "s/^DEVICE \/dev\/ttyS0/#DEVICE \/dev\/ttyS0/" /etc/apcupsd/apcupsd.conf

PACKAGE_INSTALLATION sed -i -e "s/WALL=wall/WALL=\"mail -s 'unRAID_Server_UPS_Alert'\"/" /etc/apcupsd/apccontrol

PACKAGE_INSTALLATION /sbin/apcupsd

PACKAGE_INSTALLATION #Now, put into place the shutdown script replacement

PACKAGE_INSTALLATION echo "/sbin/powerdown" >/etc/apcupsd/doshutdown

PACKAGE_INSTALLATION echo "exit 99" >>/etc/apcupsd/doshutdown

PACKAGE_INSTALLATION chmod 755 /etc/apcupsd/doshutdown

PACKAGE_INSTALLATION sed -i -e "s/\/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower; \/sbin\/poweroff/" /etc/rc.d/rc.6

PACKAGE_VERSION_TEST apcaccess status 2>&1 | grep RELEASE | awk '{print $3}'

PACKAGE_VERSION_STRING 3.14.3

PACKAGE_MEMORY_USAGE Light (10K to 500K)

 

As an after-thought - can the config file be setup to operate the UPS via a set of steps...? Like

 

1 - After 5 mins run the powerdown script (this shuts to the server) - but keep the UPS going.

2 - When the batteries begin to die, use the killpower part.

 

The sat box only runs 35watts, so having an UPS that has an 865W output would run it for quite some time.

 

As for shutting the server down and it NOT starting back up, that wouldn't bother me. I only turn it on when it's needed.  Sometimes several days go passed.  At the end of the day, perhaps it just easier to leave it as it is and manually shut it down during an extended power outage? And I though computers were meant to make life easier  ;D

Share this post


Link to post

As an after-thought - can the config file be setup to operate the UPS via a set of steps...? Like

 

1 - After 5 mins run the powerdown script (this shuts to the server) - but keep the UPS going.

2 - When the batteries begin to die, use the killpower part.

 

As far as i can tell fromt he documentation, there isn't a killpower delay based on percentage of battery left, HOWEVER, there is a parameter that can be set which is TIME based.

 

From apcupsd documentation:

KILLDELAY time in seconds 
If KILLDELAY is set, apcupsd will continue running after a shutdown has been requested, and after the specified time in seconds, apcupsd will attempt to shut off the UPS the power. This directive should normally be disabled by setting the value to zero, but on some systems such as Win32 systems apcupsd cannot regain control after a shutdown to force the UPS to shut off the power. In this case, with proper consideration for the timing, the KILLDELAY directive can be useful. Please be aware, if you cause apcupsd to kill the power to your computer too early, the system and the disks may not have been properly prepared. In addition, apcupsd must continue running after the shutdown is requested, and on Unix systems, this is not normally the case as the system will terminate all processes during the shutdown. 

 

I would suggest running an experiment (or several) to see how long the Sat Receiver lasts on your unplugged/fully charged UPS and then select an appropriate value that will leave a certain amount of power in the batteries.

 

for instance, if you find that your sat can run for 3 hours off the battery and you know that most movies will be at most 2.5 hours, then setting the apc to 2.5 hours (9000 seconds) will ensure that any movie that is recording will finish and that there will still be about 15% of the battery left [(1 - 9000/10800)*100].

 

the modification in your unmenu package file would be (asuming you want to set it at 2.5 hours/9000seconds):

PACKAGE_INSTALLATION sed -i -e "s/^KILLDELAY 0/KILLDELAY 9000/" /etc/apcupsd/apcupsd.conf

 

Like this:

 

PACKAGE_NAME apcupsd - A daemon for controlling APC UPS devices

PACKAGE_DESCR Apcupsd can be used for power management and controlling most

PACKAGE_DESCR of APC's UPS models on Unix and Windows machines. <br>Apcupsd works with most of APC's

PACKAGE_DESCR Smart-UPS models as well as most simple signalling models such as Back-UPS and BackUPS-Office.

#PACKAGE_URL http://www.linuxpackages.net/redirect.php?id=12025&url=http://www.linuxpackages.net/download.php?id=12025

PACKAGE_URL http://linuxpackages.cs.utah.edu//Slackware-12.0/ken/apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_FILE apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_INSTALLED /sbin/apcaccess

PACKAGE_DEPENDENCIES /usr/bin/mail, /sbin/powerdown

PACKAGE_MD5 98ef68509ed27848f3a8782784d42c42

PACKAGE_INSTALLATION installpkg apcupsd-3.14.3-i486-1kjz.tgz

PACKAGE_INSTALLATION sed -i -e "s/^TIMEOUT 0/TIMEOUT 300/" /etc/apcupsd/apcupsd.conf

PACKAGE_INSTALLATION sed -i -e "s/^KILLDELAY 0/KILLDELAY 9000/" /etc/apcupsd/apcupsd.conf

PACKAGE_INSTALLATION sed -i -e "s/^DEVICE \/dev\/ttyS0/#DEVICE \/dev\/ttyS0/" /etc/apcupsd/apcupsd.conf

PACKAGE_INSTALLATION sed -i -e "s/WALL=wall/WALL=\"mail -s 'unRAID_Server_UPS_Alert'\"/" /etc/apcupsd/apccontrol

PACKAGE_INSTALLATION /sbin/apcupsd

PACKAGE_INSTALLATION #Now, put into place the shutdown script replacement

PACKAGE_INSTALLATION echo "/sbin/powerdown" >/etc/apcupsd/doshutdown

PACKAGE_INSTALLATION echo "exit 99" >>/etc/apcupsd/doshutdown

PACKAGE_INSTALLATION chmod 755 /etc/apcupsd/doshutdown

PACKAGE_VERSION_TEST apcaccess status 2>&1 | grep RELEASE | awk '{print $3}'

PACKAGE_VERSION_STRING 3.14.3

PACKAGE_MEMORY_USAGE Light (10K to 500K)

 

I'm not exactly sure how this works though, and have not tested it.  In one description, it suggested the server may not completely shut down until the killpower is sent AFTER the delay, while another source seem to suggest that the killpower command is delivered to the ups with the option to delay it and the ups handles the timing. You may need to do some experimenting to figure everything out.

 

Cheers,

Matt

Share this post


Link to post

As an after-thought - can the config file be setup to operate the UPS via a set of steps...? Like

 

1 - After 5 mins run the powerdown script (this shuts to the server) - but keep the UPS going.

2 - When the batteries begin to die, use the killpower part.

 

As far as i can tell fromt he documentation, there isn't a killpower delay based on percentage of battery left, HOWEVER, there is a parameter that can be set which is TIME based.

 

From apcupsd documentation:

KILLDELAY time in seconds 
If KILLDELAY is set, apcupsd will continue running after a shutdown has been requested, and after the specified time in seconds, apcupsd will attempt to shut off the UPS the power. This directive should normally be disabled by setting the value to zero, but on some systems such as Win32 systems apcupsd cannot regain control after a shutdown to force the UPS to shut off the power. In this case, with proper consideration for the timing, the KILLDELAY directive can be useful. Please be aware, if you cause apcupsd to kill the power to your computer too early, the system and the disks may not have been properly prepared. In addition, apcupsd must continue running after the shutdown is requested, and on Unix systems, this is not normally the case as the system will terminate all processes during the shutdown. 

 

I would suggest running an experiment (or several) to see how long the Sat Receiver lasts on your unplugged/fully charged UPS and then select an appropriate value that will leave a certain amount of power in the batteries.

I interperted that KILLDELAY as the amount of time that the apcupsd daemon process running on the unRAID server would wait until it attempts to shut down the UPS.  Clearly, it cannot do anything once the unRAID server is powered off.

 

If, as you said, it is an initial instruction to the UPS to power itself off after a delay, and if the UPS uses it well after the unRAID server shuts itself down, then it might do exactly as you suggest.    The statement "In addition, apcupsd must continue running after the shutdown is requested, and on Unix systems, this is not normally the case as the system will terminate all processes during the shutdown." seems to indicate otherwise...

 

Joe L.

Share this post


Link to post

If, as you said, it is an initial instruction to the UPS to power itself off after a delay, and if the UPS uses it well after the unRAID server shuts itself down, then it might do exactly as you suggest.    The statement "In addition, apcupsd must continue running after the shutdown is requested, and on Unix systems, this is not normally the case as the system will terminate all processes during the shutdown." seems to indicate otherwise...

 

Joe L.

 

Looking into it further (yay google), the information seems to point overwhelmingly towards the apcupsd process not sending the killpower command until after the KILLDELAY has elapsed.

 

As such, the killdelay parameter probably won't be as helpful as I originally hoped.

 

Sorry,

Matt

Share this post


Link to post

Thx again for the insights.

 

It's just occurred to me (doh!) that the software is actually on the server. Without realising it, I somehow thought the UPS was the smart piece (without considering the communication taking place between the two) - but in fact, it needs apcuspd to tell it what to do.  So if the server shuts off, it no longer has access to that S/ware to receive instructions (unless apcuspd tells it what to do first before the server goes off-line??). (I'll wake up one day!)

 

So...back to just removing the killpower part of the config - is there any downside to that? I guess the UPS won't shutdown and will drain the batteries fully (Could be quite an extended time frame considering the low power requirements of the sat box).

 

I'd like to explore these options further, so I'll do some testing when I get the chance to see what happens.

 

 

 

Share this post


Link to post

Thx again for the insights.

 

It's just occurred to me (doh!) that the software is actually on the server. Without realising it, I somehow thought the UPS was the smart piece (without considering the communication taking place between the two) - but in fact, it needs apcuspd to tell it what to do.  So if the server shuts off, it no longer has access to that S/ware to receive instructions (unless apcuspd tells it what to do first before the server goes off-line??). (I'll wake up one day!)

 

So...back to just removing the killpower part of the config - is there any downside to that? I guess the UPS won't shutdown and will drain the batteries fully (Could be quite an extended time frame considering the low power requirements of the sat box).

 

I'd like to explore these options further, so I'll do some testing when I get the chance to see what happens.

 

 

 

Since most people use their UPS without any smart process on their PC to tell it to shut off, the UPS will figure out its batteries are near depletion and shut itself off even if you do not tell it via apcupsd.

 

For your use, and your desire to have it to continue to power your sat receiver/dvr, it sounds like the best fit.  You just leave off the "killpower" edit of rc.6.

 

Joe L.

Share this post


Link to post

Thx again for the insights.

 

It's just occurred to me (doh!) that the software is actually on the server. Without realising it, I somehow thought the UPS was the smart piece (without considering the communication taking place between the two) - but in fact, it needs apcuspd to tell it what to do.  So if the server shuts off, it no longer has access to that S/ware to receive instructions (unless apcuspd tells it what to do first before the server goes off-line??). (I'll wake up one day!)

 

So...back to just removing the killpower part of the config - is there any downside to that? I guess the UPS won't shutdown and will drain the batteries fully (Could be quite an extended time frame considering the low power requirements of the sat box).

 

I'd like to explore these options further, so I'll do some testing when I get the chance to see what happens.

 

 

 

Since most people use their UPS without any smart process on their PC to tell it to shut off, the UPS will figure out its batteries are near depletion and shut itself off even if you do not tell it via apcupsd.

 

For your use, and your desire to have it to continue to power your sat receiver/dvr, it sounds like the best fit.   You just leave off the "killpower" edit of rc.6.

 

Joe L.

 

Thx Joe...I'll give it a try and see what happens.

Share this post


Link to post

I recently did the same thing using a APC UPS.

 

Here is the thread - http://lime-technology.com/forum/index.php?topic=3688.0

 

I'm hoping to get a tutorial of the steps I took completed soon. (Everything required is in the thread though).

 

If I could change one thing, it would be the ability to shut the server down after a user specified time period.  As it is, the server will drain the USP before shutting down.

 

I received my UPS, and am trying to install today. I found your tutorial (http://lime-technology.com/forum/index.php?topic=3688.msg33310#msg33310) and followed that. I'm not having success

 

 

 

After doing all of that and clicking on the UPS STATUS button, I get this message:

 

(from /sbin/apcaccess status)Error contacting host localhost port 3551: Connection refused

 

So I thought maybe I need to reboot. I shutdown and rebooted, and I get this message:

 

.(from /sbin/apcaccess status)The command '/sbin/apcaccess ' was not found on your system.  You may need to install it.You don't appear to have a UPS monitoring program installed

 

Do I went to the packages, and it appears to not be installed. So I installed again. And now it's iterating through the same thing, connection refused.

 

I did modify the GO file as in your tutorial.

 

Not  sure what I'm missing.

 

[EDIT]

Oh, by the way: After installing I too get the message "Installed, but version is different...", but the button does NOT change to Reinstall. It remains Install. I do click that, but it doesn't seem to do anythign. It seems to me that one problem is the install, or whatever is needed to get it to be there after reboot is not working, and also, that maybe it is not communicating correctly to the UPS.

 

[EDIT 2]

i just went to the tower main screen and found this at the bottom:

 

May 25 15:00:19 Tower apcupsd[2191]: apcupsd FATAL ERROR in linux-usb.c at line 609 Cannot find UPS device -- For a link to detailed USB trouble shooting information, please see .

May 25 15:00:19 Tower apcupsd[2191]: apcupsd error shutdown completed

 

So wondering if may be my comm via the USB wansn't working I unplugged teh USB and plugged to a different port, and got this:

 

May 25 15:07:12 Tower kernel: usb 5-1: USB disconnect, address 2

May 25 15:07:17 Tower kernel: usb 5-2: new low speed USB device using uhci_hcd and address 3

May 25 15:07:17 Tower kernel: usb 5-2: configuration #1 chosen from 1 choice

May 25 15:07:18 Tower kernel: HID device claimed by neither input, hiddev nor hidraw

 

So it seems the USB is OK. Maybe the UPS is defective?

 

 

 

 

 

Share this post


Link to post

You did not say what UPS you are using, and that is important.  As far as I know, this is only for APC UPS's.  If recognized, you should be able to find in your syslog a line similar to any of the following: (assuming a USB connection), (the line usually appears somewhere after the USB setup and before the drive setup)

kernel: hiddev96hidraw0: USB HID v1.10 Device [American Power Conversion Back-UPS RS 1500 FW:8.g9 .D USB FW:g9 ] on usb-0000:00:02.0-8

kernel: hiddev96hidraw0: USB HID v1.10 Device [APC Back-UPS ES 650 FW:825.B1.D USB FW:B1] on usb-0000:00:1d.1-2

kernel: generic-usb 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Back-UPS XS 1300 LCD FW:836.H7 .D USB FW:H7 ] on usb-0000:00:1d.1-2/input0

Share this post


Link to post

ewingr - Sorry to hear of the problems you're having.  Unfortunately, I really can't help that much, as it was more the awesome help from JoeL that saw me through than any skill of my own.

 

Oh, by the way: After installing I too get the message "Installed, but version is different...", but the button does NOT change to Reinstall. It remains Install. I do click that, but it doesn't seem to do anything. It seems to me that one problem is the install, or whatever is needed to get it to be there after reboot is not working, and also, that maybe it is not communicating correctly to the UPS.

 

I vaguely remember I had a similar problem. I repeated the steps several times to make sure I did everything correctly. I think I ended up restarting unMenu (or a reboot) and suddenly it recognised it.

 

Edit: Make sure the line starting it is correct (and on it's own line) in the "Go" script on your flash. See page 1 of my thread.

 

 

Share this post


Link to post

You did not say what UPS you are using, and that is important.  As far as I know, this is only for APC UPS's.  If recognized, you should be able to find in your syslog a line similar to any of the following: (assuming a USB connection), (the line usually appears somewhere after the USB setup and before the drive setup)

kernel: hiddev96hidraw0: USB HID v1.10 Device [American Power Conversion Back-UPS RS 1500 FW:8.g9 .D USB FW:g9 ] on usb-0000:00:02.0-8

kernel: hiddev96hidraw0: USB HID v1.10 Device [APC Back-UPS ES 650 FW:825.B1.D USB FW:B1] on usb-0000:00:1d.1-2

kernel: generic-usb 0003:051D:0002.0001: hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Back-UPS XS 1300 LCD FW:836.H7 .D USB FW:H7 ] on usb-0000:00:1d.1-2/input0

 

Hi.

 

Thanks for your reply. Earlier in this thread (I am the OP), I did reply that I would get an APC. Although I did not specify which specific one.

 

I have an APC BE750G 750VA / 450 Watts unit.

 

Searching my syslog (via the Syslog menu item on from the screen I get from http://tower:8080), I find only the items listed earler that referecne APC in any way:

 

May 25 15:19:09 Tower apcupsd[2338]: apcupsd FATAL ERROR in linux-usb.c at line 609 Cannot find UPS device -- For a link to detailed USB trouble shooting information, please see .

May 25 15:19:09 Tower apcupsd[2338]: apcupsd error shutdown completed

 

It's interesting that the line starts to list where to look for detailed trouble shooting inf, but then doesn't give the details on where.

 

It definitely seems communicating/recognizing the unit is my problen, but I have no idea why or what the next steps would be. I doubt a call to APC would help, as of course I'm not using their software.

Share this post


Link to post


Copyright © 2005-2018 Lime Technology, Inc.
unRAID® is a registered trademark of Lime Technology, Inc.