UPSいれました。

長年UPSの導入に踏み切れていなかったのですが、この度導入しました。
大体発生する停電はそこまで長くないので、容量の小さいものを選択。

購入したのはAPCのUPS、 BR550S。
ざっくり計算でも今の拙宅の鯖周りの電気使用量から見ても、これで十分だと考えての購入。

で、せっかくなら充電量が低下してきたら、家鯖をシャットダウンする仕組みも組みたいと思い、調べたら、apcupsdというパッケージで、情報が取れるらしいことまでわかったのですが、制御するためのPCを新たに組むのも電気代の面でもあまりしたくない…

で、思い出したのが遊休機になっているRaspberryPi 3B+。
これならば電気消費量も小さく済むし、取り回しも楽。

ということでさっそく導入と初期設定までを実施。

~# apt-get install apcupsd
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
以下のパッケージが自動でインストールされましたが、もう必要とされていません:
libcamera0.3
これを削除するには 'apt autoremove' を利用してください。
以下の追加パッケージがインストールされます:
apcupsd-doc libusb-0.1-4 s-nail
提案パッケージ:
apcupsd-cgi default-mta | mail-transport-agent
以下のパッケージが新たにインストールされます:
apcupsd apcupsd-doc libusb-0.1-4 s-nail
アップグレード: 0 個、新規インストール: 4 個、削除: 0 個、保留: 0 個。
1,170 kB のアーカイブを取得する必要があります。
この操作後に追加で 2,970 kB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://deb.debian.org/debian bookworm/main arm64 libusb-0.1-4 arm64 2:0.1.12-32 [21.5 kB]
取得:2 http://deb.debian.org/debian bookworm/main arm64 apcupsd arm64 3.14.14-3.1+b1 [249 kB]
取得:3 http://deb.debian.org/debian bookworm/main arm64 apcupsd-doc all 3.14.14-3.1 [390 kB]
取得:4 http://deb.debian.org/debian bookworm/main arm64 s-nail arm64 14.9.24-2 [509 kB]
1,170 kB を 1秒 で取得しました (1,744 kB/s)
パッケージを事前設定しています ...
以前に未選択のパッケージ libusb-0.1-4:arm64 を選択しています。
(データベースを読み込んでいます ... 現在 81316 個のファイルとディレクトリがインストールされています。)
.../libusb-0.1-4_2%3a0.1.12-32_arm64.deb を展開する準備をしています ...
libusb-0.1-4:arm64 (2:0.1.12-32) を展開しています...
以前に未選択のパッケージ apcupsd を選択しています。
.../apcupsd_3.14.14-3.1+b1_arm64.deb を展開する準備をしています ...
apcupsd (3.14.14-3.1+b1) を展開しています...
以前に未選択のパッケージ apcupsd-doc を選択しています。
.../apcupsd-doc_3.14.14-3.1_all.deb を展開する準備をしています ...
apcupsd-doc (3.14.14-3.1) を展開しています...
以前に未選択のパッケージ s-nail を選択しています。
.../s-nail_14.9.24-2_arm64.deb を展開する準備をしています ...
s-nail (14.9.24-2) を展開しています...
s-nail (14.9.24-2) を設定しています ...
libusb-0.1-4:arm64 (2:0.1.12-32) を設定しています ...
apcupsd-doc (3.14.14-3.1) を設定しています ...
apcupsd (3.14.14-3.1+b1) を設定しています ...
Created symlink /etc/systemd/system/multi-user.target.wants/apcupsd.service → /lib/systemd/system/apcupsd.service.
man-db (2.11.2-2) のトリガを処理しています ...
libc-bin (2.36-9+rpt2+deb12u9) のトリガを処理しています ...

Broadcast message from root@zepar (somewhere) (Fri May 8 01:16:06 2026):

Warning communications lost with UPS

とりあえずパッケージ導入はエラーなし。
ただ初期値の設定だとUPSの情報が参照できていない模様。
/etc/apcupsd/apcupsd.confのDEVICE設定に設定をしてみてからapcupsdを再起動。


~# cd /etc/apcupsd
/etc/apcupsd# dmesg |grep tty
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835.enable_headphones=0 cgroup_disable=memory snd_bcm2835.enable_headphones=1 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_hdmi=0 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=ttyS0,115200 console=tty1 root=PARTUUID=6d534ed6-02 rootfstype=ext4 fsck.repair=yes rootwait cfg80211.ieee80211_regdom=JP
[ 0.000259] printk: console [tty1] enabled
[ 1.961692] 3f201000.serial: ttyAMA1 at MMIO 0x3f201000 (irq = 99, base_baud = 0) is a PL011 rev2
[ 1.964409] serial serial0: tty port ttyAMA1 registered
[ 7.494566] systemd[1]: Created slice system-getty.slice - Slice /system/getty.
/etc/apcupsd# cp -p apcupsd.conf{,.org}
/etc/apcupsd# vi ./apcupsd.conf
/etc/apcupsd# diff /etc/apcupsd/apcupsd.conf{.org,}
90c90,91
< DEVICE /dev/ttyS0
---
> DEVICE /dev/ttyAMA1
> #DEVICE /dev/ttyS0

