How to Monitor TWO UPSes with nut on a Raspberry Pi
So, how do you differentiate between two of the same model UPSs on the same Raspberry PI running NUT? On a real computer, you could assign names to the ports. Maybe you have two different models and you could use model= or vendor= in ups.conf. Not me! I had to have two matching UPS!
After hours of googling, I found that I could use pattern matching to match the slightly different spellings of the UPSes. First, I grepped through dmesg for “Product” and found my two targets:
dmesg | grep Product ---snip--- [ 3.937630] usb 1-1.2: Product: CP 1350C [ 4.468107] usb 1-1.3: New USB device found, idVendor=0781, idProduct=5571, bcdDevice= 1.00 [ 4.474042] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 4.477116] usb 1-1.3: Product: Cruzer Fit [ 4.733343] usb 1-1.4: New USB device found, idVendor=0764, idProduct=0501, bcdDevice= 2.00 [ 4.733365] usb 1-1.4: New USB device strings: Mfr=3, Product=1, SerialNumber=2 [ 4.733378] usb 1-1.4: Product: CP1350AVRLCDa ---snip---
Then, I could define my two UPSes with a regex in /etc/nut/ups.conf:
[ups] driver = usbhid-ups port = auto product = ".*50C.*" [ups2] driver = usbhid-ups port = auto product = ".*50A.*"
Restart, and VOILA:
Can’t send commands to the UPS
Next on my issue list, upsset won’t work! Everything I try to send to the UPS, I get:
Response: ERR ACCESS-DENIED ~or~ Unexpected response from upsd: ERR ACCESS-DENIED
WELL, turns out, you can’t use the upsmon account to send commands. It’s strictly a monitoring account! Create a second account in /etc/nut/upsd.users, called root or whatever you like, and add the allowed commands to that! Here’s mine:
[monuser] password = secret upsmon master [root] password = reallysecret instcmds = ALL actions = SET actions = FSD
Now, I can log in to the CGI page with “root” or specify -u root on the command line to tinker with my UPS all day! Next on my list: setting up NUT slaves, that is, the servers that will go offline when the lights go out!