Installing APC UPS and Associated Packages


Recommended Posts

The apcupsd package already understands the PowerChute network protocol.  You can install it and have the network notify the unRAID server to shut down.
Sweet!  They must have added that since last time I tinkered with apcupsd (which was admittedly a while ago now!)

 

Thanks.

Link to comment

Successfully installed, and working like a charm - thanks again for the clue.  For the record, here's the diff required to switch from USB to PCNS monitoring; I removed the requirement for mail since the management card in the UPS already handles email notifications.  Substitute your management card's details in the DEVICE line.

 

--- C:\Users\jon\Downloads\unRAID\FlashBackups\4.4.2\packages\apcupsd-unmenu-package.conf	2008-12-02 11:58:18.000000000 -0500
+++ Y:\packages\apcupsd-unmenu-package.conf	2009-06-20 00:15:15.000000000 -0500
@@ -3,20 +3,21 @@
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_DEPENDENCIES /sbin/powerdown
PACKAGE_MD5 98ef68509ed27848f3a8782784d42c42
PACKAGE_INSTALLATION installpkg apcupsd-3.14.3-i486-1kjz.tgz
-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 sed -i -e "s/^UPSCABLE smart/UPSCABLE ether/" /etc/apcupsd/apcupsd.conf
+PACKAGE_INSTALLATION sed -i -e "s/^UPSTYPE usb/UPSTYPE pcnet/" /etc/apcupsd/apcupsd.conf
+PACKAGE_INSTALLATION sed -i -e "s/^DEVICE \/dev\/ttyS0/DEVICE <UPS IP address>:<admin userid>:<passphrase>/" /etc/apcupsd/apcupsd.conf
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)

 

apcaccess status returns

APC      : 001,053,1329
DATE     : Fri Jun 19 23:44:53 CDT 2009
HOSTNAME : Tower
RELEASE  : 3.14.3
VERSION  : 3.14.3 (20 January 2008) slackware
UPSNAME  : Tower
CABLE    : Ethernet Link
MODEL    : PCNET UPS Driver
UPSMODE  : Stand Alone
STARTTIME: Fri Jun 19 23:44:53 CDT 2009
STATUS   : ONLINE
LINEV    : 120.9 Volts
LOADPCT  :  47.3 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT :  26.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
MAXLINEV : 121.5 Volts
MINLINEV : 119.6 Volts
OUTPUTV  : 120.9 Volts
SENSE    : High
DWAKE    : 180 Seconds
DSHUTD   : 020 Seconds
DLOWBATT : 05 Minutes
LOTRANS  : 103.0 Volts
HITRANS  : 132.0 Volts
RETPCT   : 015.0 Percent
ITEMP    : 27.9 C Internal
ALARMDEL : 5 seconds
BATTV    : 27.6 Volts
LINEFREQ : 60.0 Hz
LASTXFER : Automatic or explicit self test
NUMXFERS : 1
XONBATT  : Fri Jun 19 23:51:58 CDT 2009
TONBATT  : 0 seconds
CUMONBATT: 9 seconds
XOFFBATT : Fri Jun 19 23:52:07 CDT 2009
LASTSTEST: Fri Jun 19 23:51:58 CDT 2009
SELFTEST : NO
STESTI   : 336
STATFLAG : 0x07000008 Status Flag
REG1     : 0x00 Register 1
REG2     : 0x00 Register 2
REG3     : 0x00 Register 3
MANDATE  : 03/25/99
SERIALNO : ############
BATTDATE : 05/15/09
NOMOUTV  : 115 Volts
NOMBATTV :  24.0 Volts
EXTBATTS : 0
FIRMWARE : 70.11.D
APCMODEL : SMART-UPS 1400
END APC  : Sat Jun 20 00:18:00 CDT 2009

 

Now I suppose I'd better go find the powerdown package.  :D

Link to comment
  • 3 months later...

