Uploaded image for project: 'Observium'
  1. Observium
  2. OBS-978

Port details page requires lots of RAM for hosts with > 100 IP addresses

Details

    • Bug
    • Resolution: Fixed
    • Major
    • None
    • None
    • Web Interface
    • CentOS 5.9

    Description

      My php.ini limits RAM to 128MB.
      When I try to look at the details page of a host with 511 IP addresses on eth0, the page fails to load and returns a 500.
      If I bump the RAM limits to 512MB it renders, and the Apache process consumes 384MB.
      Looking into the code, it appears to be coming from includes/print-interface.inc.php, about line 248:
      $int_links_v4[$new['port_id']][] = $new['ipv4_network'];
      If I remove the "[]" and make the line:
      $int_links_v4[$new['port_id']] = $new['ipv4_network'];
      Everything seems to work correctly, without needing gobs of RAM to render.

      Unrelated to that issue, I observed that for the IPv6 code with the same purpose on line 266, $new['port_id'] is assigned rather than $new['ipv4_network']. I have no idea if this is a bug, but it doesn't fix the memory issue, and doesn't appear to change the page when I remove the "[]".

      Attachments

        Activity

          [OBS-978] Port details page requires lots of RAM for hosts with > 100 IP addresses
          landy Mike Stupalov made changes -
          Workflow Original: classic default workflow [ 11838 ] New: Observium workflow [ 14250 ]
          landy Mike Stupalov made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]
          landy Mike Stupalov made changes -
          Assignee Original: Adam Armstrong [ adama ] New: Mike Stupalov [ landy ]
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          Fixed in r5763.

          landy Mike Stupalov added a comment - Fixed in r5763.
          awheeler Alex Wheeler added a comment - - edited

          Found the "real" problem – the mysql queries are returning duplicate rows, so, by throwing a DISTINCT into the query:

          foreach (dbFetchRows("SELECT DISTINCT `ipv4_network_id` FROM `ipv4_addresses` WHERE `port_id` = ? AND `ipv4_address` NOT LIKE '127.%'", array($port['port_id'])) as $net)
          {
          $sql = "SELECT DISTINCT N.*, P.`port_id`, P.`device_id` FROM `ipv4_addresses` AS A, `ipv4_networks` AS N, `ports` AS P
          WHERE A.`port_id` = P.`port_id` AND P.`device_id` != ?
          AND A.`ipv4_network_id` = ? AND N.`ipv4_network_id` = A.`ipv4_network_id`
          AND P.`ifAdminStatus` = 'up'";

          And reverting back to your original [], all is working as it should.

          awheeler Alex Wheeler added a comment - - edited Found the "real" problem – the mysql queries are returning duplicate rows, so, by throwing a DISTINCT into the query: foreach (dbFetchRows("SELECT DISTINCT `ipv4_network_id` FROM `ipv4_addresses` WHERE `port_id` = ? AND `ipv4_address` NOT LIKE '127.%'", array($port ['port_id'] )) as $net) { $sql = "SELECT DISTINCT N.*, P.`port_id`, P.`device_id` FROM `ipv4_addresses` AS A, `ipv4_networks` AS N, `ports` AS P WHERE A.`port_id` = P.`port_id` AND P.`device_id` != ? AND A.`ipv4_network_id` = ? AND N.`ipv4_network_id` = A.`ipv4_network_id` AND P.`ifAdminStatus` = 'up'"; And reverting back to your original [], all is working as it should.
          awheeler Alex Wheeler added a comment - - edited

          OK. When I re-enable the functionality, I now see that when I mouse over the IPv4 on a server with 10 IP addresses on one port, I see a list of that ports subnet repeated 37K times. So, there's the source of the memory issue.
          Clearly that value is greater when there are more addresses.
          On a server with one IP on a port, the subnet is listed just once.
          With the change I proposed, none are listed, so clearly that's not a good solution, just as you suggest.
          If I change the line to this:

          $int_links_v4[$new['port_id']][$new['ipv4_network']] = $new['ipv4_network'];

          everything seems to work correctly, for servers with any number of IPs.
          Assuming this change is the right one, the IPv6 line might need to be:

          $int_links_v6[$new['port_id']][$new['ipv6_network']] = $new['ipv6_network'];

          awheeler Alex Wheeler added a comment - - edited OK. When I re-enable the functionality, I now see that when I mouse over the IPv4 on a server with 10 IP addresses on one port, I see a list of that ports subnet repeated 37K times. So, there's the source of the memory issue. Clearly that value is greater when there are more addresses. On a server with one IP on a port, the subnet is listed just once. With the change I proposed, none are listed, so clearly that's not a good solution, just as you suggest. If I change the line to this: $int_links_v4[$new ['port_id'] ][$new ['ipv4_network'] ] = $new ['ipv4_network'] ; everything seems to work correctly, for servers with any number of IPs. Assuming this change is the right one, the IPv6 line might need to be: $int_links_v6[$new ['port_id'] ][$new ['ipv6_network'] ] = $new ['ipv6_network'] ;

          You've simply introduced a bug where the page can no longer keep track of what ports have already been displayed.

          adama Adam Armstrong added a comment - You've simply introduced a bug where the page can no longer keep track of what ports have already been displayed.
          awheeler Alex Wheeler created issue -

          People

            landy Mike Stupalov
            awheeler Alex Wheeler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: