[Plugin] NUT v2 - Network UPS Tools


dmacias

Recommended Posts

12 hours ago, realies said:

It seems nut package has been updated to 2.7.5-pre. Is this replacing the old binary and can the update be reflected in the changelog?

 

Update: usbhid-ups stayed 2.7.4, great to see Nominal Power and UPS Load (W) working on Eaton!

 

Update: As discussed in the package repository, ups.power.nominal/100*battery.charge does not produce the expected results.

 

When using Eaton 5E 650i with the NUT v2 plugin, it reports:

 

Nominal Power: 650

UPS Load: 253

UPS Load %: 39

 

Eaton UPS Companion (attached to a Win10 VM) reports:

 

Output Load: 203W

Usage: 39%

 

Looking into the changes made to estimate Eaton's realpower when it is not available, I am proposing a similar change to the NUT v2 plugin until 2.7.5 or newer are deployed without any issues.

I haven't checked the specification of the UPS, but if the UPS has 650 in the name, then it's likely that 650 is the capacity in VA - not in W.

 

So it's likely that both plugin shows the correct load values.

One showing the load as 253 VA

One showing the load as 203 W

 

The VA value is almost always higher than the W value, because they can only be same for a perfectly resistive load.

  • Like 1
Link to comment

It isn't possible to estimate between VA and W unless you know the specific load that is connected to the UPS.

 

It depends on how well the Power Factor Correction (PFC) of the used PSU works. And the user may also have other equipment connected to the UPS, like switches, IoT sensor equipment etc. The regulations allows higher crest factors (quotient between VA and W) for low-power devices since they have a marginal effect on the power grid.

 

Some old wall warts can have truly terrible crest factors of 10:1 or 20:1. So a single wall wart can require 5 W but 50 VA - a difference of 45 VA from a true resistive load. While a large PSU with a crest factor of 1.1 that draws 400 W measures 440 VA - a difference of 40 VA from a true resistive load.

Link to comment
On 1/5/2018 at 3:39 AM, realies said:

It seems nut package has been updated to 2.7.5-pre. Is this replacing the old binary and can the update be reflected in the changelog?

 

Update: usbhid-ups stayed 2.7.4, great to see Nominal Power and UPS Load (W) working on Eaton!

 

I didn't add the 2.7.5pre package to the plugin because of the issues I described before.  I have since suspected that my flash drive may have become faulty (it would give an error in windows and drop off) and have swapped to a new one. I have been running 2.7.5pre for a couple days and have rebooted a dozen times without issue.  I also turned on issues as that wasn't part of the original nut plugin repo.  I added the plg file I'm using below. It includes 2.7.5pre and gets plugin version 2018.01.03 which is before your pull request. You will be notified of the 2018.01.06 update though when unRAID checks for updates. nut.plg

 

On 1/5/2018 at 8:39 AM, realies said:

Since it's not possible to create an issue in the repository, I'm writing one here.


Consider parsing the whole output of `upsc ups` to a key-value pair array instead of iterating through the keys and making use-cases for individual keys. This way the output from the ups service would be more easily accessible which eases refactoring and introducing new functionality. Would be exciting to see a separation between the front and back end too.

 

In regards to the above, this should be sufficient to generate the array:


exec("/usr/bin/upsc ups 2>/dev/null", $stdout);
print_r(array_reduce($stdout, function($carry, $line) {
 list($key, $value) = explode(":", $line, 2);
 $carry[trim($key)] = trim($value);
 return $carry;
}, []));

A demo can be seen here.

Thanks for the suggestion. I agree an array key lookup is faster and more functional than using switch but I didn't see a real reason to rewrite that bit of code (it's from the original nut plugin which borrowed it from the included apcupsd plugin). I don't really plan on adding more columns and it wouldn't be that much faster with this array size.

 

Could you explain more what you want from front and back end separation.

 