For some reason, the .conf file for apcupsd 3.14.3 which once worked, no longer does (and changing the directory path for the mirror to 12.2 doesn't help), but there was an installed package already here -- something I must have done very early on.  Anyway, unMenu would complain that it was installed but it was 3.14.3 and it expected " ".  I finally gave up on that route, downloaded apcupsd-3.14.3-i486-1486-1kjz.tgz and installed it manually, with sed additions (etal) to the go script.  This is just for background in case it turns out I've done something stupid.  Any reason not to install the newer version, 3.14.7?

 

It seems to work but since there's no UPS connected it bails, which is ok right now.

 

It isn't clear from anything I've read yet, including the apcupsd manual, which APC cards are supported.  The older AP9606 SNMP/Web Management card seems to be covered under the apcupsd.conf UPSTYPE designator 'apcsmart'.  The manual says that same designator should be 'smartups'.  Which is it really?

 

Then supposedly the UPSTYPE of 'pcnet' works only with the AP9617 card.  Is that to say that the AP9617 will also work serially in the 'apcsmart' mode, or is it NET only?

 

 

Then my next problem is that this motherboard only has a single COM port header, no DB-9, and I don't have a plug-in adaptor to backplane with the right pinout, so I want to use a USB->serial adapter.  There's all sorts of conflicting information by kernel build as to what drivers are necessary to support this adapter.

 

My kernel 2.6.29.1-unRAID #2 SMP, recognizes that a device has been plugged in (from the syslog) but there don't seem to be all of the right drivers for it.  Depending on which text you read, it could be missing the usbserial.ko module, or others besides the hiddev, hub, usb, usb-storage, usbfs and usbhid that we seem to have.

 

Can someone tell me what is actually needed to get the USB->serial device working, and which ports it shows up on?  Some text says it'll be under /dev/usb/hiddevX (assuming we're using udev) and others say /dev/ttyusbX.  Some say it doesn't assign the same device name for different plug-ins of the adaptor, others say it does.  I'm really confused over this.

 

It also seems to be unusually hard (for me) to find ready to go driver modules for 2.6.29.1, but there are some for 2.6.29.7.

 

Any tips?

 

--Bill

Link to comment
  • 4 weeks later...

I got my APC UPS hooked up the unraid server and all the software installed.

I just had a power outage for about 5-8 minutes and UNRAID shutdown right away.

 

Is there a way to have the unraid only shutdown when there is say 5 minutes left of battery or something like that?

 

Thx

Link to comment

Is there a way to have the unraid only shutdown when there is say 5 minutes left of battery or something like that?

 

I think it's best to schedule a powerdown if the power has not been present for 3-5 minutes.

Two things wear out the batteries.

Age (inevitable).

Deep Discharge (From what I read on the APC site some time ago. The batteries are only rated for a certain number of deep discharges).

 

Anyone else have comments on this?

Link to comment

I got my APC UPS hooked up the unraid server and all the software installed.

I just had a power outage for about 5-8 minutes and UNRAID shutdown right away.

 

Is there a way to have the unraid only shutdown when there is say 5 minutes left of battery or something like that?

 

Thx

What you are requesting is how apcupsd normally works.  as unMENU's package has it configured, (actually as the package is distributed) it will shut down the server when there is less than 3 minutes time remaining as calculated by the UPS.

 

The file that controls all this is in /etc/apcupsd/apcupsd.conf

 

As distributed, it has this in it:

# 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

 

When you ask for a UPS status report, how much runtime does it say you have remaining?

 

Joe L.

Link to comment

Here is the info from my UPS status page:

 

(from /sbin/apcaccess status)

APC      : 001,044,1098

DATE    : Thu Oct 15 14:55:05 GMT+4 2009

HOSTNAME : Tower

RELEASE  : 3.14.3

VERSION  : 3.14.3 (20 January 2008) slackware

UPSNAME  : Tower

CABLE    : Custom Cable Smart

MODEL    : Back-UPS BR  800

UPSMODE  : Stand Alone

STARTTIME: Thu Oct 15 13:16:45 GMT+4 2009

STATUS  : ONLINE LOWBATT

LINEV    : 123.0 Volts

LOADPCT  :  30.0 Percent Load Capacity

BCHARGE  : 022.0 Percent

TIMELEFT :  0.5 Minutes

MBATTCHG : 5 Percent

MINTIMEL : 3 Minutes

MAXTIME  : 0 Seconds

OUTPUTV  : 120.0 Volts

SENSE    : High

DWAKE    : 000 Seconds

DSHUTD  : 000 Seconds

LOTRANS  : 097.0 Volts

HITRANS  : 138.0 Volts

RETPCT  : 000.0 Percent

ITEMP    : 29.2 C Internal

ALARMDEL : Always

BATTV    : 27.4 Volts

LINEFREQ : 60.0 Hz

LASTXFER : No transfers since turnon

