mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-11 21:10:29 +01:00
Power utilization not calculated over cascaded devices/PDU #2765
Closed
opened 2025-12-29 18:21:51 +01:00 by adam
·
34 comments
No Branch/Tag Specified
main
update-changelog-comments-docs
feature-removal-issue-type
20911-dropdown
20239-plugin-menu-classes-mutable-state
21097-graphql-id-lookups
feature
fix_module_substitution
20923-dcim-templates
20044-elevation-stuck-lightmode
feature-ip-prefix-link
v4.5-beta1-release
20068-import-moduletype-attrs
20766-fix-german-translation-code-literals
20378-del-script
7604-filter-modifiers-v3
circuit-swap
12318-case-insensitive-uniqueness
20637-improve-device-q-filter
20660-script-load
19724-graphql
20614-update-ruff
14884-script
02496-max-page
19720-macaddress-interface-generic-relation
19408-circuit-terminations-export-templates
20203-openapi-check
fix-19669-api-image-download
7604-filter-modifiers
19275-fixes-interface-bulk-edit
fix-17794-get_field_value_return_list
11507-show-aggregate-and-rir-on-api
9583-add_column_specific_search_field_to_tables
v4.5.0
v4.4.10
v4.4.9
v4.5.0-beta1
v4.4.8
v4.4.7
v4.4.6
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.3.7
v4.4.0-beta1
v4.3.6
v4.3.5
v4.3.4
v4.3.3
v4.3.2
v4.3.1
v4.3.0
v4.2.9
v4.3.0-beta2
v4.2.8
v4.3.0-beta1
v4.2.7
v4.2.6
v4.2.5
v4.2.4
v4.2.3
v4.2.2
v4.2.1
v4.2.0
v4.1.11
v4.1.10
v4.1.9
v4.1.8
v4.2-beta1
v4.1.7
v4.1.6
v4.1.5
v4.1.4
v4.1.3
v4.1.2
v4.1.1
v4.1.0
v4.0.11
v4.0.10
v4.0.9
v4.1-beta1
v4.0.8
v4.0.7
v4.0.6
v4.0.5
v4.0.3
v4.0.2
v4.0.1
v4.0.0
v3.7.8
v3.7.7
v4.0-beta2
v3.7.6
v3.7.5
v4.0-beta1
v3.7.4
v3.7.3
v3.7.2
v3.7.1
v3.7.0
v3.6.9
v3.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r1
v1.0.3
1.0.0
Labels
Clear labels
beta
breaking change
complexity: high
complexity: low
complexity: medium
needs milestone
netbox
pending closure
plugin candidate
pull-request
severity: high
severity: low
severity: medium
status: accepted
status: backlog
status: blocked
status: duplicate
status: needs owner
status: needs triage
status: revisions needed
status: under review
topic: GraphQL
topic: Internationalization
topic: OpenAPI
topic: UI/UX
topic: cabling
topic: event rules
topic: htmx navigation
topic: industrialization
topic: migrations
topic: plugins
topic: scripts
topic: templating
topic: testing
type: bug
type: deprecation
type: documentation
type: feature
type: housekeeping
type: translation
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/netbox#2765
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @resource-not-found-blank on GitHub (Jul 30, 2019).
Environment
Steps to Reproduce
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.
@larsuhartmann commented on GitHub (Sep 16, 2019):
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..
@roblarose commented on GitHub (Oct 3, 2019):
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
@jeremystretch commented on GitHub (Oct 17, 2019):
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?
@larsuhartmann commented on GitHub (Oct 19, 2019):
We could switch our Netbox instance to a beta branch to test it out - no problem!
@jeremystretch commented on GitHub (Oct 21, 2019):
@larsuhartmann not beta testing, actually committing to doing the work.
@andrewcleveland commented on GitHub (Nov 25, 2019):
@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).
@stale[bot] commented on GitHub (Dec 9, 2019):
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.
@chas0rde commented on GitHub (Dec 10, 2019):
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
@hSaria commented on GitHub (Dec 16, 2019):
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.
@stale[bot] commented on GitHub (Dec 30, 2019):
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.
@phurrelmann commented on GitHub (Dec 30, 2019):
@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.
@hSaria commented on GitHub (Jan 12, 2020):
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
UNIONinstead ofUNION 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.
@roblarose commented on GitHub (Jan 13, 2020):
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:
@hSaria commented on GitHub (Jan 14, 2020):
@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.
@phurrelmann commented on GitHub (Jan 14, 2020):
@hSaria, thank you. I'm eager to test this :)
@roblarose commented on GitHub (Jan 14, 2020):
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:
@Blackraz0r commented on GitHub (Jan 21, 2020):
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 ?
@stale[bot] commented on GitHub (Feb 4, 2020):
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.
@roblarose commented on GitHub (Feb 4, 2020):
Looks like jeremystretch already intercepted this but yeah please don't let this go stale/wontfix. I'm eagerly awaiting!
@phurrelmann commented on GitHub (Feb 4, 2020):
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
@phurrelmann commented on GitHub (Feb 4, 2020):
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.
@roblarose commented on GitHub (Feb 4, 2020):
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
@jeremystretch commented on GitHub (Feb 5, 2020):
@roblarose No, it hasn't been implemented yet. I believe @phurrelmann means that he tried out the pull request submitted by @hSaria above.
@roblarose commented on GitHub (Feb 5, 2020):
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:
@RHuehne commented on GitHub (Jul 6, 2020):
is this topic still being focused by the developers or won't this be fixed?
Thank you.
@stale[bot] commented on GitHub (Sep 29, 2020):
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.
@MarcHagen commented on GitHub (Sep 29, 2020):
Please do not close this. still needing this function
@larsuhartmann commented on GitHub (Sep 29, 2020):
Same here! It would be really nice to have this!
@jeremystretch commented on GitHub (Sep 29, 2020):
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?
@hSaria commented on GitHub (Sep 29, 2020):
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
@MarcHagen commented on GitHub (Sep 29, 2020):
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 :(
@larsuhartmann commented on GitHub (Oct 8, 2020):
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 :-\
@stale[bot] commented on GitHub (Oct 24, 2020):
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.
@Starkstromkonsument commented on GitHub (Jan 2, 2021):
The function required for the calculation seems to be already implemented at
b2e05aafc1/netbox/dcim/models/device_components.py (L327)It is called by Power Feeds (for Power Utilization)
872ba89cad/netbox/templates/dcim/powerfeed.html (L111)and Racks (for Power Utilization)
4ce7dfa55e/netbox/templates/dcim/rack.html (L249)There is another call for devices ("Power Utilization" panel)
872ba89cad/netbox/templates/dcim/device.html (L221)Edit 1: I'm trying to understand the code of the current power calculation and noticed that the above "Power Utilization" panel of a device page is never shown, although they have both power ports and power outlets defined. A fixed issue (#5184) about this already exists, but it does not seem to work (anymore?). Am I misunderstanding something here or should I file a new issue about this?
I opt for reopening #3782 to prevent power loops (I can't see a valuable use case. Electrical power circuits should always be protected by corresponding fuses/switchgears. Building loops or interconnecting different circuits ends up in a mess and can get very dangerous in case of a fault. This is what devices with multiple PSUs are built for.) and use the existing function
get_power_drawrecursively for power ports connected to power outlets.But I regret, I don't have sufficient python skills so far to do so either :-(
Edit 2: I apologize, I misunderstood the current point of this discussion. I did not read the two PRs related to this issue first of writing my comment. The last posts of this issue gave me the impression, that most of the work to fix this still has to be done. But wow, PR #4226 already contains a piece of very hard work!
It seems like this issue is currently stuck mainly because of loop and performance concerns. How can one help to solve these?