Edited by dmacias
Link to comment
On 1/4/2018 at 12:51 PM, wgstarks said:

I installed Nut so that I could use the server functions to shutdown other computers also connected to the same UPS. So far I have been completely unable to get nit working on the other machines. I’ve reached the point where I’m ready to just call the project a failure and move on.

 

What do I need to do to switch back to the built in apcupsd package? Will just uninstalling the nut plugin take care of it?

Sorry for the late reply. Uninstalling maybe all that is needed but I think I had to reboot when I was testing the apcupsd plugin recently.

Link to comment
7 hours ago, dmacias said:

 

Thanks for the suggestion. I agree an array key lookup is faster and more functional than using switch but I didn't see a real reason to rewrite that bit of code (it's from the original nut plugin which borrowed it from the included apcupsd plugin). I don't really plan on adding more columns and it wouldn't be that much faster with this array size.

 

Could you explain more what you want from front and back end separation.

 

 

Changing the switch structure for a key-value array pair wouldn't be increasing processing speed but allowing for further and easier progression of the plugin. Future functionality might allow the user to specify UPS information that they would want to be displayed. This would be easy if the front-end (html and javascript) is isolated from the back-end (php) if both communicate via a REST interface. In practice, nut_status.php would be replying with a json array containing the information and the front-end would be drawing it.

 

Another reason to have the key-value array pair would be if there is more UPS specific rules such as the Eaton one. Another case would be falling back to VA instead of W for the load section of UPS units without real power and a specific estimation rule. All of those would be easier to write and manage outside a switch statement.

 

Happy to prepare a refactor for the aforementioned.

Link to comment
 
Changing the switch structure for a key-value array pair wouldn't be increasing processing speed but allowing for further and easier progression of the plugin. Future functionality might allow the user to specify UPS information that they would want to be displayed. This would be easy if the front-end (html and javascript) is isolated from the back-end (php) if both communicate via a REST interface. In practice, nut_status.php would be replying with a json array containing the information and the front-end would be drawing it.
 
Another reason to have the key-value array pair would be if there is more UPS specific rules such as the Eaton one. Another case would be falling back to VA instead of W for the load section of UPS units without real power and a specific estimation rule. All of those would be easier to write and manage outside a switch statement.
 
Happy to prepare a refactor for the aforementioned.


 
Changing the switch structure for a key-value array pair wouldn't be increasing processing speed but allowing for further and easier progression of the plugin. Future functionality might allow the user to specify UPS information that they would want to be displayed. This would be easy if the front-end (html and javascript) is isolated from the back-end (php) if both communicate via a REST interface. In practice, nut_status.php would be replying with a json array containing the information and the front-end would be drawing it.
 
Another reason to have the key-value array pair would be if there is more UPS specific rules such as the Eaton one. Another case would be falling back to VA instead of W for the load section of UPS units without real power and a specific estimation rule. All of those would be easier to write and manage outside a switch statement.
 
Happy to prepare a refactor for the aforementioned.


Ok. I thought you meant nut server/client separation. I get what your saying as most of my other plugins are written this way. This is the way it was written and I don't see any benefit vs time spent to rewrite it. You're more than welcome to refractor the code. I'll merge it.

A fall back of VA is not really useful. Nobody knows what 250VA means? User input of the output watt capacity of their ups would be a better method.
Link to comment
Yes, the problem is that it doesn't read the values correctly because of what I see, right?
 
5a54f468b7dbd_Capturadepantalla(1).thumb.png.e4ffc78cc87ff0b5b969b606ebc17a74.png
Yeah either the nut driver or the ups doesn't present all the values especially load or time left on battery. But it may still work to shutdown the server during power outage.
Link to comment
15 hours ago, dmacias said:
18 hours ago, Nebur692 said:
Yes, the problem is that it doesn't read the values correctly because of what I see, right?
 
5a54f468b7dbd_Capturadepantalla(1).thumb.png.e4ffc78cc87ff0b5b969b606ebc17a74.png

Yeah either the nut driver or the ups doesn't present all the values especially load or time left on battery. But it may still work to shutdown the server during power outage.

 

The problem is just that, I have to turn off the server when there are 4 minutes of battery.

Not reading the time of battery, I turn it off at the moment even with a lot of battery.

 

With an update of the plugin could not be made compatible?

Link to comment
1 hour ago, Nebur692 said:

 

The problem is just that, I have to turn off the server when there are 4 minutes of battery.

Not reading the time of battery, I turn it off at the moment even with a lot of battery.

 

With an update of the plugin could not be made compatible?

It's much better for all your equipment to shut down with lots of battery left. The time it takes to refill means that if you were to get 2 power outages in the same day, the second outage would likely crash the server because the batteries didn't have enough time to recharge.

 

If the power is out for more than a minute or two, it's likely going to be out for much longer than the batteries are capable of supporting. Better to shut down sooner than wait until the batteries are almost dead.

 

Also, these types of batteries don't like to be discharged below 50% very often, it reduces their life.

Link to comment
15 minutes ago, jonathanm said:

It's much better for all your equipment to shut down with lots of battery left. The time it takes to refill means that if you were to get 2 power outages in the same day, the second outage would likely crash the server because the batteries didn't have enough time to recharge.

 

If the power is out for more than a minute or two, it's likely going to be out for much longer than the batteries are capable of supporting. Better to shut down sooner than wait until the batteries are almost dead.

 

Also, these types of batteries don't like to be discharged below 50% very often, it reduces their life.

 

Anyway I would like to show the load and battery

Link to comment
I was keeping this plugin up to date & was happy with the added "nominal power" functionality released in 2018.01.03

The latest update seems to have broken that functionality....any advice on how to get "nominal power" and "UPS load" displayed properly again

nutups.thumb.png.6be4f4b247937e85123c23e09bdb0a95.png

I have a Tripp Lite too. The 2018.01.03 nominal power was in volt amperes and didn't display the correct load. Our UPS don't have the ups.realpower.nominal variable. I need the watt capacity to calculate the power factor to reflect an accurate load in watts. Basically I just need the total watts multiplied by the load percentage. So change the UPS Power and Load display setting at the bottom of the page to manual and enter in your total capacity in VA and Watts. I believe your values should be 1500 for VA and 900 for Watts. Click apply.

 

Link to comment
2 minutes ago, dmacias said:

Basically I just need the total watts multiplied by the load percentage.

It's important to remember that if you have a UPS that supplies max 500 W or max 650 VA and claims the load is 50%, then the only thing you know is that

1) the load is <= 250 W

2) the load is <= 325 VA

 

But you can't figure out the power factor, because you can't know if the UPS computed 50% based on VA or W.

 

The UPS could internally have computed that the load was 45% on W and 50% on VA. Or 50% on W and 45% on VA. But it still needs to report the worst-case load percentage, which would be 50%.

Link to comment
39 minutes ago, dmacias said:

I have a Tripp Lite too. The 2018.01.03 nominal power was in volt amperes and didn't display the correct load. Our UPS don't have the ups.realpower.nominal variable. I need the watt capacity to calculate the power factor to reflect an accurate load in watts. Basically I just need the total watts multiplied by the load percentage. So change the UPS Power and Load display setting at the bottom of the page to manual and enter in your total capacity in VA and Watts. I believe your values should be 1500 for VA and 900 for Watts. Click apply.

 

 

Worked like a charm...

 

Had a feeling I could use that, but it was populated automatically last build so I figured I'd ask

 

UPS load is close to reading on upstream Kill-A-Watt

Link to comment



It's important to remember that if you have a UPS that supplies max 500 W or max 650 VA and claims the load is 50%, then the only thing you know is that
1) the load is 2) the load is  
But you can't figure out the power factor, because you can't know if the UPS computed 50% based on VA or W.
 
