...
For this setup, we will be setting up our UPS master on a raspberry pi with slaves setup on a QNAP NAS and a Ubuntu Server.
Master Setup on Raspberry Pi
...
Code Block |
---|
RUN_AS_USER root
MONITOR qnapups@192.168.1.52 1 deepthought 123456 slave
NOTIFYCMD /usr/sbin/upssched
NOTIFYFLAG ONLINE WALL+EXEC
NOTIFYFLAG ONBATT WALL+EXEC |
On our master we created a slave user called deepthought.
...
Code Block |
---|
$ sudo vi /etc/nut/upssched.conf |
Ensure that the CMDSCRIPT is setSet the following
Code Block |
---|
CMDSCRIPT /etc/binnut/upssched-cmd |
Add the following
Code Block |
---|
# Timer to shutdown machine after 60 PIPEFN /var/run/nut/upssched.pipe LOCKFN /var/run/nut/upssched.lock # Timer to shutdown machine after 30 seconds AT ONBATT * START-TIMER onbattwarn 6030 AT ONLINE * CANCEL-TIMER onbattwarn |
Edit Create the Command Script
Code Block |
---|
$ sudo vi /binetc/nut/upssched-cmd |
Add the following content
Code Block |
---|
case $1 in onbattwarn) logger -t upssched-cmd "Timer On Battery Warning has been triggered - Shutting Down!" wall "ShuttingUPS down NOW!" timer expired: shutting down..." shutdown -h now ;; *) logger -t upssched-cmd "Unrecognized command: $1" ;; esac |
...
Code Block |
---|
$ upsc qnapups@192.168.1.52 |
Installing NUT on Mac
Code Block |
---|
> brew install nut
==> Downloading https://ghcr.io/v2/homebrew/core/nut/manifests/2.8.1
######################################################################### 100.0%
==> Fetching nut
==> Downloading https://ghcr.io/v2/homebrew/core/nut/blobs/sha256:e89241f392bb9f
######################################################################### 100.0%
==> Pouring nut--2.8.1.arm64_sonoma.bottle.tar.gz
Warning: The post-install step did not complete successfully
You can try again using:
brew postinstall nut
==> Caveats
To start nut now and restart at login:
brew services start nut
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/nut/sbin/upsmon -D
==> Summary
🍺 /opt/homebrew/Cellar/nut/2.8.1: 94 files, 12MB
==> Running `brew cleanup nut`...
|
Didn't work.....
Troubleshooting
Problem | Details |
---|---|
UPS Shutting Down | Sometimes the UPS shutdown for no reason. No power outage. cat /var/log/syslog |grep ups Mar 16 02:09:28 pihole upsmon[390]: UPS qnapups@localhost on battery Unplugging the power and querying the UPS showed a charge of 0! > upsc qnapups@localhost |grep battery
|
Get NUT status | sudo service nut-server status Mar 16 03:10:11 pihole upsd[374]: fopen /var/run/nut/upsd.pid: No such file or directory
|
Querying UPS | upsc qnapups@localhost
$ upsc qnapups@192.168.1.52
battery.charge: 100
battery.charge.low: 10
...
ups.vendorid: 051d |
References
Reference | URL |
---|---|
Network UPS Tools User Manual | https://networkupstools.org/docs/user-manual.chunked/index.html |
Configuration | https://networkupstools.org/docs/user-manual.chunked/ar01s06.html |
UPSMON Man Page | https://networkupstools.org/docs/man/upsmon.conf.html |
NUT Introduction to Network UPS Tools - Configuration Examples | http://rogerprice.org/NUT/ConfigExamples.A5.pdf |
Raspberry Pi Home Server v2: Network UPS Tools | https://melgrubb.com/2016/12/11/rphs-v2-ups/ |
...