Wrong rounding in rack-level power utilization figure #8173

Closed
opened 2025-12-29 20:33:27 +01:00 by adam · 0 comments
Owner

Originally created by @candlerb on GitHub (Jun 8, 2023).

Originally assigned to: @candlerb on GitHub.

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 #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)
Originally created by @candlerb on GitHub (Jun 8, 2023). Originally assigned to: @candlerb on GitHub. ### 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 #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%" ![](https://user-images.githubusercontent.com/44789/244380583-33a6e41e-2c5a-41fa-9744-4df1e386cab3.png) But rack-level utilization power shows as "2.0%" ![](https://user-images.githubusercontent.com/44789/244382228-41acdf97-60e4-4e2c-a3ac-802ee4809d37.png) 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) ```
adam added the type: bugstatus: accepted labels 2025-12-29 20:33:27 +01:00
adam closed this issue 2025-12-29 20:33:27 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8173