QNAP威联通NAS连接UPS并配置断电网络广播,pve客户端使用NUT监听

我们要做到流程:

  1. QNAP 威联通 NAS 连接 UPS 并配置断电网络广播
  2. pve 或 pc 或 linux 客户端使用 NUT 监听 NAS 的断电消息

我们假设:

  • 你的威联通 NAS ip 为 192.168.124.100(作为 server)
  • 你的 PVE 或者 PC ip 为 192.168.124.160(作为 client)

PVE 配置 NUT 监听 NAS 断电消息

NAS 连接 UPS 并启用断电网络广播

查看威联通 NAS UPS SERVER 配置

通过 ssh 登录你的 NAS,查看 ups nut server 配置

1
cat /mnt/HDA_ROOT/.config/ups/upsd.users

威联通的配置都是固定的如下,账号 admin,密码 123456

1
2
3
4
5
6
[admin]
password = 123456
allowfrom = localhost
actions = SET
instcmds = ALL
upsmon master # or upsmon slave

在 PVE 配置 NUT client 监听

在你的 PVE shell 或 ssh 里操作

1
2
3
4
5
6
7
8
9
10
11
# 安装
apt install nut -y

# 创建开启自启配置
systemctl enable --now nut-client

# 修改nut.conf 启用网络客户端监听模式
echo "MODE=netclient" > /etc/nut/nut.conf

# 把威联通的ups nut server信息配置进来
vim /etc/nut/upsmon.conf

在文件底部添加代码:

1
MONITOR qnapups@192.168.124.100 1 admin 123456 slave
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 重启加载配置
systemctl restart nut-client.service

# 检查UPS状态
upsc qnapups@192.168.124.100

# 打印如下信息就是连接成功了。
root@pve:~# upsc qnapups@192.168.124.100
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10
battery.mfr.date: 2001/01/01
battery.runtime: 2200
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 13.6
battery.voltage.nominal: 12.0
device.mfr: American Power Conversion
device.model: Back-UPS BK650M2-CH

参考 https://github.com/Bpazy/blog/issues/206

PC windows 配置 NUT Client

记得在 NAS 里配置上你 windows 电脑的 ip。

参考 https://www.cnblogs.com/HeisenbergUncertainty/p/18065831

ttps://github.com/gawindx/WinNUT-Client