crx349 发表于 2024-11-25 01:25:23

PVE 雷迪斯UPS断电自动关机

环境:
PVE8.2
LADIS雷迪司的UPS型号H1000M(理论上带usb接口的都可以实现)


开始:
1.Ups用usb连接线接入pve机器的usb接口


Cypress Semiconductor USB to Serial
这个是usb接口通了的提示
2.安装UNT
apt update
apt install nut nut-client nut-server nut-cgi

安装成功后 查看ups信息
nut-scanner -U



3.ups配置 nano /etc/nut/ups.conf

填入nut-scanner -U 获取到的信息


maxretry = 3

      driver = "nutdrv_qx"
      port = "auto"
      vendorid = "xxx"
      productid = "xxx"
      bus = "001"


4.配置监控设置 nano /etc/nut/upsmon.conf
文件最后面填入
RUN_AS_USER root
MONITOR nutdev1@localhost 1 monuser secret master

5.配置upsd nano /etc/nut/upsd.conf
修改监听端口,文件最后部加入
#listen all interface
LISTEN 0.0.0.0 3493

6.配置nut nano /etc/nut/nut.conf
修改MODE
MODE=netserver

7.配置nut用户名,用于其他客户端连接 nano /etc/nut/upsd.users

password = xmspace.net
upsmon master

8.重启服务
service nut-server restart
service nut-client restart
systemctl restart nut-monitor
upsdrvctl stop
upsdrvctl start

9.配置网页版监控界面 nano /etc/nut/hosts.conf
底部加入
MONITOR nutdev1@localhost "LADS H1000M 1000VA 600W UPS"

10.配置cgi安全
a2enmod cgi
systemctl restart apache2
nano /etc/nut/upsset.conf
最后面添加
I_HAVE_SECURED_MY_CGI_DIRECTORY

访问http://ip/cgi-bin/nut/upsstats.cgi 可查看ups状态


11.配置关机脚本 nano /etc/nut/upssched.conf

修改带有CMDSCRIPT 这句这行

CMDSCRIPT /etc/nut/upssched-cmd #编写此脚本设置
PIPEFN /etc/nut/upssched.pipe
LOCKFN /etc/nut/upssched.lock

AT ONBATT * START-TIMER power-off 60
AT ONLINE * CANCEL-TIMER power-off
AT ONLINE * EXECUTE power-on

说明:使用ups电源后60秒后关机

/etc/nut/upssched-cmd 内容如下
#!/bin/sh
case $1 in
       onbatt)
          logger -t upssched-cmd "UPS running on battery"
                  # do somethings ,e.g.send email \ wechat
          ;;
       earlyshutdown)
          logger -t upssched-cmd "UPS on battery too long, early shutdown"
          /usr/sbin/upsmon -c fsd
          ;;
       shutdowncritical)
          logger -t upssched-cmd "UPS on battery critical, forced shutdown"
          /usr/sbin/upsmon -c fsd
          ;;
       upsgone)
          logger -t upssched-cmd "UPS has been gone too long, can't reach"
          ;;
       *)
          logger -t upssched-cmd "Unrecognized command: $1"
          ;;
esac
12.再次重启服务生效

service nut-server restart
service nut-client restart
systemctl restart nut-monitor
upsdrvctl stop
upsdrvctl start
页: [1]
查看完整版本: PVE 雷迪斯UPS断电自动关机