Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Status > Queues display order for HFSC-based traffic shaping

    Scheduled Pinned Locked Moved Traffic Shaping
    2 Posts 1 Posters 844 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      basisau
      last edited by

      Is there a way to configure the display order of queues on the Status > Queues page, even if by editing files through SSH rather than using the Web Admin UI?

      We currently have 40 HFSC queues/subqueues spanning 2 WANs, 1 DMZ, 4 LANs and 3 other private network segments used for routing. All queues are working fine for managing both inbound and outbound bandwidth sharing on both WAN links.

      We recently added the 4th LAN segment and hence configured the appropriate queues and floating rules - again, all of that is working, this is only a question about display order.

      The problem we'd like to solve is to see all the LAN queues display adjacent to each other on the Queues page as it's much easier to interpret at a glance that way. Right now the queues for the 4th LAN are at the very bottom of the list of queues per interface, only because they were created after all the other queues. Meanwhile the queues for all other LANs are near the top of the list because they were created first.

      So, the question is, can the display order of queues be changed or is it strictly set by the order in which they were created? Being able to set the order manually, or even specify display alphabetically would be great.

      Thanks in advance for any tips!

      B 1 Reply Last reply Reply Quote 0
      • B
        basisau @basisau
        last edited by

        Self-solved. Wrote two new functions in status_queues.php and added a call to SortStats in the existing processInterfaceQueues call:

        processInterfaceQueues(SortStats($stats), 0, "");
        
        

        Code is not so elegant and is not optimised but it works. Sharing for interest.

        function SortStats_AppendCurrentAndContained(&$sorted_qname, &$raw_real_if_qlist, $qname, &$qdata, &$qcontains)
        {
        	# Sort the list of child queue names and store back into the original 'contains' array
        	sort($qcontains);
        	$qdata['contains'] = $qcontains;
        
        	# Add the current qname (which 'contains' other queues) to the sorted_qname array first
        	$sorted_qname[$qname] = $qdata;
        
        	# Then add the contained queues, in sorted order
        	foreach ($qcontains as $qcontainedname)
        	{
        		# Retrieve the queue entry for the named queue
        		$qcontained = $raw_real_if_qlist[$qcontainedname];
        
        		# If it has a 'contains' array, recurse the addition of current & contained queues
        		if (is_array($qcontained['contains']))
        		{
        			SortStats_AppendCurrentAndContained($sorted_qname, $raw_real_if_qlist, $qcontainedname, $qcontained, $qcontained['contains']);
        		}
        		else
        		{
        			# Add the queue data for the named qcontained into the sorted_qname array
        			$sorted_qname[$qcontainedname] = $qcontained;
        		}
        	}
        }
        
        function SortStats($stats_to_sort)
        {
        	foreach ($stats_to_sort['interfacestats'] as $raw_real_if_name => $raw_real_if_qlist)
        	{
        		$sorted_qname = array();
        		foreach ($raw_real_if_qlist as $qname => $qdata)
        		{
        			# If it has a 'contains' array, sort the children and build out the sorted_real_if_qlist
        			if (is_array($qdata['contains']))
        			{
        				# Append the current and contained queues
        				SortStats_AppendCurrentAndContained($sorted_qname, $raw_real_if_qlist, $qname, $qdata, $qdata['contains']);
        			}
        		}
        		# Assign the sorted array of queue names back to the raw_real_if_qlist
        		$stats_to_sort['interfacestats'][$raw_real_if_name] = $sorted_qname;
        	}
        	return $stats_to_sort;
        }
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.