OPNsense Forum

English Forums => General Discussion => Topic started by: FullyBorked on March 21, 2021, 07:19:44 pm

Title: Help getting NUT working with CyberPower UPS
Post by: FullyBorked on March 21, 2021, 07:19:44 pm
Finally decided to connect my ups to my firewall via USB and setup NUT to gracefully shut it down during power outages.  Seemed pretty simple using the documentation here https://docs.opnsense.org/manual/how-tos/nut.html, but my diagnostics tab stays blank like it's not connected.  I verified that my ups is supported using the USBHID driver https://networkupstools.org/ddl/Cyber_Power_Systems/CP1500AVRLCD.html, so I'm thinking I'm just missing some simple something. 

Edit: Just noticed the Nut Daemon isn't running and won't start for some reason.

Anyone have any pointers and/or any shell commands I can run to help troubleshoot the issue?

Thanks 8)
Title: Re: Help getting NUT working with CyberPower UPS
Post by: Patrick M. Hausen on March 21, 2021, 07:24:42 pm
NUT and the USB HID driver are broken on FreeBSD because they are using an unsupported legacy API. According to information I got on their mailing list they have implemented the new API, but since they have not tagged a release since 2016, that code has not made it into any FreeBSD package, yet.

Your best bet (IMHO) is to get a network card for your UPS if available and use SNMP.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: FullyBorked on March 21, 2021, 07:32:40 pm
NUT and the USB HID driver are broken on FreeBSD because they are using an unsupported legacy API. According to information I got on their mailing list they have implemented the new API, but since they have not tagged a release since 2016, that code has not made it into any FreeBSD package, yet.

Your best bet (IMHO) is to get a network card for your UPS if available and use SNMP.

Dang, unfortunately my ups is USB only, surprised that's been broken so long.   
Title: Re: Help getting NUT working with CyberPower UPS
Post by: IsaacFL on March 21, 2021, 08:30:28 pm
Did you reboot the opnsense?  It seems to have to do a reboot with the UPS plugged in to detect it.  Then it is using the USBHID as UPS type.

It works for me on my CyberPower CST135XLU which is about 3 years old, so don't know why it wouldn't work for you.  The key is even on pfsense it requires a reboot.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: IsaacFL on March 21, 2021, 08:45:44 pm
Also, when you go to Nut/Diagnostics, it doesn't show the status until you click on the UPS status Button.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: FullyBorked on March 21, 2021, 09:00:24 pm
Did you reboot the opnsense?  It seems to have to do a reboot with the UPS plugged in to detect it.  Then it is using the USBHID as UPS type.

It works for me on my CyberPower CST135XLU which is about 3 years old, so don't know why it wouldn't work for you.  The key is even on pfsense it requires a reboot.
I did reboot.  I'm getting errors in the system log as well.  When I get back home I'll post up my syslog errors.

Sent from my IN2025 using Tapatalk

Title: Re: Help getting NUT working with CyberPower UPS
Post by: tswalker on March 21, 2021, 10:06:20 pm
Did you reboot the opnsense?  It seems to have to do a reboot with the UPS plugged in to detect it.  Then it is using the USBHID as UPS type.

It works for me on my CyberPower CST135XLU which is about 3 years old, so don't know why it wouldn't work for you.  The key is even on pfsense it requires a reboot.
I did reboot.  I'm getting errors in the system log as well.  When I get back home I'll post up my syslog errors.

Sent from my IN2025 using Tapatalk

I have a couple at this at home i use and could not get it working with opnsense, if you figure this out i would be very interested in how.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: Patrick M. Hausen on March 21, 2021, 11:24:08 pm
Dang, unfortunately my ups is USB only, surprised that's been broken so long.
The current version on github seems to work fine, but without a release since 2016 it's almost impossible to update the FreeBSD package.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: FullyBorked on March 22, 2021, 02:44:49 am
Here are my current error logs.

Code: [Select]
2021-03-21T21:43:01 root[43795] /usr/local/etc/rc.d/nut: WARNING: failed precmd routine for nut
2021-03-21T21:43:00 upsmon[94899] upsmon parent: read
2021-03-21T21:42:58 upsmon[95263] UPS [CyberPowerUPS]: connect failed: Connection failure: Operation already in progress
2021-03-21T21:42:27 upsmon[95263] UPS [CyberPowerUPS]: connect failed: Connection failure: Operation timed out
2021-03-21T21:42:04 root[81548] /usr/local/etc/rc.d/nut: WARNING: failed precmd routine for nut
Title: Re: Help getting NUT working with CyberPower UPS
Post by: FullyBorked on March 22, 2021, 02:45:39 am
Dang, unfortunately my ups is USB only, surprised that's been broken so long.
The current version on github seems to work fine, but without a release since 2016 it's almost impossible to update the FreeBSD package.

How can install the version from github?  Any downsides to sideloading like that?
Title: Re: Help getting NUT working with CyberPower UPS
Post by: Patrick M. Hausen on March 22, 2021, 10:32:15 am
How can install the version from github?
You would need to checkout the source from github and build it on HardenedBSD yourself.

Any downsides to sideloading like that?
Sorry, no idea.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: genesysguy on March 22, 2021, 04:02:16 pm
I did a fresh install yesterday and ran into the same issue with my Cyberpower UPS.

When I looked into the ups.conf file located at /usr/local/etc/nut, I noticed that opnsense was adding several (3) configs for the ups in the file.  I removed the configs that didn't pertain and was left with:

# Please don't modify this file as your changes might be overwritten with
# the next update.
#
[CP1500PFCLCD]
driver=usbhid-ups
port=auto