The UPS could internally have computed that the load was 45% on W and 50% on VA. Or 50% on W and 45% on VA. But it still needs to report the worst-case load percentage, which would be 50%.

I added user input so I could figure the power factor. Correct me if I'm wrong but I was speaking to the Tripp Lite specifically to any UPS that reports ups.power.nominal which is in VA as opposed to the ups.realpower.nominal which is in watts. I would get the load in watts from power nominal x load%/100 x power factor. For UPS with real power nominal the power factor is included already and shown in watts. So all I need is real power nominal x load%/100. For a UPS like mine I can get the power factor with user input of 700W/1200VA. To get the load in watts 1200VA x load%/100 x 700W/1200VA which is basically my 700W capacity x load%/100. I figure ups.load 50 is 50% whether it was from VA or watts. It's what I apply that 50% to that matters.

ups.power.nominal is the capacity of 1200VA for my UPS. So I could just use that and ask for user input of watt capacity. But maybe some UPS don't have that variable too.
Link to comment

I plan on building an unRAID server and I already have custom built pfSense router. I also plan on getting an Eaton 5PX UPS. I want to make sure this will all work right. Now I see my options as connect via serial or USB to either pfSense or unRAID, then with NUT on both, I can get the other device connected. One concern I have about this is what if the NUT server turns itself off before the other device does. How will the other device know when to turn off?

 

A better way I'd prefer to do it is with a network card in the UPS, which it supports. Costs some extra, but it would be fine. I'd then use SNMP I think as the best way to get both pfSense and unRAID connected and won't have to worry about one relying on the other? Can anyone shed some light on this, please? Thanks.

Link to comment
10 hours ago, dmacias said:


 


I added user input so I could figure the power factor. Correct me if I'm wrong but I was speaking to the Tripp Lite specifically to any UPS that reports ups.power.nominal which is in VA as opposed to the ups.realpower.nominal which is in watts. I would get the load in watts from power nominal x load%/100 x power factor. For UPS with real power nominal the power factor is included already and shown in watts. So all I need is real power nominal x load%/100. For a UPS like mine I can get the power factor with user input of 700W/1200VA. To get the load in watts 1200VA x load%/100 x 700W/1200VA which is basically my 700W capacity x load%/100. I figure ups.load 50 is 50% whether it was from VA or watts. It's what I apply that 50% to that matters.

ups.power.nominal is the capacity of 1200VA for my UPS. So I could just use that and ask for user input of watt capacity. But maybe some UPS don't have that variable too.

A UPS specification of 700 W / 1200 VA can't be used to get any load factor. It can only be used to compute the largest power factor where the UPS still can give out maximum true power without becoming limited by apparent power.

 

It is the power factor of the actual load, that decides if the UPS will reach the maximum limit because it reaches 700 W or 1200 VA.

 

So to display the power in W, you need a UPS that measures and reports the load in W. Or reports the load in VA + PF. Without that information, you have no option but to display the information you do have available. So you need to skip displaying W and only show VA or %.

Link to comment



I plan on building an unRAID server and I already have custom built pfSense router. I also plan on getting an Eaton 5PX UPS. I want to make sure this will all work right. Now I see my options as connect via serial or USB to either pfSense or unRAID, then with NUT on both, I can get the other device connected. One concern I have about this is what if the NUT server turns itself off before the other device does. How will the other device know when to turn off?
 
A better way I'd prefer to do it is with a network card in the UPS, which it supports. Costs some extra, but it would be fine. I'd then use SNMP I think as the best way to get both pfSense and unRAID connected and won't have to worry about one relying on the other? Can anyone shed some light on this, please? Thanks.


Shutdown modes Battery Level and Runtime Left both require UPS input. Time on Battery does not. So you could use Time on Battery for clients. Either way you could make sure they are set to shutdown before the server shuts down. Direct network connection through SNMP would be best with no server in between.
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.