Ad Widget

Collapse

Suggestion: natsort()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ekenberg
    Junior Member
    • Mar 2006
    • 21

    #1

    Suggestion: natsort()

    Please consider using natsort() or something similar in the PHP frontend, when displaying lists of hosts etc. For instance, a list of hosts named www1, www2, ..., www100 should not be displayed as currently:

    www1
    www10
    www100
    www11
    ...

    but instead
    www1
    www2
    www3
    ...

    The above is a real life example taken from my current drop down host list in /items.php, using Zabbix version 1.4.1

    Thank you for continously improving Zabbix and listening to user requests, you're doing a great job!
  • Foxi
    Junior Member
    • Apr 2007
    • 7

    #2
    Patch to natsort

    Hi,

    I'm at present working on ZEC(Zabbix esay config) http://zec.woueb.fr
    Natsorting is already included in ZEC next release.
    Here some code to natsort from ZEC:

    search the following line in files hosts.php, items.php ... :
    $result=DBselect($sql);

    After this line, add thes lines:

    $sort_by = 'host'; // if you want to sort by host
    $natsorted_array = array();
    $all_hosts = array();
    while($row=DBfetch($result)) {
    $all_hosts[] = $row;
    }
    foreach($all_hosts as $key => $a_host) {
    $natsorted_array[$key] = $a_host[$sort_by];
    }
    natsort($natsorted_array);
    $natsorted_rows =array();
    foreach($natsorted_array as $key => $value) {
    $natsorted_rows[$key] = $all_hosts[$key];
    }

    Then search the following line and comment it or delete it :
    // while($row=DBfetch($result))
    and replace by :
    foreach($natsorted_rows as $row)

    I hope it will help you, or help Zabbix developpers.

    Regards Salim Jendoubi
    Last edited by Foxi; 10-07-2007, 00:57. Reason: Correction

    Comment

    Working...