[Plugin] NUT v2 - Network UPS Tools


dmacias

Recommended Posts

Hi there, i'm having issues with my ups staying connected. looking in the system log i get the errors in the picture. the only way to make it work again is to stop the service, unplug and replug the usb which i'm keeping it in the same usb port however i have tried changing ports and then re-enabling the service and it'll stay working for quite a while. Any ideas of what i can try to resolve?image.thumb.png.cfb021047509f02e66046eec53855e2a.png

Link to comment
5 hours ago, jcofer555 said:

Hi there, i'm having issues with my ups staying connected. looking in the system log i get the errors in the picture. the only way to make it work again is to stop the service, unplug and replug the usb which i'm keeping it in the same usb port however i have tried changing ports and then re-enabling the service and it'll stay working for quite a while. Any ideas of what i can try to resolve?image.thumb.png.cfb021047509f02e66046eec53855e2a.png

Do you see any messages in the logs about the USB connection dropping?

Link to comment
59 minutes ago, SimonF said:

Do you see any messages in the logs about the USB connection dropping?

it does seem so this is what the log shows. my usb mouse seems to drop connection in a similar way preventing a vm from starting that i have the device passed through on but my usb keyboard and headset don't seem to have problems.


image.png.bc6bca5b36fb8b95c63d131dee79b100.png

Link to comment
9 hours ago, jcofer555 said:

it does seem so this is what the log shows. my usb mouse seems to drop connection in a similar way preventing a vm from starting that i have the device passed through on but my usb keyboard and headset don't seem to have problems.


image.png.bc6bca5b36fb8b95c63d131dee79b100.png

Usb drop offline and was enumerated so nut likely trying to use dev 27 but is now 28 hence the failure.

Link to comment
4 hours ago, SimonF said:

Usb drop offline and was enumerated so nut likely trying to use dev 27 but is now 28 hence the failure.

Wonder why its dropping out its a new build, but ill keep try to resolve that, anyway to have it pick up the new dev number when it does this like the built in ups plugin does?

Link to comment
11 hours ago, SimonF said:

Usb drop offline and was enumerated so nut likely trying to use dev 27 but is now 28 hence the failure.

i changed the port it's plugged into to a usb 3.0 port and now i get, any idea about these? when i had the ups hooked up to my other server i never had the problems so i'm not sure where to go on these.image.thumb.png.5259cdd68ae30abf2eff208a7dabd71e.png

Link to comment
On 6/4/2023 at 5:02 AM, JudasD said:

is anyone else seeing "/etc/nut/upssched.conf" get overwritten by the default file on each reboot?

 

Thanks,

JD

 

After some investigation I've managed to find the cause for this issue and the other users' issues.

 

The changes to the NUT configuration files (present in /etc/nut/) done via the web-interface or directly inside the files are currently lost because the script does not save those modified NUT configuration files onto the flash drive (USB) at all when the mode is set to "Enable Manual Config Only: No".

 

The information "You can still edit the conf files to add extras not included on the NUT Settings Page." at the moment only applies to the LIVE/CURRENT running session of UNRAID. After a reboot the package basically gets reinstalled and the installations script pulls the default NUT configuration files from the package into /etc/nut, when it should actually be pulling the previously saved backups of the modified NUT configuration files from the flash drive (USB) into /etc/nut.

 

This behaviour can only be changed inside the package by the developer, basically the script would need to backup the NUT configuration files onto the flash drive (USB) regardless of the state of the setting "Enable Manual Config".

 

In any case the script should save the NUT configuration files from /etc/nut onto the flash drive (USB) for re-population of /etc/nut after a system reboot, no matter if it's using:

 

  1. only the settings from the web-interface
  2. a mixture of the web-interface settings plus custom extra settings written into the configuration files (either via web-interface or directly)
  3. only the configuration files without the web-interface settings

 

for the configuration of the services; it does this currently only in the last scenario (number 3).

 

@SimonF: Any chance we can get a fix for this in the next version?

Edited by Rysz
Link to comment

Hi!

I have a problem with current Unraid (6.12.3) and latest NUT plugin (2023.06.03).

 

When there is a power outage Unraid server and other client machines are correctly turned off, but UPS is not turned off (of course I setup "Turn off UPS after shutdown" to yes in plugin configuration). This produces another effect, when power returns the Unraid server is not turned on again!

 

I investigated the cause seems related with the creation of "/etc/nut/killpower" that should end in running: "upsmon -c fsd" to turn UPS off.

May be is because the /etc/nut/ folder os owned by nut user?

AFAIK this was working ok with the "old" plugin

 

Please help me to fix this issue, I need server restarted as soon as possible when power is back.

 

Thanks in advance

Best Regards

Link to comment

Dear fellow NUT-ters,

 

I've fixed the problem with configuration files not persisting a system reboot. Once these changes are incorporated into @SimonF's project, please make sure to add any configuration changes at the end of the respective configuration files.

 

While at it, I've also added a feature which presents a fail-safe in case the UPS emits a LOWBATT event. This allows for a graceful shutdown in case of a prematurely dying battery (regardless of and in addition to any other shutdown conditions). One theoretic scenario would be a degraded battery not being able to withstand the configured shutdown conditions (i.e. "Time on battery before shutdown"). Before implementing this feature a degraded battery could theoretically run completely empty before any other shutdown condition is met, resulting in a hard shutdown of the server. By activating this new feature the server will immediately but gracefully shutdown when the UPS emits a LOWBATT event (usually happens around 20% remaining battery, configurable directly on some UPS screens like for Eaton 5P) regardless of other configured shutdown conditions. By default this setting will be DISABLED.

 

I cannot guarantee a long-term commitment to this project and particularly do not mean to hijack @SimonF's considerable efforts. I will therefore be submitting respective pull-requests for any fixes and additions so that they can be incorporated into his repository for sake of continuance, rather than trying to advertise users into using a new fork of the project.

 

However, for those urgently needing those changes, you can find the (obviously experimental) modified plugins here:

Please make sure to uninstall any other NUT installations and ideally reboot your server before installing the experimental modified plugins. The same obviously applies if you're switching back to @SimonF's versions!

 

I'd appreciate any errors being reported back here so I can work on fixing those before they make their way into the upstream repositories, so far I've however not encountered any on my UNRAID installation with an USB-connected Eaton 5P.

 

Best regards!

 

 

 

Edited by Rysz
  • Like 1
  • Thanks 1
Link to comment
5 hours ago, Rysz said:

Dear fellow NUT-ters,

 

I've fixed the problem with configuration files not persisting a system reboot. Once these changes are incorporated into @SimonF's project, please make sure to add any configuration changes at the end of the respective configuration files.

 

While at it, I've also added a feature which presents a fail-safe in case the UPS emits a LOWBATT event. This allows for a graceful shutdown in case of a prematurely dying battery (regardless of and in addition to any other shutdown conditions). One theoretic scenario would be a degraded battery not being able to withstand the configured shutdown conditions (i.e. "Time on battery before shutdown"). Before implementing this feature a degraded battery could theoretically run completely empty before any other shutdown condition is met, resulting in a hard shutdown of the server. By activating this new feature the server will immediately but gracefully shutdown when the UPS emits a LOWBATT event (usually happens around 20% remaining battery, configurable directly on some UPS screens like for Eaton 5P) regardless of other configured shutdown conditions. By default this setting will be DISABLED.

 

I cannot guarantee a long-term commitment to this project and particularly do not mean to hijack @SimonF's considerable efforts. I will therefore be submitting respective pull-requests for any fixes and additions so that they can be incorporated into his repository for sake of continuance, rather than trying to advertise users into using a new fork of the project.

 

However, for those urgently needing those changes, you can find the (obviously experimental) modified plugins here:

Please make sure to uninstall any other NUT installations and ideally reboot your server before installing the experimental modified plugins. The same obviously applies if you're switching back to @SimonF's versions!

 

I'd appreciate any errors being reported back here so I can work on fixing those before they make their way into the upstream repositories, so far I've however not encountered any on my UNRAID installation with an USB-connected Eaton 5P.

 

Best regards!

 

 

 

I am not the original author, I just made changes for 6.12 compatibility so thanks for the pr will review. Happy for any contribution.

  • Like 1
Link to comment

Hi I just set up this plugin on unraid and installed seperate plugins on home assistant and OPNsense to use the unraid nut server. My understanding is that now all 3 devices will shutdown as per the settings on the unraid plugin (2min time on battery in my case). Is that correct?

Link to comment
21 hours ago, rama3124 said:

Hi I just set up this plugin on unraid and installed seperate plugins on home assistant and OPNsense to use the unraid nut server. My understanding is that now all 3 devices will shutdown as per the settings on the unraid plugin (2min time on battery in my case). Is that correct?

 

