Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong rounding in rack-level power utilization figure #12838

Closed
candlerb opened this issue Jun 8, 2023 · 0 comments · Fixed by #12839
Closed

Wrong rounding in rack-level power utilization figure #12838

candlerb opened this issue Jun 8, 2023 · 0 comments · Fixed by #12839
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@candlerb
Copy link
Contributor

candlerb commented Jun 8, 2023

NetBox version

v3.5.3

Python version

3.8

Steps to Reproduce

  1. Create a power feed and some devices in a rack, such that the power utilization on the power feed is 2.5% - specific instructions in discussion Documenting the "power utilization" features of Netbox #12837
  2. Look at the power feed utilization
  3. Look at the rack level power utilization

Expected Behavior

Both to show the same

Observed Behavior

Power-feed utilization shows as "2.5%"

But rack-level utilization power shows as "2.0%"

The problem is that percentage() in netbox/utilities/templatetags/helpers.py rounds to nearest 0.1%

return round(x / y * 100, 1)

Whereas Rack.get_power_utilization in netbox/dcim/models/racks.py rounds down to integer:

return int(allocated_draw / available_power_total * 100)
@candlerb candlerb added the type: bug A confirmed report of unexpected behavior in the application label Jun 8, 2023
candlerb added a commit to candlerb/netbox that referenced this issue Jun 8, 2023
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Jun 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants