(→Example ups.conf) |
(→Example upsd.users) |
||
Line 68: | Line 68: | ||
instcmds = ALL | instcmds = ALL | ||
upsmon master | upsmon master | ||
− | [upsmon_remote] | + | [upsmon_remote] |
password = <SLAVE_PASSWORD_HERE> | password = <SLAVE_PASSWORD_HERE> | ||
upsmon slave | upsmon slave | ||
− | |||
=== upsmon.conf === | === upsmon.conf === |
Latest revision as of 10:50, 19 October 2023
Contents
Overview
NUT is an OpenSource tool that can monitor an extensive list of UPS devices. Often times UPS manufactures charge an extremely high cost for their network monitoring / SNMP cards. NUT running on a Raspberry Pi or other inexpensive SBC can be a cost effective way to monitor an UPS and performed network wide graceful shutdown in the event of a power failure.
Prerequisites
- Raspberry Pi or other SBC running a Debian based distro
- NUT Compatible UPS (see: NUT-HCL)
- USB (or Serial to USB) connection to the Raspberry Pi
- Network Connectivity (Wired or Wireless depending on RPi Model).
Installation
Update the software package list
sudo apt update sudo apt upgrade
Install NUT
sudo apt install nut
Server Configuration
Configuration Files
NUT is broken into two services: nut-server and nut-monitor. The configuration files for these services are located here:
/etc/nut/
ups.conf
This is the configuration file for the UPS hardware. Here is where you specify the Driver, Make, and Model of the UPS.
Obtaining the VendorID and ProductID
You will need this information before editing ups.conf.
lsusb Bus 001 Device 004: ID 0764:0601 Cyber Power System, Inc. PR1500LCDRT2U UPS
In this case the ID field is 0764:0601 and this translates to <VendorID>:<ProductID>.
Example ups.conf
[ups1] driver = usbhid-ups port = auto vendor = "CyberPowerPC PR1500LCDRT2U" vendorid = 0764 productid = 0601 pollinterval = 1 bus = "001"
upsd.conf
This file tells the UPS service what IP & Port to listen on.
Example upsd.conf
LISTEN 127.0.0.1 3493 # Listen on localhost LISTEN 192.168.69.69 3493 # Listen on the LAN
upsd.users
This file contains the list of users that can access NUT services.
Security
Its important to note that this file contains clear text passwords! So you should take steps to restrict read access to this file. For example, set it to only be readable by the root user.
chown root.root /etc/nut/upsd.users chmod 600 /etc/nut/upsd.users
Example upsd.users
[upsmon_master] password = <MASTER_PASSWORD_HERE> actions = SET instcmds = ALL upsmon master [upsmon_remote] password = <SLAVE_PASSWORD_HERE> upsmon slave
upsmon.conf
This file tells the nut-monitor which users can access the monitoring service. It essentially maps the user you created in the previous step to an Access Control List which tells the monitoring service which users can connect from which hosts on your network.
Security
Its important to note that this file contains clear text passwords! So you should take steps to restrict read access to this file. For example, set it to only be readable by the root user.
chown root.root /etc/nut/upsmon.conf chmod 600 /etc/nut/upsmon.conf
Example upsmon.conf
MONITOR ups1@localhost 1 upsmon_master <MASTER_PASSWORD_HERE> master
Note: You'll likely have more than one line if you have remote clients connecting to this NUT server (which is really the whole point).
nut.conf
This file defines the type of role this installation of NUT will be performing.
Example nut.conf
MODE=netserver
Client Configuration
Other
[NUT Client for ESXi]
References
https://www.networkshinobi.com/raspberry-pi-as-ups-server-via-the-nut/
https://haefelfinger.org/posts/2019/2019-11-20-using-network-ups-tools-and-mosquitto-part1/