Linux/UPS

From Omnia
Revision as of 16:25, 26 April 2015 by Kenneth (talk | contribs) (→‎apcupsd)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

UPS

APC

use #apcupsd

CyberPower

Use #apcupsd

http://www.cyberpowersystems.com/support/product-support.html

Or you can use APC with these modifications:

# /etc/apcupsd/apcupsd.conf

UPSCABLE usb
UPSTYPE usb
DEVICE

apctest can only perform the following with a CyberPower UPS:

[?]  1)  Test kill UPS power
[X]  2)  Perform self-test
[X]  3)  Read last self-test result
[ ]  4)  View/Change battery date
[ ]  5)  View manufacturing date
[X]  6)  View/Change alarm behavior
[ ]  7)  View/Change sensitivity
[X]  8)  View/Change low transfer voltage  (LOTRANS = 100 Volts)
[X]  9)  View/Change high transfer voltage  (HITRANS = 140 Volts)
[X]  10) Perform battery calibration
[ ]  11) Test alarm
[ ]  12) View/Change self-test interval

apcaccess interesting fields:

# ups details
MODEL    : UPS CP600
SERIALNO : AEC7101.251

# full battery
STATUS   : ONLINE
# low battery
STATUS   : ONLINE LOWBATT

# load level, and battery charge
# full battery
LOADPCT  :  47.0 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT :  12.0 Minutes
# low level battery
LOADPCT  :  48.0 Percent Load Capacity
BCHARGE  : 053.0 Percent
TIMELEFT :   5.1 Minutes

# levels at when the alarm goes off
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
ALARMDEL : 30 seconds

# nominal voltage and wattage
NOMINV   : 120 Volts
NOMPOWER : 340 Watts

apcaccess full battery example:

APC      : 001,032,0795
DATE     : 2013-07-26 22:16:36 -0600
HOSTNAME : prime.t0e.org
VERSION  : 3.14.10 (13 September 2011) redhat
UPSNAME  : prime.t0e.org
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2013-07-26 14:36:27 -0600
MODEL    : UPS CP600
STATUS   : ONLINE
LINEV    : 116.0 Volts
LOADPCT  :  47.0 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT :  12.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
OUTPUTV  : 116.0 Volts
DWAKE    : 000 Seconds
LOTRANS  : 100.0 Volts
HITRANS  : 140.0 Volts
ALARMDEL : 30 seconds
NUMXFERS : 0
TONBATT  : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : WN
STATFLAG : 0x07000008 Status Flag
SERIALNO : AEC7101.251
NOMINV   : 120 Volts
NOMPOWER : 340 Watts
END APC  : 2013-07-26 22:16:41 -0600

apcaccess low battery example:

APC      : 001,032,0803
DATE     : 2013-07-26 14:15:11 -0600
HOSTNAME : prime.t0e.org
VERSION  : 3.14.10 (13 September 2011) redhat
UPSNAME  : prime.t0e.org
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2013-07-26 14:15:09 -0600
MODEL    : UPS CP600
STATUS   : ONLINE LOWBATT
LINEV    : 112.0 Volts
LOADPCT  :  48.0 Percent Load Capacity
BCHARGE  : 053.0 Percent
TIMELEFT :   5.1 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
OUTPUTV  : 112.0 Volts
DWAKE    : 000 Seconds
LOTRANS  : 100.0 Volts
HITRANS  : 140.0 Volts
ALARMDEL : 30 seconds
NUMXFERS : 0
TONBATT  : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : WN
STATFLAG : 0x07000048 Status Flag
SERIALNO : AEC7101.251
NOMINV   : 120 Volts
NOMPOWER : 340 Watts
END APC  : 2013-07-26 14:15:16 -0600

Issues

Transfer to endpoint failed

kernel: [67839.403339] Transfer to device 6 endpoint 0x1 frame 2026 failed - FIQ reported NYET. Data may have been lost.

USB Device 6 turns out to be the UPS:

# lsusb
Bus 001 Device 006: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS

Seems to be an intermittent issue as able to still get UPS device status with apcaccess.

The UPS is connected to a RaspberryPi and Google searches seem to show this issue appears to be isolated to the Raspberry Pi.

apcupsd

apcupsd - APC UPS power control daemon

APCUPSD User Manual - http://www.apcupsd.com/manual/

# CentOS/RedHat:
yum install --enablerepo=rpmforge  apcupsd    # rpmforge
# Ubuntu
apt-get install apcupsd
# /etc/apcupsd/apcupsd.conf

UPSCABLE usb
UPSTYPE usb
DEVICE

Test UPS: (apcupsd can't be running)

# modify/test certain aspects of the UPS
apctest

Start the service:

chkconfig apcupsd on
service apcupsd restart

To get UPS details: (apcupsd must be running

apcaccess

To get the field details:

man apcaccess

References:

apcupsd actions scripts - "This shell script if placed in /etc/apcupsd will be called by /etc/apcupsd/apccontrol when the UPS goes on batteries. We send an email message to root to notify him."

/etc/apcupsd/onbattery - when the UPS goes on batteries
/etc/apcupsd/offbattery - when the UPS comes off batteries
/etc/apcupsd/killpower - before apcupsd kills power in the UPS
/etc/apcupsd/changeme - when battery should be replaced
/etc/apcupsd/commfailure - when apcupsd loses contact with UPS
/etc/apcupsd/commok - when apcupsd restores contact with UPS

NUT

Network UPS Tools - http://www.networkupstools.org/

Network UPS Tools (NUT) project is to provide support for Power Devices, such as Uninterruptible Power Supplies, Power Distribution Units and Solar Controllers.

UPS connected via USB:

ohci_hcd 0000:00:12.0: wakeup
usb 4-3: new low speed USB device using ohci_hcd and address 2
usb 4-3: configuration #1 chosen from 1 choice
hiddev96,hidraw96: USB HID v1.10 Device [CPS UPS CP600] on usb-0000:00:12.0-3

Installation:

mkdir -p ~/.src ; cd ~/.src
wget http://www.networkupstools.org/source/2.6/nut-2.6.5.tar.gz
tar -zvxf nut-2.6.5.tar.gz
cd nut-2.6.5
./configure --prefix /opt/nut
make
sudo make install