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

Prefix Utilization is Always 0% #1689

Closed
girlpunk opened this issue Nov 3, 2017 · 5 comments
Closed

Prefix Utilization is Always 0% #1689

girlpunk opened this issue Nov 3, 2017 · 5 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@girlpunk
Copy link

girlpunk commented Nov 3, 2017

Issue type

[ ] Feature request
[X] Bug report
[ ] Documentation

Environment

  • Python version: 3.5.3
  • NetBox version: 2.2.4

Description

Just noticed this after upgrading to the latest version and adding some new prefixes to subnet an existing prefix. After doing so, the utilization for the new prefixes shows the correct number of IPs, but the percentage is always 0%.
This appears to be caused by the get_utilization() function's IPAddress filter.

Steps to reproduce

  1. Create a Prefix
  2. Add IPs to the prefix
  3. Subnet the prefix by adding a child prefix. The prefix correctly identifies the IPs already added, and shows them in the list and utilization count, but not the percentage.
@jeremystretch
Copy link
Member

Utilization is counted differently depending on whether the prefix is designated as a container:

    def get_utilization(self):
        """
        Determine the utilization of the prefix and return it as a percentage. For Prefixes with a status of
        "container", calculate utilization based on child prefixes. For all others, count child IP addresses.
        """

Which type of prefix are you looking at?

@girlpunk
Copy link
Author

girlpunk commented Nov 6, 2017

The Utilization on the child prefixes is the one I'm looking at. I've already set the parent to a container, and its utilization is showing correctly. The top child prefix in the screenshot below (192.168.42.0/27) has 10 IPs assigned, so should be showing about 30% usage.

image

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application and removed awaiting reply labels Nov 6, 2017
@jeremystretch
Copy link
Member

I think I see what's happening. Did you create those ten IPs with a mask larger than /27 (e.g. /24)? If so, the net_contained_or_equal filter won't count them (because a /24 obviously cannot be contained by a /27). Granted, we probably want to see all IPs within a prefix even if their masks are "wrong." I'm going to change the lookup to net_host_contained, which will return all IPs in the given prefix regardless of mask. Hopefully this won't break anything for people; I can't think of a situation where it would.

@girlpunk
Copy link
Author

girlpunk commented Nov 6, 2017

Yes, the IPs were created with /24, because that's the mask in use by the hosts (the subnetting is just for allocation and organisation). That would make sense as to why they're not detected then. Does the count on the prefix page use the net_host_contained function, as that is correct?

@jeremystretch
Copy link
Member

@cyberjacob Yes, the count was using net_host_contained but the get_utilization() method on the prefix was using net_contained_or_equal.

jeremystretch added a commit that referenced this issue Nov 6, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants