无限星辰工作室-精品资源-知识付费
标题:
PVE 雷迪斯UPS断电自动关机
[打印本页]
作者:
crx349
时间:
2024-11-25 01:25
标题:
PVE 雷迪斯UPS断电自动关机
环境:
PVE8.2
LADIS雷迪司的UPS型号H1000M(理论上带usb接口的都可以实现)
开始:
1.Ups用usb连接线接入pve机器的usb接口
(, 下载次数: 2)
上传
点击文件名下载附件
Cypress Semiconductor USB to Serial
这个是usb接口通了的提示
2.安装UNT
apt update
apt install nut nut-client nut-server nut-cgi
复制代码
安装成功后 查看ups信息
nut-scanner -U
复制代码
(, 下载次数: 4)
上传
点击文件名下载附件
3.ups配置
nano /etc/nut/ups.conf
复制代码
填入nut-scanner -U 获取到的信息
maxretry = 3
[nutdev1]
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
复制代码
[monuser]
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状态
(, 下载次数: 4)
上传
点击文件名下载附件
(, 下载次数: 3)
上传
点击文件名下载附件
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
复制代码
欢迎光临 无限星辰工作室-精品资源-知识付费 (https://paid.xmwxxc.com/)
Powered by Discuz! X3.4