Install the packages:
sudo apt update sudo apt install nut nut-client nut-server apache2 nut-cgi nut-snmp
Edit /etc/nut/ups.conf and add your UPS
sudo vi /etc/nut/ups.conf
Add the below stanza to the bottom:
[servers] driver = usbhid-ups port = auto desc = "BamBu Printers UPS"
Edit the bottom of the /etc/nut/upsmon.conf:
sudo vi /etc/nut/upsmon.conf
Add your line to the bottom:
# MONITOR <system> <powervalue> <user> <password> ("master"|"slave")
MONITOR servers@localhost 1 monuser secret master
Add the same user to /etc/nut/upsd.users
sudo vi /etc/nut/upsd.users
add the below to the bottom:
[monuser] password = secret upsmon master
Edit /etc/nut/nut.conf and change the last line:
sudo vi /etc/nut/nut.conf
Add the below to the end:
MODE=netserver
Test:
sudo reboot
Check:
upsc servers@localhost
Edit /etc/nut/hosts.conf to allow CGI scrips access to the monitor. Add one line to the bottom of the file:
sudo vi /etc/nut/hosts.conf MONITOR servers@localhost "Server UPS"
Enable CGI in apache and restart the web server:
sudo a2enmod cgi sudo systemctl restart apache2
Now, you just need to convince apache that you really, really want to turn on CGI by uncommenting the following in /etc/nut/upsset.conf:
sudo vi /etc/nut/upsset.conf ### I_HAVE_SECURED_MY_CGI_DIRECTORY
Try it:
http://printmon.hohenfels.mylocal/cgi-bin/nut/upsset.cgi
http://printmon.hohenfels.mylocal/cgi-bin/nut/upsstats.cgi
REF:
https://www.howtoraspberry.com/2020/11/how-to-monitor-ups-with-raspberry-pi/
https://rymnd.net/blog/2018/ups-monitoring/