When UNRAID shuts down as per your configured settings, the secondary devices (slaves) will also receive shutdown commands and shutdown slightly before (usually 15 seconds) your primary device (master) does.

 

Some clients allow you to configure separate shutdown settings for your client instance (e.g. time on battery), but to answer your question: Yes, the primary instance of NUT on your UNRAID will always instruct the secondary devices to shutdown with it.

 

But you should test the shutdown sequence before blindly relying on your configuration:

upsmon -c fsd

Is the command to execute on your primary NUT instance (in this case your UNRAID server).

Link to comment
2 hours ago, Rysz said:

 

When UNRAID shuts down as per your configured settings, the secondary devices (slaves) will also receive shutdown commands and shutdown slightly before (usually 15 seconds) your primary device (master) does.

 

Some clients allow you to configure separate shutdown settings for your client instance (e.g. time on battery), but to answer your question: Yes, the primary instance of NUT on your UNRAID will always instruct the secondary devices to shutdown with it.

 

But you should test the shutdown sequence before blindly relying on your configuration:

upsmon -c fsd

Is the command to execute on your primary NUT instance (in this case your UNRAID server).

Thanks, i just ran your test command and everything shutdown as expected. Doesn't seem like my clients offer separate shutdown times but i can live with that

Link to comment

Hi,

 

Is really this plugin turning off UPS for you when there is a power outage?

In my tests the UPS is not turned off but it was working in previous versions of Unraid or plugin when I initially setup.

 

Why it does not turn off UPS?

Because when it tries to do it is in rc.6 running the command:

[ -x /etc/rc.d/rc.nut ] && /etc/rc.d/rc.nut shutdown

this runs rc.nut with parameter shutdown, so in this script it executes:

/usr/sbin/upsdrvctl shutdown

 

The problem is: at this point of rc.6 the drives are unmounted so upsdrvctl is not found.

 

Please can somebody confirm if his UPS is  turned off? Mine is not and can't be done.

 

Thanks in advance

Best Regards,

 

Link to comment
On 7/21/2023 at 8:02 PM, yonesmit said:

Hi,

 

Is really this plugin turning off UPS for you when there is a power outage?

In my tests the UPS is not turned off but it was working in previous versions of Unraid or plugin when I initially setup.

 

Why it does not turn off UPS?

Because when it tries to do it is in rc.6 running the command:

[ -x /etc/rc.d/rc.nut ] && /etc/rc.d/rc.nut shutdown

this runs rc.nut with parameter shutdown, so in this script it executes:

/usr/sbin/upsdrvctl shutdown

 

The problem is: at this point of rc.6 the drives are unmounted so upsdrvctl is not found.

 

Please can somebody confirm if his UPS is  turned off? Mine is not and can't be done.

 

Thanks in advance

Best Regards,

 

My Eaton 5P powers off just fine (via USB). edit: on my old 6.8.3 system!

Edited by Rysz
Link to comment
1 hour ago, Rysz said:

My Eaton 5P powers off just fine (via USB).

 

It's very strange because in unraid shutdown script (rc.6) you can find this command:

/bin/umount -v -a

the output of this command in my system is:

/mnt                     : successfully unmounted
/sys/fs/cgroup           : successfully unmounted
/hugetlbfs               : successfully unmounted
/sys/fs/fuse/connections : successfully unmounted
/dev/shm                 : successfully unmounted
/dev/pts                 : ignored
/usr                     : successfully unmounted
/usr                     : successfully unmounted
/lib                     : successfully unmounted
/lib                     : successfully unmounted
/run                     : successfully unmounted
/sys                     : ignored
/proc                    : ignored

so /usr is unmounted.

it is imposible that later UPS can be shutdown:

/usr/sbin/upsdrvctl shutdown

 

I think that this command should be run before unmounting the drive.

How can you ups shutdown?

 

Best Regards,

 

 

  • Like 1
Link to comment
11 hours ago, yonesmit said:

 

It's very strange because in unraid shutdown script (rc.6) you can find this command:

/bin/umount -v -a

the output of this command in my system is:

/mnt                     : successfully unmounted
/sys/fs/cgroup           : successfully unmounted
/hugetlbfs               : successfully unmounted
/sys/fs/fuse/connections : successfully unmounted
/dev/shm                 : successfully unmounted
/dev/pts                 : ignored
/usr                     : successfully unmounted
/usr                     : successfully unmounted
/lib                     : successfully unmounted
/lib                     : successfully unmounted
/run                     : successfully unmounted
/sys                     : ignored
/proc                    : ignored

