找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 5102|回复: 74

[虚拟机相关] pve下连接山特UPS,作为NUT服务给威联通NAS并关机

  [复制链接]
使用环境 软路由主机PVE7.4+威联通NAS物理主机+山特TGBOX 850 UPS



1、首先执行lsusb 看到下面的信息,代表已经正确识别usb的ups


  1. root@pve:~# lsusb
  2. Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
  3. Bus 001 Device 003: ID 0529:0003 Aladdin Knowledge Systems Sentinel HL
  4. Bus 001 Device 002: ID 0463:ffff MGE UPS Systems UPS
  5. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
复制代码
已经正确识别UPS了

2、安装nut软件

  1. apt-get install nut nut-server nut-client nut-cgi
复制代码
3、看下ups的信息

  1. nut-scanner
复制代码
显示如下

  1. No start IP, skipping SNMP
  2. No start IP, skipping NUT bus (old connect method)
  3. [nutdev1]
  4.         driver = "usbhid-ups"
  5.         port = "auto"
  6.         vendorid = "0463"
  7.         productid = "FFFF"
  8.         product = "SANTAK TG-BOX"
  9.         serial = "Blank"
  10.         vendor = "EATON"
  11.         bus = "001"
复制代码
4、复制全部内容后,添加到/etc/nut/ups.conf

  1. nano /etc/nut/ups.conf
复制代码
添加查看到的UPS信息
  1. [qnapups]   --我这为了威联通使用,所以将名字改成威联通能识别的,如果群晖要根据实际情况改名字
  2.         driver = "usbhid-ups"
  3.         port = "auto"
  4.         vendorid = "0463"
  5.         productid = "FFFF"
  6.         product = "SANTAK TG-BOX"
  7.         serial = "Blank"
  8.         vendor = "EATON"
  9.         bus = "001"
复制代码
5、修改NUT运行模式

  1. nano /etc/nut/nut.conf
复制代码
6、修改监听配置

  1. nano /etc/nut/upsd.conf
  2. ;文件最后一行加入
  3. LISTEN 0.0.0.0 3493    --允许整个网络
复制代码
7、设置客户端连接密码

  1. nano /etc/nut/upds.users
  2. ;文件最后一行加入
  3. [nutuser]
  4. password = nutpasswd
  5. upsmon maste
复制代码
8、配置CGI服务

  1. nano /etc/nut/hosts.conf
  2. ;文件最后一行加入
  3. MONITOR qnapups[url=home.php?mod=space&uid=467693]@Localhost[/url] 1 nutuser nutpasswd master    --注意UPS的名字要与ups.conf一致
复制代码
9、设置CGI目录安全性

  1. nano /etc/nut/upsset.conf
  2. 文件最后一行加入
  3. I_HAVE_SECURED_MY_CGI_DIRECTORY
复制代码
10、重启下nut相关服务

  1. systemctl restart nut-server.service
  2. systemctl restart nut-driver.service
  3. systemctl restart nut-monitor.service
  4. 查看下运行状态
  5. lsof -i:3493
复制代码

11、配置CGI服务(以支持WEB查看)

  1. nano /etc/apache2/apache2.conf
复制代码
文件最后一行加入

  1. Alias /nut /usr/share/nut/www
  2. <Directory /usr/share/nut/www>
  3.         Options +SymLinksIfOwnerMatch
  4.         AllowOverride All
  5.         Require all granted
  6. </Directory>
复制代码
  1. nano /etc/apache2/conf-available/serve-cgi-bin.conf
复制代码
文件最后一行加入

  1. <IfDefine ENABLE_USR_LIB_CGI_BIN>
  2.                 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  3.                 <Directory "/usr/lib/cgi-bin">
  4.                 AllowOverride None
  5.                                 AddHandler cgi-script .cgi
  6.                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  7.                 Require all granted
  8.                 </Directory>
  9.         </IfDefine>
  10. ScriptAlias /cgi-bin/ /var/www/cgi-bin/
  11.         <Directory "/var/www/cgi-bin">
  12.             Options +Indexes +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  13.             #Require all granted
  14.             Order allow,deny
  15.             Allow from all
  16.             AddHandler cgi-script .py .cgi
  17.             AddHandler default-handler .html .htm
  18. </Directory>
复制代码


重启服务

  1. systemctl  restart apache2
复制代码
之后打开http://ip/nut  就可以看到UPS的状态了



12、配置自动关机

  1. nano /etc/nut/upssched.conf
复制代码
文件最后一行加入

  1. CMDSCRIPT /etc/nut/upssched-cmd
  2. PIPEFN /etc/nut/upssched.pipe
  3. LOCKFN /etc/nut/upssched.lock
  4. AT ONBATT * START-TIMER power-off 40
  5. AT ONLINE * CANCEL-TIMER power-off
  6. AT ONLINE * EXECUTE power-on
复制代码
新建/etc/nut/upssched-cmd文件

  1. nano /etc/nut/upssched-cmd
复制代码
复制添加下面代码
  1. #!/bin/sh
  2. case $1 in
  3.        onbatt)
  4.           logger -t upssched-cmd "UPS running on battery"
  5.                   # do somethings ,e.g.send email \ wechat
  6.           ;;
  7.        earlyshutdown)
  8.           logger -t upssched-cmd "UPS on battery too long, early shutdown"
  9.           /usr/sbin/upsmon -c fsd
  10.           ;;
  11.        shutdowncritical)
  12.           logger -t upssched-cmd "UPS on battery critical, forced shutdown"
  13.           /usr/sbin/upsmon -c fsd
  14.           ;;
  15.        upsgone)
  16.           logger -t upssched-cmd "UPS has been gone too long, can't reach"
  17.           ;;
  18.        *)
  19.           logger -t upssched-cmd "Unrecognized command: $1"
  20.           ;;
  21. esac
复制代码
增加可执行权限

  1. chmod +x /etc/nut/upssched-cmd
复制代码
重启服务,之后就ok了, 威联通NAS添加网络UPS

  1. systemctl restart nut-server.service
  2. systemctl restart nut-driver.service
  3. systemctl restart nut-monitor.service
  4. systemctl  restart apache2
复制代码




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
 楼主| | 显示全部楼层
还可以通过NUT设置email通知之类的,等空了研究研究断电后推送消息
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

感谢分享 很有用
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

感谢分享,试试看
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

APC可以用吗
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
谢谢楼主分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

Not Found
The requested URL was not found on this server.

Apache/2.4.57 (Debian) Server at 192.168.1.3 Port 80

最后网页打不开

点评

执行下  详情 回复 发表于 2023-11-11 18:19
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习侠正需要这个,以前老配置不成功

我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

正好学习一下,以前一直没弄好
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
tianrenhyb 发表于 2023-11-6 18:33
Not Found
The requested URL was not found on this server.

执行下  
  1. a2enmod cgi
复制代码
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

感谢大佬的分享,收藏一下,以备后用
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

好文章-感谢分享-如果给群晖用貌似应给就改下群晖默认的信息就可以了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

谢谢分享!!!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 11:40

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表