NUMXFERS : 0

TONBATT  : 0 seconds

CUMONBATT: 0 seconds

XOFFBATT : N/A

SELFTEST : NO

STATFLAG : 0x07000048 Status Flag

SERIALNO : QB0408232951 

BATTDATE : 2001-09-25

NOMOUTV  : 120 Volts

NOMINV  : 120 Volts

NOMBATTV :  24.0 Volts

NOMPOWER : 540 Watts

FIRMWARE : 9.o2 .D USB FW:o2

APCMODEL : Back-UPS BR  800

END APC  : Thu Oct 15 14:55:59 GMT+4 2009

 

 

Link to comment

There's why it powered down right away...

 

STATUS  : ONLINE LOWBATT

LOADPCT  :  30.0 Percent Load Capacity

BCHARGE  : 022.0 Percent

TIMELEFT :  0.5 Minutes

 

According to your UPS, its batteries are 22% charged, and you have only 0.5 minutes runtime remaining if power were to fail now.  That might mean it thinks you have only 2 to 3 minutes run-time if fully charged.  Since 0.5 minutes is less than the 3 minutes it is configured to shut down at, it just started the shutdown process right away when you lost power.

 

You need to wait until your batteries are fully charged to see what the total UPS estimated run time is.    If you are just now recovering from an extended outage, then perhaps your batteries just need to recharge.  but, since you said the server powered down immediately, you should not have fully discharged the batteries in the UPS.

 

In that case, you're in the market for a new battery, or a bigger UPS.  (Isn't it great when the UPS can tell you its own status!)

 

Joe L.

Link to comment
  • 5 weeks later...

If I modify the /etc/apcupsd/apcupsd.conf, is there any command I need to run to have the new settings applied? Lets say I want to use my custom .conf file all the time. How can I make my settings the default (between reboots)?

 

Many Thanks

 

Yes, you need to tell it to use the "new" (as in settings, not location of the file) config file.  You do this with the -f argument.

 

apcupsd -f /etc/apcupsd/apcupsd.conf

 

