Netbox: Power utilization not calculated over cascaded devices/PDU

Created on 30 Jul 2019  Â·  33Comments  Â·  Source: netbox-community/netbox

Environment

  • Python version: 3.6.8
  • NetBox version: 2.6.1

Steps to Reproduce

  1. create power panel
  2. create power feed
  3. create 3 devices (example: 'pdu_1level', 'pdu_2level', 'device')
  4. connect 'pdu_1level' to created feed (over power port)
  5. connect 'pdu_2level' to 'pdu_1level' (over power port + power outlet)
  6. connect 'device' to 'pdu_2level'
  7. set 'Allocated draw' for 'device' (example: 300)

Expected Behavior

In 'pdu_2level' view 'Power Utilization -> Allocated' - 300;
In 'pdu_1level' view 'Power Utilization -> Allocated' - 300;
In power feed view 'Utilization (Allocated)' - 300.

Observed Behavior

In 'pdu_2level' view 'Power Utilization -> Allocated' - 300;
In 'pdu_1level' view 'Power Utilization -> Allocated' - 0;
In power feed view 'Utilization (Allocated)' - 0.

pending closure needs owner feature

Most helpful comment

Same behaviour on our Side - It would be nice to have this Feature - it is not uncommon to add PDUs to USVs and USVs to Power Feeds especially in smaller Edge Cabinets..

All 33 comments

Same behaviour on our Side - It would be nice to have this Feature - it is not uncommon to add PDUs to USVs and USVs to Power Feeds especially in smaller Edge Cabinets..

Agreed. In a "server room" (versus a large datacenter?) we often see multiple PDUs on a single UPS (backed by a single circuit/feed), so at least 3 hops for most equipment.

Feed -> UPS -> PDU -> Device

Issues like this illustrate why participation in beta releases is so important. Modifying the current approach to support recursive calculations efficiently would require a substantial amount of work. Do we have any volunteers?

We could switch our Netbox instance to a beta branch to test it out - no problem!

@larsuhartmann not beta testing, actually committing to doing the work.

@jeremystretch Is a recursive SQL query the right way to go about this?
nested_power_draw_legs.patch.txt
Just a proof of concept (individual legs only).

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

This definetly is also an issue for us. Sadly we do not have internal coding-capabilities we could supply but we would be happy if anyone could support this think

Using a recursive query in the database seems like the best approach; as far as I can tell, performing the recursion outside of it would entail O(n) as opposed to O(1) in it.

The work that @andrewcleveland has done looks good, but NetBox is currently prone to loops with that query because the current power model allows for loops, be it direct (power port connected back to a power outlet on the same device) or indirect (looped over multiple devices).

It might be worth addressing the power loop first as it could very well fix this issue in the process. I'm not sure how a recursive model (or multiple) can be handled by Django as most solutions out there are handled at the database.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@jeremystretch could you please check if the proposed solution (see @andrewcleveland and #3782) is accetable? I'd really like to have this fixed. We have several cascaded PDUs in our racks and thus currently can't montor the power usage.

I'll take care of creating the PR for this. I was initially wanting to prevent power loops, but I'm more than fine with keeping them (see #3782 for more info).

Instead, I'll limit the recursive query to a number of iterations (maybe 16) and use UNION instead of UNION ALL (former doesn't include duplicates). If there is a loop, it'll cause the query to hit the iteration limit, but will still return valid and non-inflated/non-duplicate results.

No preference on the number, but I figure it's unreal for someone to chain 16 power sources

I'll make sure to put enough tests to detect any regression in this as it involves a raw query.

My hero!

--Rob


Rob LaRose

engineer | rock paper scissors https://rockpaperscissors.com/ 245 5th
ave 23rd floor new york ny 10016 | O 212 255 6446

On Sun, Jan 12, 2020 at 3:34 PM hSaria notifications@github.com wrote:

I'll take care of creating the PR for this. I was initially wanting to
prevent power loops, but I'm more than fine with keeping them (see #3782
https://github.com/netbox-community/netbox/issues/3782 for more info).

Instead, I'll limit the recursive query to a number of iterations (maybe
16) and use UNION instead of UNION ALL (former doesn't include
duplicates). If there is a loop, it'll cause the query to hit the iteration
limit, but will still return valid and non-inflated/non-duplicate results.

I'll make sure to put enough tests to detect any regression in this as it
involves a raw query.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/netbox-community/netbox/issues/3377?email_source=notifications&email_token=AFSTFE3SFPJDIYZMEAVJEGDQ5N5EPA5CNFSM4IIAORB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIXDQPA#issuecomment-573454396,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AFSTFE4I3FH2X4BO7HA54BTQ5N5EPANCNFSM4IIAORBQ
.

@andrewcleveland Thanks a lot for your query; I modified it to remove looped entries, but apart from that, it pretty much worked from the get go.

Just need to add tests for this and then I'll fire up a PR.

@hSaria, thank you. I'm eager to test this :)

Me too!

--Rob


Rob LaRose

engineer | rock paper scissors https://rockpaperscissors.com/ 245 5th
ave 23rd floor new york ny 10016 | O 212 255 6446

On Tue, Jan 14, 2020 at 8:17 AM Patrick Hurrelmann notifications@github.com
wrote:

@hSaria https://github.com/hSaria, thank you. I'm eager to test this :)

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/netbox-community/netbox/issues/3377?email_source=notifications&email_token=AFSTFE5DXW6K6OXXOVALUCDQ5W3PPA5CNFSM4IIAORB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI4R5DA#issuecomment-574168716,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AFSTFE2FHQCFHJF3I6FBJYDQ5W3PPANCNFSM4IIAORBQ
.

Can someone help me with this?
my calculation also dows not work.

Is created a panel wich goes into a feed wich goes into a device called "UPS" wich goes into a device called "PDU" wich goes to other devices.

example:
Panel->Feed->(PowerPort of UPS - Power Outlet of UPS) ->
(PowerPort of PDU - Power Outlet of PDU) -> Switch

the allocated draw of the switch is not in the utilization of the pdu. and also not further down the chain.

fells like the power of the outlets are not calculated into the ultilization

can someone eli5 me how to do power in netbox? Have the strange feeling i am missing something here. since english is not my main language i also dont really understand what allocated and maximum draw means. the manual is kinda limited on this.
Like allocated on the pdu is the power the pdu itself neets for running its software (metered with webinterface) and the like ?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

Looks like jeremystretch already intercepted this but yeah please don't let this go stale/wontfix. I'm eagerly awaiting!

thank you Jeremy for accepting this one. I'm just spinning up a new vm to test this, as I could not do it yet in our testing-environment

I just tested this in a new test setup and it is working great. Cascaded PDU get correctly summed and it now possible to handle the use cases described in this ticket. Thank you very much for your PR @hSaria and @jeremystretch for your tremendous work on this project and the patience with us users.

Is this feature included in the recent 2.7.4 release? Or still outside the releases?

--Rob

--
Rob LaRose
engineer | rock paper scissors
245 5th ave 23rd floor new york ny 10016 | O 212 255 6446

On Feb 4, 2020, at 5:51 PM, Patrick Hurrelmann notifications@github.com wrote:


I just tested this in a new test setup and it is working great. Cascaded PDU get correctly summed and it now possible to handle the use cases described in this ticket. Thank you very much for your PR @hSaria and @jeremystretch for your tremendous work on this project and the patience with us users.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

@roblarose No, it hasn't been implemented yet. I believe @phurrelmann means that he tried out the pull request submitted by @hSaria above.

Roger that. Thank you. :-)

--Rob


Rob LaRose

engineer | rock paper scissors https://rockpaperscissors.com/ 245 5th
ave 23rd floor new york ny 10016 | O 212 255 6446

On Tue, Feb 4, 2020 at 6:10 PM Jeremy Stretch notifications@github.com
wrote:

@roblarose https://github.com/roblarose No, it hasn't been implemented
yet. I believe @phurrelmann https://github.com/phurrelmann means that
he tried out the pull request submitted by @hSaria
https://github.com/hSaria above.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/netbox-community/netbox/issues/3377?email_source=notifications&email_token=AFSTFEYLSLYQ4OCLGYTRJJDRBHYWVA5CNFSM4IIAORB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKZRDIY#issuecomment-582160803,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AFSTFE6UEKP2T3H32D5RYBTRBHYWVANCNFSM4IIAORBQ
.

is this topic still being focused by the developers or won't this be fixed?
Thank you.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

Please do not close this. still needing this function

Same here! It would be really nice to have this!

This has been tagged "needs owner" for several months. If no one is interested in committing to the work, it will be closed. @MarcHagen @larsuhartmann are either of you volunteering to own the implementation?

Hey Jeremy,

I think the issue here is that we don’t have an acceptable solution without changing the existing behavior in power modelling. As you and I discussed in previous PRs, raw SQL is difficult to maintain and calculating a topology tree and storing it as a field in the model is somewhat complex.

Because loops are currently permitted in power modelling, we can’t use MPTT. Otherwise, that’s one solution that might work. If you got something in mind, I can try to help where I can.

Regards,
Saria

On 29 Sep 2020, at 4:00 pm, Jeremy Stretch notifications@github.com wrote:

This has been tagged "needs owner" for several months. If no one is interested in committing to the work, it will be closed. @MarcHagen @larsuhartmann are either of you volunteering to own the implementation?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

i would love to help with this, but my Python skills are just not up to the task, and this is a big "task/issue/feature". So sorry :(

Is there any way to "sponsor" someone to implement this feature?
We have the same situation at work: it would be nice to have this feature but none of us have the skills to implement it :-\

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benjy44 picture benjy44  Â·  3Comments

cloos picture cloos  Â·  3Comments

aarjbdea picture aarjbdea  Â·  3Comments

bellwood picture bellwood  Â·  4Comments

markve-sa picture markve-sa  Â·  4Comments