Back ups 650 linux
I recently bought an APC Back-UPS ES 650 uninterruptible power supply (shown on the right). It connects to my computer via a USB cable (actually, via a special APC-supplied cable that has a standard USB connector on the computer end and a standard Ethernet connector on the UPS end — it behaves like a USB though).
To get this to work under Linux, I used the NUT (Network UPS Tools) package with the «usbhid-ups» driver. Note that this driver was called «newhidups» until nut-2.0.5. The instructions below have been updated to reflect the new name.
Update, December 2010: I just bought another APC Back-UPS, since the battery was failing on my old one. Except for minor cosmetic changes, this UPS is identical, including its interface, functionality, and cables, to the one I bought in 2005. I am still using a version of NUT from 2007, which works fine. I’ll update this page if I upgrade to a newer NUT version.
Supported variables and instant commands
The usbhid-ups driver supports the following variables and instant commands for the APC Back-UPS ES 650. Additional variables and commands might be supported by different UPS models.
Variables:
Variable | Typical value | Meaning |
---|---|---|
battery.charge | 100 | Current battery level (percent) |
battery.charge.low | 10 | Battery level when UPS switches to «LB» low battery (percent) |
battery.charge.warning | 50 | Battery level when UPS switches to «Warning» |
battery.date | not set | Date when the battery should be changed |
battery.mfr.date | 2005/04/02 | Date when the battery was manufactured |
battery.runtime | 1980 | Current battery runtime (seconds) |
battery.runtime.low | 120 | Battery runtime when UPS switches to «LB» low battery (seconds) |
battery.type | PbAc | Battery chemistry |
battery.voltage | 13.0 | Current battery voltage (Volt) |
battery.voltage.nominal | 12.0 | Nominal battery voltage |
driver.name | usbhid-ups | Driver name |
driver.parameter.port | auto | Meaningless for USB |
driver.version | 2.2.0 | NUT version |
driver.version.data | APC HID 0.7 | usbhid-ups/APC version |
driver.version.internal | 0.28 | usbhid-ups version |
input.transfer.high | 139 | High voltage transfer point (Volt) |
input.transfer.low | 88 | Low voltage transfer point (Volt) |
input.voltage | 120.0 | Current input voltage |
input.voltage.nominal | 120 | Nominal input voltage |
ups.beeper.status | enabled | State of the beeper: enabled, disabled, or muted |
ups.delay.shutdown | -1 | Time left until shutdown (seconds) |
ups.firmware | 818.w1.D | Firmware version |
ups.firmware.aux | w1 | Firmware version |
ups.load | 9 | Current load on UPS (percent) |
ups.mfr | APC | UPS manufacturer |
ups.mfr.date | 2005/04/02 | Date when UPS was manufactured |
ups.model | Back-UPS ES 650 | UPS model |
ups.serial | QB0514132764 | UPS serial number |
ups.status | OL | UPS status (OL=on line, OB=on battery, CHRG=charging, DISCHRG=discharging, etc |
Instant commands:
Instant command | Meaning |
---|---|
test.panel.start | Start testing the UPS panel (this will beep) |
test.panel.stop | Stop a UPS panel test (this will do nothing) |
load.off | Turn off the load immediately, and return when power is back |
shutdown.return | Turn off the load after a 60 second delay, and return when power is back |
shutdown.stop | Stop a shutdown in progress |
beeper.on | Enable the UPS beeper |
beeper.off | Mute the UPS beeper (it will revert to «enabled» once the UPS goes back online) |
Download
Installation instructions
The following installation instructions assume that you have downloaded the source distribution, as described under «Download» above. They are more or less similar to the instructions contained in the files INSTALL and in the FAQ that comes with NUT. I have customized them for the usbhid-ups driver, which has some special requirements (e.g. there is no «port» to specify, and «upsdrvctl shutdown» does not work).
In the instructions below, the commands shown in blue must be issued as root; the commands shown in green can be issued as an ordinary user.
- Check if you need to install libusb. Do:
ls /usr/lib/libusb* /usr/include/usb.h
If you see /usr/include/usb.h and libusb-0.1.so.4.4.0 or higher, or libusb-0.1.4.4.0 or higher, you don’t need to install or upgrade libusb. Otherwise, download libusb at the website mentioned above, and install it using the instructions that come with it. Here is how I did it.
tar zxf libusb-0.1.10a.tar.gz ./configure --prefix=/usr make make install
tar zxf nut-2.0.3.tar.gz cd nut-2.0.3
./configure --with-user=ups --with-group=ups --with-drivers=usbhid-ups --prefix=/usr make
Note: the «—prefix=/usr» options causes all files to be installed in /usr, rather than /usr/local (the default). I prefer this because sometimes /usr/local is not mounted when the system’s shutdown script runs, and you definitely need to be able to access your UPS while the computer shuts down.
Also note: if you happen to re-run «./configure» with different options, then you must also run «make clean» before you run «make» again.
/usr/etc/ups.conf: ---------------------------------------------------------------------- [apc] driver = usbhid-ups port = auto desc = "APC Back-UPS ES 650" ----------------------------------------------------------------------
chown ups:ups /usr/etc/ups.conf chmod 0600 /usr/etc/ups.conf
mkdir -p /var/state/ups chmod 0700 /var/state/ups chown ups:ups /var/state/ups
drivers/usbhid-ups -u root -DD -a apc
This should give you lots of debugging output and should announce that your UPS was found. This is just a test. Don’t forget to stop the driver again by pressing CTRL-C.
Note: until you install the hotplug script (see the next step below), the usbhid-ups driver must be run as the root user, which is specified by the «-u root» option.
drivers/usbhid-ups -u root -k -a apc
Do the following. Note that the file «scripts/hotplug/libhidups» should have been generated by «./configure» above.
cp scripts/hotplug/libhidups /etc/hotplug/usb/ cp scripts/hotplug/libhid.usermap /etc/hotplug/usb/ chmod 0755 /etc/hotplug/usb/libhidups chmod 0644 /etc/hotplug/usb/libhid.usermap
Check if the hotplug script is working. You will need to know the answer to this before you continue. Unplug and re-plug the USB cable of your UPS. Do
You should see listings of several directories. You should see at least one file owned by «root ups», for example:
/proc/bus/usb/002: total 0 -rw-r--r-- 1 root root 43 Aug 28 16:33 001 -rw-r--r-- 1 root ups 52 Aug 28 16:33 002
The actual file names will most likely be different; it is the ownership that matters. If you see a file owned by «root ups», then skip the next paragraph and continue with the instructions.
drivers/usbhid-ups -DD -a apc drivers/usbhid-ups -k -a apc
/usr/etc/upsd.conf: ---------------------------------------------------------------------- ACL all 0.0.0.0/0 ACL localhost 127.0.0.1/32 ACCEPT localhost REJECT all ---------------------------------------------------------------------- /usr/etc/upsd.users: ---------------------------------------------------------------------- [admin] password = password1 allowfrom = localhost actions = SET instcmds = ALL [monuser] password = password2 allowfrom = localhost upsmon master ---------------------------------------------------------------------- /usr/etc/upsmon.conf: ---------------------------------------------------------------------- MONITOR apc@localhost 1 monuser password2 master MINSUPPLIES 1 SHUTDOWNCMD "/sbin/shutdown -h +0" POLLFREQ 5 POLLFREQALERT 5 HOSTSYNC 15 DEADTIME 15 POWERDOWNFLAG /etc/killpower RBWARNTIME 43200 NOCOMMWARNTIME 300 FINALDELAY 5 ----------------------------------------------------------------------
chown ups:ups /usr/etc/upsd.conf chown ups:ups /usr/etc/upsd.users chown ups:ups /usr/etc/upsmon.conf chmod 0600 /usr/etc/upsd.conf chmod 0600 /usr/etc/upsd.users chmod 0600 /usr/etc/upsmon.conf
upsdrvctl start apc upsd
battery.charge: 100 battery.charge.low: 10 battery.charge.warning: 50 battery.date: not set battery.mfr.date: 2005/04/02 battery.runtime: 2850 battery.runtime.low: 120 battery.voltage: 13.0 battery.voltage.nominal: 12.0 driver.name: usbhid-ups driver.parameter.port: auto driver.version: 2.0.3 driver.version.data: APC HID 0.8 driver.version.internal: 0.28 input.transfer.high: 139 input.transfer.low: 88 input.voltage: 110.0 input.voltage.nominal: 120 ups.beeper.status: disabled ups.delay.shutdown: -1 ups.firmware: 818.w1.D ups.firmware.aux: w1 ups.load: 20 ups.mfr: APC ups.mfr.date: 2005/04/02 ups.model: Back-UPS ES 650 ups.serial: QB0514132764 ups.status: OL
upscmd -l apc@localhost Instant commands supported on UPS [apc@localhost]: test.panel.start - Start testing the UPS panel test.panel.stop - Stop a UPS panel test load.off - Turn off the load immediately shutdown.return - Turn off the load and return when power is back shutdown.stop - Stop a shutdown in progress beeper.on - Enable the UPS beeper beeper.off - Disable the UPS beeper
upscmd -u admin apc@localhost load.off
if [ -f /etc/killpower ] ; then # if USB is already disabled, re-enable it. if [ ! -f /proc/bus/usb/devices ]; then echo "Mounting USB filesystem" mount -t usbfs usbfs /proc/bus/usb fi # hotplugging is probably off, so run driver as -u root echo "Killing the power, bye!" /usr/bin/upsdrvctl -u root shutdown apc sleep 20 # uh oh. the UPS power-off failed # you probably want to reboot here so you don't get stuck! # *** see the section on power races in shutdown.txt! *** echo "Rebooting." reboot fi
Next, try out your shutdown script. Make sure you read the rest of the instructions for Step 15 before issuing the command below, as that command will shut down your computer.
One way to test your shutdown scripts is to unplug your UPS from the wall and to wait until the battery runs out. This method takes a very long time. A better method is to leave your UPS plugged in, and issue the command below. (I am assuming that «upsmon» is already running, otherwise, repeat Step 13 above).
Note: this command will cause your computer to go through its ordinary shutdown sequence, as if there had been a power failure and low battery condition. At the end of the shutdown sequence, you should see the message «Killing the power, bye!», and the desk lamp (or whatever you have attached to your UPS) should briefly go off. Then after about 20 seconds, your computer will reboot. Note: if it had been your computer, and not the lamp, plugged into the UPS, then your computer would have gone off too.
upsdrvctl start apc upsd upsmon
echo "Starting UPS driver, daemon, and monitor." /usr/bin/upsdrvctl start /usr/sbin/upsd /usr/sbin/upsmon
ups 7491 1 0 13:32 ? 00:00:00 /usr/bin/usbhid-ups -a apc ups 7493 1 0 13:32 ? 00:00:00 /usr/sbin/upsd root 7495 1 0 13:32 ? 00:00:00 /usr/sbin/upsmon ups 7496 7495 0 13:32 ? 00:00:00 /usr/sbin/upsmon
Special Notes
- Question: I’m running Fedora on a MacMini and can’t figure out how to turn on the BIOS option to automatically restart after a power failure. OSX has an option in the System Preferences, but since I’m running Fedora, I’m not sure how to do it.
echo server_mode=1 > /proc/pmu/options
Sponsored Links
- Refurbished APC UPS. I have not tried this myself, but you may be able to get a good deal on a refurbished UPS (with brand-new batteries) from this site. I’d be happy to receive feedback from people who buy a UPS via this link. (Added , 2009).
Back ups 650 linux
2 0 создан: 2020-04-10 22:07:07
пользователь: cloud раздел: технологии
[2891]
подключаем ибп к компьютеру
service udev restart
upsdrvctl start
nut.conf
MODE=standalone
ups.conf
[ippon]
driver = blazer_usb
port = auto
desc = «IPPON BACK Basic 650VA»
default.battery.voltage.high = 13.60
default.battery.voltage.low = 10.60
ignorelb
override.battery.charge.low = 40
override.battery.charge.warning = 45
upsd.conf
LISTEN 127.0.0.1 3493
upsd.users
[upsmon]
password = 12345
actions = SET FSD
instcmds = ALL
upsmon master
upsmon.conf
MONITOR ippon@localhost 1 upsmon 12345 master
upssched.conf
CMDSCRIPT /bin/upssched-cmd
2. перезагрузим nut и компьютер
service nut-server restart
service nut-client restart
3. пишем скрипт upscmd.sh который будет отключать звук после включения компьютера, добавить желательно скрипт в /etc/rc.local
upsc ippon@localhost
battery.charge: 100
battery.charge.low: 40
battery.charge.warning: 45
battery.voltage: 13.70
battery.voltage.high: 13.60
battery.voltage.low: 10.60
battery.voltage.nominal: 12.0
device.type: ups
driver.flag.ignorelb: enabled
driver.name: blazer_usb
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: .