In this document, I will explain how to setup apcupsd
on Ubuntu 18.04 and 20.04.
I'll only document USB
connected UPS and not the other supported connection modes.
If you have followed my previous gist related to nut
, I'd serisouly recommend you to cleanup everything before continuing this gist.
# Remove the main 'nut' package
sudo apt remove --purge -y nut
# Mode to the generated 'nut' deb packages folder
cd ~/nut-274-debs/
# Create a loop that gather package basenames only and remove them
for D in *.*deb ; do sudo apt remove --purge -y $(echo $D | sed -e 's/_2.7.4-11ubuntu4_all.*deb//' | sed -e 's/_2.7.4-11ubuntu4_amd64.*deb//') ; done
# Remove any left dependent and now orphan packages
sudo apt autoremove --purge -y
sudo apt install apcupsd
If you have followed my previous gist related to nut
, you might have it already installed but if not, simply run this command to install netdata
:
bash <(curl -Ss https://my-netdata.io/kickstart.sh) all --dont-wait --disable-telemetry
I'd also recommend you to take the time to explore the PDF
manual that contains tons of useful information about how to implement and configure apcupsd.
You can find the HTML
manual here if you prefer.
It seems like almost everything has been already configured during the installation process of apcupsd
but if when running apcaccess
you get a similar status:
STATUS : COMMLOST
Then you might need to patch the /etc/apcupsd/apcupsd.conf
file that way:
# Remove the unnecessary assigned USB device port
sudo sed -e 's|DEVICE /dev/ttyS0|DEVICE|' -i /etc/apcupsd/apcupsd.conf
# Restart the service
sudo systemctl restart apcupsd.service ; systemctl status apcupsd.service -l
You should now get a similar output when running apcaccess
:
$ apcaccess
APC : 001,036,0880
DATE : 2021-07-03 19:40:00 +0200
HOSTNAME : [REDACTED]
VERSION : 3.14.14 (31 May 2016) debian
UPSNAME : [REDACTED]
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2021-07-03 18:34:46 +0200
MODEL : Back-UPS XS 1400U
STATUS : ONLINE
LINEV : 236.0 Volts
LOADPCT : 19.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 33.1 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 155.0 Volts
HITRANS : 280.0 Volts
ALARMDEL : 30 Seconds
BATTV : 27.2 Volts
LASTXFER : Unacceptable line voltage changes
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
SERIALNO : [REDACTED]
BATTDATE : 2020-09-17
NOMINV : 230 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 700 Watts
FIRMWARE : 926.T2 .I USB FW:T2
END APC : 2021-07-03 19:40:00 +0200
As you might have seen if you've following my previous gist related to nut
, the configuration for apcupsd
is much more simpler 😅
You can now configure Netdata and add the name of your UPS in the configuration file:
# Go to the netdata config folder
cd /etc/netdata
# Run the editing script
sudo ./edit-config charts.d/apcupsd.conf
You don't really need to change anything as normally the defaults are good enough to simply having to restart the service and nothing more:
sudo systemctl restart netdata ; systemctl status netdata -l
Now you can navigate to http://localhost:19999 and search for the UPS section on the right, you should see something like that:
- http://www.apcupsd.org/
- http://www.apcupsd.org/manual/manual.pdf
- https://linux.die.net/man/8/apcaccess
- https://linux.die.net/man/8/apcupsd
- https://linux.die.net/man/5/apcupsd.conf
- https://learn.netdata.cloud/docs/agent/collectors/charts.d.plugin/apcupsd
- https://gist.github.com/Jiab77/0778ef11a441f49df62e2b65f3daef76