After saving and rebooting, it worked.  But since there isn't a widget for the UPS like in pfSense, I'm wondering why I wasted so much time mucking with it.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: FullyBorked on March 22, 2021, 04:13:19 pm
I did a fresh install yesterday and ran into the same issue with my Cyberpower UPS.

When I looked into the ups.conf file located at /usr/local/etc/nut, I noticed that opnsense was adding several (3) configs for the ups in the file.  I removed the configs that didn't pertain and was left with:

# Please don't modify this file as your changes might be overwritten with
# the next update.
#
[CP1500PFCLCD]
driver=usbhid-ups
port=auto


After saving and rebooting, it worked.  But since there isn't a widget for the UPS like in pfSense, I'm wondering why I wasted so much time mucking with it.

This might explain something too, my config file is pretty much blank.

Code: [Select]
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
MODE=standalone
~
~
Title: Re: Help getting NUT working with CyberPower UPS
Post by: Patrick M. Hausen on March 22, 2021, 04:37:46 pm
If the "old" usb-hid driver works, you are lucky. Sorry if I suggested it was completely broken. It does not work with a couple of devices, though. And the software has indeed not been updated since 2016, because they did not publish another release for 5 years ...
Title: Re: Help getting NUT working with CyberPower UPS
Post by: genesysguy on March 22, 2021, 04:50:19 pm
I did a fresh install yesterday and ran into the same issue with my Cyberpower UPS.

When I looked into the ups.conf file located at /usr/local/etc/nut, I noticed that opnsense was adding several (3) configs for the ups in the file.  I removed the configs that didn't pertain and was left with:

# Please don't modify this file as your changes might be overwritten with
# the next update.
#
[CP1500PFCLCD]
driver=usbhid-ups
port=auto


After saving and rebooting, it worked.  But since there isn't a widget for the UPS like in pfSense, I'm wondering why I wasted so much time mucking with it.

This might explain something too, my config file is pretty much blank.

Code: [Select]
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
MODE=standalone
~
~

You are looking at nut.conf, not ups.conf
Title: Re: Help getting NUT working with CyberPower UPS
Post by: FullyBorked on March 22, 2021, 04:52:42 pm
I did a fresh install yesterday and ran into the same issue with my Cyberpower UPS.

When I looked into the ups.conf file located at /usr/local/etc/nut, I noticed that opnsense was adding several (3) configs for the ups in the file.  I removed the configs that didn't pertain and was left with:

# Please don't modify this file as your changes might be overwritten with
# the next update.
#
[CP1500PFCLCD]
driver=usbhid-ups
port=auto


After saving and rebooting, it worked.  But since there isn't a widget for the UPS like in pfSense, I'm wondering why I wasted so much time mucking with it.

This might explain something too, my config file is pretty much blank.

Code: [Select]
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
MODE=standalone
~
~

You are looking at nut.conf, not ups.conf

Correct, nut.conf

EDIT: I'm dumb I misread what you posted. 

Code: [Select]
root@OPNsense:/usr/local/etc/nut # vi nut.conf
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
MODE=standalone
Title: Re: Help getting NUT working with CyberPower UPS
Post by: FullyBorked on March 22, 2021, 05:01:48 pm
@genesysguy editing the ups.conf file fixed it.  It works now.  I had some extra lines too.

Now that it's added I assume OPNsense will now power down if the battery gets critical? Didn't see any config for that part so assume that's predefined somewhere else.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: genesysguy on March 22, 2021, 06:16:24 pm
@genesysguy editing the ups.conf file fixed it.  It works now.  I had some extra lines too.

Now that it's added I assume OPNsense will now power down if the battery gets critical? Didn't see any config for that part so assume that's predefined somewhere else.

Glad it works for you now.  I assume it's an OPNsense bug that causing the extra config to be put in there.
Good question about the shutdown, I don't know. I just moved from pfSense to give this a try.
Once I saw there was no UPS widget, I kind of lost interest.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: yodaphone on March 23, 2021, 12:56:33 pm
@genesysguy editing the ups.conf file fixed it.  It works now.  I had some extra lines too.

Now that it's added I assume OPNsense will now power down if the battery gets critical? Didn't see any config for that part so assume that's predefined somewhere else.

this is done by the upsmon.conf but no point modifying it as it will be overwritten in the next update

this is pretty much default and not sure at what % opnsense shuts down.

https://networkupstools.org/docs/man/upsmon.conf.html

AFAIK there is no way in opnsense gui to modify this.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: genesysguy on March 24, 2021, 05:24:56 pm
I see that this isn't so much a bug in OPNsense as it is a misunderstanding in the GUI.  You can select each driver from the drop down and select enable/disable it.  I thought just choosing the driver once and ensuring it was selected was enough.  I had to go back through each one and ensure it was de-slected.
Title: Re: Help getting NUT working with CyberPower UPS
Post by: yodaphone on April 09, 2021, 02:07:20 pm
I'm new to opnsense from pfsense. this UPS worked fine with the plugin there.

I tried installing this plugin and I also tried all options mentioned here, but NUT just freezes my opnsense UI. Not sure where i look for the logs?

i had to reload all services to get my UI to start working again.

any ideas?

I have a cyberpower UPS connected via USB
Title: Re: Help getting NUT working with CyberPower UPS
Post by: gpb on April 09, 2021, 03:48:18 pm
As an alternative, my cyberpower UPS works fine in netclient mode.  I run NUT on a raspberry pi (usb connected) and then point to it from my NAS and OPNsense...and monitor via zabbix.