NUT

Installation of Network UPS Tools to shutdown servers when there is a power outage.

Server Installation

Notes:

Installation of NUT can be done with

sudo apt-get update 
sudo apt-get install nut nut-server nut-client

The UPS should be connected to the Raspberry Pi via USB, you can verify the connection by running the command below and checking with the example output.

lsusb
Bus 001 Device 018: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 004: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Run a NUT command to scan and output the connected UPS information

sudo nut-scanner -U

Example output:

Neon library not found. XML search disabled.
IPMI library not found. IPMI search disabled.
Scanning USB bus.
[nutdev1]
        driver = "usbhid-ups"
        port = "auto"
        vendorid = "051D"
        productid = "0002"
        product = "Back-UPS RS 1300G FW:863.L3 .D USB FW:L3"
        serial = "XXXXXXXXXXXX"
        vendor = "American Power Conversion"
        bus = "001"
[nutdev2]
        driver = "usbhid-ups"
        port = "auto"
        vendorid = "051D"
        productid = "0002"
        product = "Back-UPS RS1000G FW:868.L3 -P.D USB FW:L3 -P"
        serial = "XXXXXXXXXXXX"
        vendor = "American Power Conversion"
        bus = "001"

Copy the output and edit /etc/nut/ups.conf with the following template.

pollinterval = 15
maxretry = 3

[RS1000G]
        driver = usbhid-ups
        port = auto
        vendorid = "051D"
        productid = "0002"
        serial = "XXXXXXXXXXXX"
[RS1300G]
        driver = usbhid-ups
        port = auto
        vendorid = "051D"
        productid = "0002"
        serial = "XXXXXXXXXXXX"

Edit /etc/nut/upsmon.conf to set the credentials for the UPS monitors

RUN_AS_USER root

MONITOR RS1000G@localhost 1 admin megasecurepassword master
MONITOR RS1300G@localhost 1 admin megasecurepassword master

Edit /etc/nut/upsd.conf to change the listening interface and port

LISTEN 0.0.0.0 3493
DEADTIME 25

Edit /etc/nut/nut.conf to set the NUT instance to server

MODE=netserver

Edit /etc/nut/upsd.users to set the user permissions

[monuser]
        password = megasecurepassword
        admin master

Restart all the NUT services

sudo service nut-server restart
sudo service nut-client restart
sudo systemctl restart nut-monitor
sudo upsdrvctl stop
sudo upsdrvctl start

 

Client Installation

Connecting clients such as my PfSense box, Proxmox host, and TrueNAS boxes.

 

PfSense:

Under System -> Package Manager -> Available Packages, search for NUT and install the package.

image.png

Under Services -> UPS -> Settings, Fill in the user credentials from the server install.

image.png