📜 ⬆️ ⬇️

Initial setup of an APC UPS in Linux from a teapot point of view

Having bought an uninterruptible power supply from APC (namely, APC Back-UPS ES 550VA), I was surprised to find that “out of the box” it cannot boast a close friendship with Linux. Of course, XFCE Power Manager, part of XFCE 4.6, picked up and recognized the UPS, but all he was capable of was displaying the charge level in the tray. Any settings were missing completely, it was impossible even to set the PC to turn off when a certain charge level was reached.

Turning to Google for advice, I learned about the existence of the wonderful demon apcupsd, whose role is to - never believe - the management of the UPS from APC. But, as it turned out, almost all the guides on its initial configuration were frankly outdated - including, oddly enough, the official manual. Stumbling had already at the very beginning about "cat / proc / bus / usb / devices". After talking to Google in a serious and trusting tone, I got him to link to the current manual , whose artistic translation with additions from other sources is this article.

So let's start by installing apcupsd itself:

sudo apt-get install apcupsd

Of course, this is true for Debian and its derivatives, including Ubuntu. If apt-get is not used in your distribution, I think you still know how to install the necessary package. Hope so.
')
Now we edit the apcupsd configuration file:

sudo gedit /etc/apcupsd/apcupsd.conf

In this case, we are interested in only three parameters:

UPSCABLE - we indicate the type of cable that our UPS is connected to the PC. The comments indicate the possible types - simple, smart, ether, usb. The current home models are connected via USB - therefore, it suffices to add usb
UPSTYPE is a type of UPS connected. The comments list the possible types and the corresponding values ​​of the DEVICE parameter, our choice is the usb type.
DEVICE - we will comment out this line by placing a # sign in front of it - it is not needed for USB devices

Save the modified configuration file, open the following:

sudo gedit /etc/default/apcupsd

Replace ISCONFIGURED = no with ISCONFIGURED = yes, save, close. From now on, apcupsd will know that we have not forgotten to configure it.

Now it’s enough to run apcupsd:
sudo /etc/init.d/apcupsd start

If it has already been launched - instead of start, of course, we will need to write restart.

Everything, your PC is now connected with the new UPS with strong ties of friendship.

And now a little about what we can configure in extensive /etc/apcupsd/apcupsd.conf:

ONBATTERYDELAY - the time (in seconds) that determines the delay between the detection of a power failure and the sending of an onbattery event. Default is 6
BATTERYLEVEL - the battery charge level (in percent) at which the computer is turned off. Default is 5
MINUTES - the estimated time of residual work (in minutes), at which time the computer is turned off. Default is 3
TIMEOUT - the parameter is relevant for old UPS, unable to determine its level of charge. Sets the time (in seconds) between power failure and computer shutdown. For a modern UPS, the parameter should be left at 0, but setting a different value may be convenient for testing the operation of the UPS. For example, if you put 30 and pull the cord out of the socket, in half a minute apcupsd will demonstrate his ability to turn off the computer

One of the conditions (BATTERYLEVEL, MINUTES or TIMEOUT) is sufficient to turn off the computer. A finer setting is not described, because its need for a home user is highly questionable.

For a long time, a fairy tale affects, but it’s not a long deal: I suppose the user will perform the described actions in a couple of minutes. I hope this article will help someone to make friends with its APC UPS with Linux, saving time and not getting stuck in outdated manuals.

Source: https://habr.com/ru/post/132099/


All Articles