/etc/apcupsd# systemctl restart apcupsd
/etc/apcupsd# apcaccess
APC : 001,017,0420
DATE : 2026-05-08 01:20:57 +0900
HOSTNAME : hogehoge
VERSION : 3.14.14 (31 May 2016) debian
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2026-05-08 01:20:14 +0900
STATUS : COMMLOST
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000100
END APC : 2026-05-08 01:20:57 +0900

Broadcast message from root@zepar (somewhere) (Fri May 8 01:21:24 2026):

Warning communications lost with UPS

認識しない。
dmesgコマンドで見れてるのと、実際のデバイスのパスが違っているのではないかと思い、/dev以下を確認。

~ # ls /dev/
Display all 192 possibilities? (y or n)
autofs           null             tty26            urandom
block/           port             tty27            usb/
btrfs-control    ppp              tty28            v4l/
bus/             ptmx             tty29            vc-mem
cachefiles       pts/             tty3             vchiq
cec0             ram0             tty30            vcio
char/            ram1             tty31            vcs
console          ram10            tty32            vcs1
cpu_dma_latency  ram11            tty33            vcs2
cuse             ram12            tty34            vcs3
disk/            ram13            tty35            vcs4
dma_heap/        ram14            tty36            vcs5
dri/             ram15            tty37            vcs6
fb0              ram2             tty38            vcsa
fd/              ram3             tty39            vcsa1
full             ram4             tty4             vcsa2
fuse             ram5             tty40            vcsa3
gpiochip0        ram6             tty41            vcsa4
gpiochip1        ram7             tty42            vcsa5
gpiochip2        ram8             tty43            vcsa6
gpiochip4        ram9             tty44            vcsm-cma
gpiomem          random           tty45            vcsu
hidraw0          rfkill           tty46            vcsu1
hwrng            shm/             tty47            vcsu2
initctl          snd/             tty48            vcsu3
input/           stderr           tty49            vcsu4
kmsg             stdin            tty5             vcsu5
kvm              stdout           tty50            vcsu6
log              tty              tty51            vga_arbiter
loop-control     tty0             tty52            vhci
loop0            tty1             tty53            vhost-net
loop1            tty10            tty54            vhost-vsock
loop2            tty11            tty55            video10
loop3            tty12            tty56            video11
loop4            tty13            tty57            video12
loop5            tty14            tty58            video13
loop6            tty15            tty59            video14
loop7            tty16            tty6             video15
mapper/          tty17            tty60            video16
media0           tty18            tty61            video18
media1           tty19            tty62            video20
media2           tty2             tty63            video21
mem              tty20            tty7             video22
mmcblk0          tty21            tty8             video23
mmcblk0p1        tty22            tty9             video31
mmcblk0p2        tty23            ttyprintk        watchdog
mqueue/          tty24            uhid             watchdog0
net/             tty25            uinput           zero
kusanagi@zepar:~ # ls /dev/usb/
hiddev0
kusanagi@zepar:~ #

/devにはそれらしきドライバもなかったのですが、/dev/usb以下にデバイスがあったので、改めてこれを設定。

/etc/apcupsd# vi ./apcupsd.conf
/etc/apcupsd# diff /etc/apcupsd/apcupsd.conf{.org,}
90c90,91
< DEVICE /dev/ttyS0
---
> DEVICE /dev/usb/hiddev0
> #DEVICE /dev/ttyS0

/etc/apcupsd# systemctl restart apcupsd
/etc/apcupsd# apcaccess
APC : 001,036,0856
DATE : 2026-05-08 01:26:32 +0900
HOSTNAME : hogehoge
VERSION : 3.14.14 (31 May 2016) debian
UPSNAME : zepar
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2026-05-08 01:26:28 +0900
MODEL : APC RS 550S
STATUS : ONLINE
LINEV : 101.0 Volts
LOADPCT : 64.0 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 6.9 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 82.0 Volts
HITRANS : 123.0 Volts
ALARMDEL : 30 Seconds
BATTV : 13.7 Volts
LASTXFER : No transfers since turnon
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x05000008
SERIALNO : 5B2542T11565
BATTDATE : 2025-10-13
NOMINV : 100 Volts
NOMBATTV : 12.0 Volts
NOMPOWER : 330 Watts
FIRMWARE : 941.c6 .A USB FW:c6
END APC : 2026-05-08 01:26:33 +0900
root@zepar:/etc/apcupsd#

お、認識した。
あとはこれを各家鯖からアクセスできるようにすればいろいろできそう。
追々対応しますか。