so /usr is unmounted.

it is imposible that later UPS can be shutdown:

/usr/sbin/upsdrvctl shutdown

 

I think that this command should be run before unmounting the drive.

How can you ups shutdown?

 

Best Regards,

 

 

 

Not sure what you mean, but the relevant files are in RAM in remain accessible.

Besides I cannot find the command "/bin/umount -v -a" on its own anywhere in my RC.6 file.

It does exist with additional parameters to unmount specific targets, but not "/bin/umount -v -a" on its own?

 

Maybe your UPS does not support powering off - which one are you using?

I know my Eaton 5P has a setting where you specifically have to allow a software-initiated poweroff.

 

 

 

 

Link to comment
On 7/17/2023 at 12:17 PM, Rysz said:

Dear fellow NUT-ters,

 

I've fixed the problem with configuration files not persisting a system reboot. Once these changes are incorporated into @SimonF's project, please make sure to add any configuration changes at the end of the respective configuration files.

 

While at it, I've also added a feature which presents a fail-safe in case the UPS emits a LOWBATT event. This allows for a graceful shutdown in case of a prematurely dying battery (regardless of and in addition to any other shutdown conditions). One theoretic scenario would be a degraded battery not being able to withstand the configured shutdown conditions (i.e. "Time on battery before shutdown"). Before implementing this feature a degraded battery could theoretically run completely empty before any other shutdown condition is met, resulting in a hard shutdown of the server. By activating this new feature the server will immediately but gracefully shutdown when the UPS emits a LOWBATT event (usually happens around 20% remaining battery, configurable directly on some UPS screens like for Eaton 5P) regardless of other configured shutdown conditions. By default this setting will be DISABLED.

 

I cannot guarantee a long-term commitment to this project and particularly do not mean to hijack @SimonF's considerable efforts. I will therefore be submitting respective pull-requests for any fixes and additions so that they can be incorporated into his repository for sake of continuance, rather than trying to advertise users into using a new fork of the project.

 

However, for those urgently needing those changes, you can find the (obviously experimental) modified plugins here:

Please make sure to uninstall any other NUT installations and ideally reboot your server before installing the experimental modified plugins. The same obviously applies if you're switching back to @SimonF's versions!

 

I'd appreciate any errors being reported back here so I can work on fixing those before they make their way into the upstream repositories, so far I've however not encountered any on my UNRAID installation with an USB-connected Eaton 5P.

 

Best regards!

 

 

 

I have merged @Rysz changes into my plugins. If your are running 2.8 you need to load the plugin via https://raw.githubusercontent.com/SimonFair/NUT-unRAID/master/plugin/nut-2.8.0.plg

 

Thanks for the PR.

 

Link to comment
2 hours ago, Rysz said:

 

Not sure what you mean, but the relevant files are in RAM in remain accessible.

Besides I cannot find the command "/bin/umount -v -a" on its own anywhere in my RC.6 file.

It does exist with additional parameters to unmount specific targets, but not "/bin/umount -v -a" on its own?

 

Maybe your UPS does not support powering off - which one are you using?

I know my Eaton 5P has a setting where you specifically have to allow a software-initiated poweroff.

 

 

 

 

Are you running unraid 6.12.x ?

In both rc.0 and rc.6 i find:

# Unmount local file systems:
echo "Unmounting local file systems:"
/bin/umount -v -a

may be this is a new addition in 6.12 (because as I said the UPS power off was working ok with my ups when I tested time ago).

And also UPS shutdown when i run from command line:

upsdrvctl -u root shutdown

 

I looked my plugins and I don't find anyone adding the "umount -v -a" command so it must be from unraid 6.12

 

Please, can anyone running unraid 6.12.x confirm if "/bin/umount -v -a" is present in file /etc/rc.d/rc.6 or not?

 

Thnaks in advance

 

 

Link to comment
On 7/5/2023 at 6:51 PM, SimonF said:

So it is still not working correctly on my latest version?

Unfortunately no (Version 2023.07.22). Up to 60W or 10% power it shows the correct consumption, above 60W respectively 11% power, it shows only "1W" as the current consuming in the status bar.

Maybe the error can be found quickly, otherwise it doesn't really bother.

Link to comment
  • Rysz featured this topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.