To make these changes permanent(i'm going to assume you use the unmenu package manager to install it), you will need to edit the apcupsd-package-unmenu.conf in your package directory and add/modify some sed lines to make the changes for you on boot.

 

If you give me an idea of the changes you made, possibly include the "new" version of your config file and we can get you set up with your new commands.

 

Cheers,

Matt

Link to comment

Thanks Biggy,

 

Yes I did use unMenu. My change is simple. I just wanted the APC to shutdown after 3min of no power so I changed "TIMEOUT 180". I copied the .conf file to my flash drive. Can I add the above line of code (different path) in my go script for the same affect?

 

apcupsd -f /boot/apcupsd.conf

Link to comment

Thanks Biggy,

 

Yes I did use unMenu. My change is simple. I just wanted the APC to shutdown after 3min of no power so I changed "TIMEOUT 180". I copied the .conf file to my flash drive. Can I add the above line of code (different path) in my go script for the same affect?

 

apcupsd -f /boot/apcupsd.conf

 

It should work, but if you don't like that solution or run into problems, you can use the following:

 

Here is the modified package .conf for unmenu.  Just copy into your package folder and go into the unmenu package manager and disable, then re-enable the package for AUTO install. or add the following line to your apcupsd-unmenu-package.conf.auto_install (in your package folder as well)

sed -i -e "s:^\(TIMEOUT \)0:\1180:" /etc/apcupsd/apcupsd.conf just BEFORE the line /sbin/apcupsd.

 

Your apcupsd-unmenu-package.conf.auto_install file would look like this:

installpkg apcupsd-3.14.3-i486-1kjz.tgz
sed -i -e "s/^DEVICE \/dev\/ttyS0/#DEVICE \/dev\/ttyS0/" /etc/apcupsd/apcupsd.conf
sed -i -e "s/WALL=wall/WALL=\"mail -s 'unRAID_Server_UPS_Alert'\"/" /etc/apcupsd/apccontrol
sed -i -e "s:^\(TIMEOUT \)0:\1180:" /etc/apcupsd/apcupsd.conf
/sbin/apcupsd
#Now, put into place the shutdown script replacement
echo "/sbin/powerdown" >/etc/apcupsd/doshutdown
echo "exit 99" >>/etc/apcupsd/doshutdown
chmod 755 /etc/apcupsd/doshutdown
sed -i -e "s/\/sbin\/poweroff/\/etc\/apcupsd\/apccontrol killpower; \/sbin\/poweroff/" /etc/rc.d/rc.6

(EDIT: AS ALWAYS USE A UNIX FRIENDLY TEXT EDITOR)

 

 

NEW apcupsd-unmenu-package.conf

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/^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 sed -i -e "s:^\(TIMEOUT \)0:\1180:" /etc/apcupsd/apcupsd.conf
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 /sbin/apcaccess status 2>&1 | grep RELEASE | awk '{print $3}'
PACKAGE_VERSION_STRING 3.14.3
PACKAGE_MEMORY_USAGE Light (10K to 500K)

Link to comment
  • 2 weeks later...

Biggy,

 

I finally got around to testing these changes. The instructions you provided worked and I can see the "MAXTIME  : 180 Seconds" when i query "/sbin/apcaccess status".

 

If I copy /etc/apcupsd/apcupsd.conf to my flash and make changes. Then run "apcupsd -f /boot/apc/apcupsd.conf", the apcaccess status reports nothing has changed. No changes are reflected if I copy apcupsd.conf file back to /etc/apcupsd/ and run "/etc/rc.d/rc.acpid restart" either.

 

How can I make changes to the APC settings while the system is running?

 

Many Thanks

 

Link to comment

Biggy,

 

I finally got around to testing these changes. The instructions you provided worked and I can see the "MAXTIME  : 180 Seconds" when i query "/sbin/apcaccess status".

 

If I copy /etc/apcupsd/apcupsd.conf to my flash and make changes. Then run "apcupsd -f /boot/apc/apcupsd.conf", the apcaccess status reports nothing has changed.

Since it is already running, your subsequent second attempt to invoke it is ignored.. You must restart it innstead.

No changes are reflected if I copy apcupsd.conf file back to /etc/apcupsd/ and run "/etc/rc.d/rc.acpid restart" either.

You can do exactly as you said, but to restart apcupsd you would type the following command:

/etc/rc.d/rc.apcupsd restart

 

The command you invoked in rc.d was rc.acpid, it is used to start/stop/restart the ACPI daemon.  It has nothing to do with the UPS daemon. It monitors the power button on the front panel.

 

I know the two files in the rc.d directory have similar looking names, especially if you are even a tiny bit dyslexic, or a tiny bit tired.

How can I make changes to the APC settings while the system is running?

Copy the changed file into place and then call

/etc/rc.d/rc.apcupsd restart

 

ACPI  = Advanced Configuration and Power Interface

APC   = American Power Conversion company.

 

Joe L.

Link to comment

Copy the changed file into place and then call

/etc/rc.d/rc.apcupsd restart

 

Thanks for the quick reply, I get the following error when trying to restart the apc service...

 

root@unraid:/etc/rc.d# rc.apcupsd restart
Stopping apcupsd power management.../rc.apcupsd: line 33: kill: (11110) - No such process
  Failed.
Starting apcupsd power management..touch: cannot touch `/var/lock/subsys/apcupsd': No such file or directory
  Failed.

 

Link to comment
  • 2 weeks later...

Is there a way to have the unraid only shutdown when there is say 5 minutes left of battery or something like that?

 

I think it's best to schedule a powerdown if the power has not been present for 3-5 minutes.

Two things wear out the batteries.

Age (inevitable).

Deep Discharge (From what I read on the APC site some time ago. The batteries are only rated for a certain number of deep discharges).

 

Anyone else have comments on this?

I found a link on APC forums to a Deep Cycle Battery FAQ:

http://www.windsun.com/Batteries/Battery_FAQ.htm

 

In it's Cycles vs Life section there is a graph explaining quite nicely the effect of DOD (Degree of Discharge I guess) on battery life time (charge/discharge cycles). Basicly the less you discharge the better. At the end they are also stating that lead-acid batteries do not have memory thus there is no need for deep discharge ever.

cyclelife2.gif

 

I'm still wondering should I discharge/charge periodically to some level like 50-70%? I tried googling but found basicly nothing. There was some information available in apcupsd documentation about maintaining ups batteries. The most interesting was perhaps the fact that "Runtime calibration" actually fully discharges the battery during the process and is thus not a recommended procedure to do often.

http://www.apcupsd.com/manual/manual.html#maintaining-your-ups-batteries

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.