Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-23921

"Top Hosts" widget makes sorting Backwards by default

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 6.4.10, 7.0.0alpha9
    • Frontend (F)
    • None

      Steps to reproduce:

      1. Add a couple of hosts, link to a template with numeric values
      2. create a top hosts widget
      3. Add a column for some numeric metric and leave the "Aggregation function" as 'none', and "Display" as "As is" and don't add any thresholds.
      4. The values appear to be sorted the opposite of what you'd expect based on the sorting option
      5. For an array of values ('500', '21', '104', '53'); TopN sorting results in an ascending sort where the ordering becomes 21, 53, 104, 500. 

       

      It appears that self::isNumericOnlyColumn($master_column) could use some work. For the metric I'm plotting its a known numeric item type, But it looks like that function expects that the display is not "As is" or the aggregation function is nont "none". 

       

      I think, unless I'm missing something here, the sorting logic is backwards in this block when doing SORT_NATURAL:

       

      		if ($this->fields_values['order'] == Widget::ORDER_TOP_N) {
      			if ($master_items_only_numeric_present) {
      				arsort($master_item_values, SORT_NUMERIC);
      				$master_items_min = end($master_item_values);
      				$master_items_max = reset($master_item_values);
      			}
      			else {
      				asort($master_item_values, SORT_NATURAL);
      			}
      		}
      		else {
      			if ($master_items_only_numeric_present) {
      				asort($master_item_values, SORT_NUMERIC);
      				$master_items_min = reset($master_item_values);
      				$master_items_max = end($master_item_values);
      			}
      			else {
      				arsort($master_item_values, SORT_NATURAL);
      			}
      		} 

            zabbix.dev Zabbix Development Team
            GRyan337 Ryan Eberly
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: