Ad Widget

Collapse

WIP: Custom Dashboard

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • billb
    Junior Member
    • Nov 2012
    • 14

    #31
    The dashboard looks great. I have installed both files and when browsing the page, I get no errors, just under each block it says "loading..." but no data loads.

    Any ideas how to get this working? Sorry I am fairly new to Zabbix.

    Thank!

    Comment

    • jix
      Member
      • Feb 2011
      • 73

      #32
      !

      it says "loading..." but no data loads.
      Same Problem here

      Comment

      • eskytthe
        Senior Member
        Zabbix Certified Specialist
        • May 2011
        • 363

        #33
        Most likely you do not have any items matching the default setup.
        You need to go to the setup page - click icon at right side, upper corner (like at the dashboard page). Enter key string of items or part of item description.

        Remark that you have to correct the top10conf.php file - post no. 28 in this thread:
        "Did resolve problem with top10conf.php - the file did have same content 2 times (same content after line 614)"

        Br
        Erik

        Comment

        • billb
          Junior Member
          • Nov 2012
          • 14

          #34
          I have got to another stage now. This is what I did:

          1. unzipped the top10.tar file
          2. installed top10.php. top10.inc.php, class.pmastertop10.js and top10conf.php
          3. removed extra lines from top10conf.php
          4. edited jsLoader.php and menu.inc.php as per post 23

          I now just get a blank page when accessing top10.php.

          Is there anything i am missing. I am running version v1.8.11 which is perhaps the problem

          Thanks!

          Comment

          • danrog
            Senior Member
            • Sep 2009
            • 164

            #35
            Yes...this version will only work with 2.0 (2.0.3 and 2.0.4rc1). The older version in the first post will work with 1.8 (but its missing some of the newer features of this 2.0 version). You would have to manually edit the top10.php for the 1.8 version to use your item key format. I've pretty much stopped all my 1.8 development as we are upgrading to 2.0 in the next week or two. I am planning on releasing a 'complete install' package for this and maybe a few other customizations I have written before Christmas.

            Just a note on some of the customizations in order of my planned release:
            1. This dashboard
            2. IT Services graphical view (using GoJS - http://gojs.net/latest/index.html)
            3. HTML5 SSH client
            4. HTML5 RDP/VNC client
            5. A few other smaller items

            Comment

            • r.achter
              Junior Member
              • Apr 2013
              • 1

              #36
              Modification to see item key

              Hello there,
              Very useful Dashboard!
              i got it running using the information from Posts #23,#27 and #28

              i tried to show Top interface utilization of switches. There where multiple interfaces of the same host and there was no way to indentify WHICH Interface is seen there.
              Information was like this
              Switch1 : 100 MBps
              Switch1 : 90 MBps
              Switch1 : 70 MBps
              ....
              So i decided to include the item KEY in the top 10 Dashboard.
              These are my modifications to top10.inc.php

              PHP Code:
              //...
                   
              $table  = new CTableInfo();
                   
              $table->setHeader(array(
                       
              is_show_all_nodes() ? _('Node') : null,
                       
              _('Host'),
              //New Header "Key"
                      
              _('Key'),
                       
              _('Value')
                   ));
              //...
              //...

              //inclusion of column i.key_ in query
              $history_sql =     ' SELECT avg( h.value ) AS avg, hs.host, i.itemid, i.key_, i.units, i.description '.
                                   
              ' FROM '.$qtable.' h '.
                                   
              '  LEFT JOIN items i ON h.itemid = i.itemid '.
                                   
              '  LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
              //...

              //configuration of new column for output
              $col2 = (empty($label))? new CCol($row['key_'],$sstyle) : new CCol(ShortenText($row['description']), $sstyle);
              $col3 = new CCol($val,$sstyle);

              //...
              //Formatting of columns
              $col2->setWidth('230');
              $col3->setWidth('70');
              //...

              //Inclusion of additional column to table
              $table->addRow(array(
                           
              $col1,
                          
              $col2,
                          
              $col3
                       
              )); 

              Now we have

              Switch1 : ifInOctets[Port 1] : 100 MBps
              Switch1 : ifInOctets[Port 2] : 90 MBps
              Switch1 : ifInOctets[Port 3] :70 MBps

              My modified top10.inc.php is attached
              Attached Files

              Comment

              • Robert.hau
                Junior Member
                Zabbix Certified Specialist
                • Jun 2010
                • 10

                #37
                Good things to add into this

                This section will change the popup if its numeric or text based. Good to show logs.
                Code:
                                        if(is_numeric($row['lastvalue'])) {
                                                $img = new CImg('chart.php?width=500&height=100&period='.$qtable_period.'&itemid='.$row['itemid'].'&stime='.$qtable_time);
                                                $table_inf->addRow(array(new CCol($img, 'pointer')));
                                        } else {
                                                $text= new CIFrame('history.php?itemid[0]='.$row['itemid'].'&action=showvalues&period='.$qtable_period.'&plaintext=As+plain+text&stime='.$qtable_time, $qtable_width, $qtable_height, 'yes' );
                                                $table_inf->addRow(array(new CCol($text, 'pointer')));
                                        };
                Also this code works faster since it returns the last value not the average value for the last hour. The problem with average for the last hour is it will not show values for items not updating within at least an hour.

                Code:
                        switch($type){
                                case ITEM_VALUE_TYPE_FLOAT:
                                        $qtable = "history";
                                        if (isset($GroupBy)) {
                                        $history_sql =  ' SELECT i.lastclock, i.status, i.name, SUM(i.lastvalue) as lastvalue, hs.host, i.itemid, i.units '.
                                                        ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                        ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                        ' AND i.lastvalue IS NOT NULL '.
                                                        ' AND i.status = 0 '.
                                                        ' GROUP by '.$GroupBy.
                                                        ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;
                                        } else {
                                        $history_sql =  ' SELECT i.lastclock, i.status, i.name, CAST(i.lastvalue AS unsigned) as lastvalue , hs.host, i.itemid, i.units '.
                                                        ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                        ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                        ' AND i.lastvalue IS NOT NULL '.
                                                        ' AND i.status = 0 '.
                                                        ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;
                                        };
                                        $qtable_width = "600";
                                        $qtable_height= "200";
                                        $qtable_period= "21600";
                                        break;
                                case ITEM_VALUE_TYPE_UINT64:
                                        $qtable = "history_uint";
                                        if (isset($GroupBy)) {
                                        $history_sql =  ' SELECT i.lastclock, i.status, i.name, SUM(i.lastvalue) as lastvalue, hs.host, i.itemid, i.units '.
                                                        ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                        ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                        ' AND i.lastvalue IS NOT NULL '.
                                                        ' AND i.status = 0 '.
                                                        ' GROUP by '.$GroupBy.
                                                        ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;
                                        } else {
                                        $history_sql =  ' SELECT i.lastclock, i.status, i.name, CAST(i.lastvalue AS unsigned) as lastvalue , hs.host, i.itemid, i.units '.
                                                        ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                        ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                        ' AND i.lastvalue IS NOT NULL '.
                                                        ' AND i.status = 0 '.
                                                        ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;
                                        };
                                        $qtable_width = "600";
                                        $qtable_height= "200";
                                        $qtable_period= "21600";
                                        break;
                                case ITEM_VALUE_TYPE_TEXT:
                                        $qtable = "history_text";
                                        $history_sql =  ' SELECT i.lastclock, i.status, i.name, i.lastvalue, hs.host, i.itemid, i.units '.
                                                        ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                        ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                        //              ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                        ' AND i.lastvalue IS NOT NULL '.
                                                        ' AND i.status = 0 '.
                                                        ' ORDER BY i.lastvalue '.$order;
                                        $qtable_width = "600";
                                        $qtable_height= "200";
                                        $qtable_period= "43200";
                                        break;
                                case ITEM_VALUE_TYPE_STR:
                                        $qtable = "history_str";
                                        $history_sql =  ' SELECT i.lastclock, i.status, i.name, i.lastvalue, hs.host, i.itemid, i.units '.
                                                        ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                        ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                        //              ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                        ' AND i.lastvalue IS NOT NULL '.
                                                        ' AND i.status = 0 '.
                                                        ' ORDER BY i.lastvalue '.$order;
                                        $qtable_width = "600";
                                        $qtable_height= "200";
                                        $qtable_period= "43200";
                                        break;
                                case ITEM_VALUE_TYPE_LOG:
                                default:
                                        $qtable = "history_log";
                                        $history_sql =  ' SELECT i.lastclock, i.status, i.name, i.lastvalue, hs.host, i.itemid, i.units '.
                                                        ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                        ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                        //              ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                        ' AND i.lastvalue IS NOT NULL '.
                                                        ' AND i.status = 0 '.
                                                        ' ORDER BY i.lastclock '.$order;
                                        $qtable_width = "1100";
                                        $qtable_height= "200";
                                        $qtable_period= "43200";
                                        break;
                                }
                I hope this helps you.

                RH

                Comment

                • billb
                  Junior Member
                  • Nov 2012
                  • 14

                  #38
                  Hi Robert.hau

                  Thanks for your last post - exactly what I am looking for. I cant quite get it working. I want to show last value for all my top 10s. Currently everything defaults to the default in top10.inc.php:
                  $history_sql = ' SELECT avg( h.value ) AS avg, hs.host, i.itemid, i.units, i.description '.
                  ' FROM '.$qtable.' h '.
                  ' LEFT JOIN items i ON h.itemid = i.itemid '.
                  ' LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                  ' WHERE h.itemid IN ('.implode(",",$itemids).') '.
                  ' AND h.clock >= unix_timestamp(timestampadd(hour,"-'.$hoursback.'",now())) '.
                  ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                  ' GROUP BY h.itemid '.
                  ' ORDER BY avg '.$order;


                  I have put in place the case statements but dont know where to put in your first block of code.
                  Thanks!

                  Comment

                  • Robert.hau
                    Junior Member
                    Zabbix Certified Specialist
                    • Jun 2010
                    • 10

                    #39
                    updated top10.inc.php

                    Try using the top10.inc.php

                    It should work properly

                    Code:
                    <?php
                    /*
                    ** This program is free software; you can redistribute it and/or modify
                    ** it under the terms of the GNU General Public License as published by
                    ** the Free Software Foundation; either version 2 of the License, or
                    ** (at your option) any later version.
                    **
                    ** This program is distributed in the hope that it will be useful,
                    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
                    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                    ** GNU General Public License for more details.
                    **
                    ** You should have received a copy of the GNU General Public License
                    ** along with this program; if not, write to the Free Software
                    ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                    **/
                    ?>
                    <?php
                    require_once('include/users.inc.php');
                    require_once('include/config.inc.php');
                    
                    
                    function make_top10($filter, $description, $maxvalue, $order, $label=0, $hoursback=2){
                            $field = 'name';
                    
                            $table  = new CTableInfo();
                            $table->setHeader(array(
                                    is_show_all_nodes() ? _('Node') : null,
                                    _('Host'),
                                    _('Value')
                            ));
                    
                            // get hosts
                            $options = array(
                                            'nodeids' => get_current_nodeid(),
                                            'groupids' => zbx_objectValues($filter['groupids'], 'groupid'),
                                            'monitored_hosts' => 1,
                                            'filter' => array('maintenance_status' => $filter['maintenance']),
                                            'output' => array('hostid', 'name')
                            );
                            $hosts = API::Host()->get($options);
                            $hostids = zbx_objectValues($hosts, 'hostid');
                    
                    //      if(preg_match('/^'.ZBX_PREG_ITEM_KEY_FORMAT.'$/u', $description) ){
                    //              $field = 'key_';
                    //      }
                    
                            //Item by descrption
                            $iquery =       'SELECT itemid, value_type '.
                                            ' FROM items '.
                                            ' WHERE '.$field.' LIKE "'.$description.'"'.
                                            '  AND hostid IN ('.implode(",",$hostids).') ';
                            $icursor = DBselect($iquery);
                            while($row = DBfetch($icursor)) {
                                    $itemids[]      = $row['itemid'];
                                    $type           = $row['value_type'];
                            }
                    
                        if(!isset($type)) { return $table; }
                    /*
                            switch($type){
                                    case ITEM_VALUE_TYPE_FLOAT:
                                                    $qtable = "history";
                                                    break;
                                    case ITEM_VALUE_TYPE_UINT64:
                                                    $qtable = "history_uint";
                                                    break;
                                    case ITEM_VALUE_TYPE_TEXT:
                                                    $qtable = "history_text";
                                                    break;
                                    case ITEM_VALUE_TYPE_STR:
                                                    $qtable = "history_str";
                                                    break;
                                    case ITEM_VALUE_TYPE_LOG:
                                    default:
                                                    $qtable = "history_log";
                                                    break;
                        }
                    
                    
                            $history_sql =  ' SELECT avg( h.value ) AS avg, hs.host, i.itemid, i.units, i.description '.
                                            ' FROM '.$qtable.' h '.
                                            '  LEFT JOIN items i ON h.itemid = i.itemid '.
                                            '  LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                            ' WHERE h.itemid IN ('.implode(",",$itemids).') '.
                                            '  AND h.clock >= unix_timestamp(timestampadd(hour,"-'.$hoursback.'",now())) '.
                                            '  AND hs.hostid IN ('.implode(",",$hostids).') '.
                                            '  GROUP BY h.itemid '.
                                            '  ORDER BY avg '.$order;
                    */
                            switch($type){
                                    case ITEM_VALUE_TYPE_FLOAT:
                                            $qtable = "history";
                                            if (isset($GroupBy)) {
                                            $history_sql =  ' SELECT i.lastclock, i.status, i.name, SUM(i.lastvalue) as lastvalue, hs.host, i.itemid, i.units '.
                                                            ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                            ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                    //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                            ' AND i.lastvalue IS NOT NULL '.
                                                            ' AND i.status = 0 '.
                                                            ' GROUP by '.$GroupBy.
                                                            ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;
                                            } else {
                                            $history_sql =  ' SELECT i.lastclock, i.status, i.name, CAST(i.lastvalue AS unsigned) as lastvalue , hs.host, i.itemid, i.units '.
                                                            ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                            ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                    //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                            ' AND i.lastvalue IS NOT NULL '.
                                                            ' AND i.status = 0 '.
                                                            ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;
                                            };
                                            $qtable_width = "600";
                                            $qtable_height= "200";
                                            $qtable_period= "21600";
                                            break;
                                    case ITEM_VALUE_TYPE_UINT64:
                                            $qtable = "history_uint";
                                            if (isset($GroupBy)) {
                                            $history_sql =  ' SELECT i.lastclock, i.status, i.name, SUM(i.lastvalue) as lastvalue, hs.host, i.itemid, i.units '.
                                                            ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                            ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                    //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                            ' AND i.lastvalue IS NOT NULL '.
                                                            ' AND i.status = 0 '.
                                                            ' GROUP by '.$GroupBy.
                                                            ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;
                                            } else {
                                            $history_sql =  ' SELECT i.lastclock, i.status, i.name, CAST(i.lastvalue AS unsigned) as lastvalue , hs.host, i.itemid, i.units '.
                                                            ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                            ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                    //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                            ' AND i.lastvalue IS NOT NULL '.
                                                            ' AND i.status = 0 '.
                                                            ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;
                                            };
                                            $qtable_width = "600";
                                            $qtable_height= "200";
                                            $qtable_period= "21600";
                                            break;
                                    case ITEM_VALUE_TYPE_TEXT:
                                            $qtable = "history_text";
                                            $history_sql =  ' SELECT i.lastclock, i.status, i.name, i.lastvalue, hs.host, i.itemid, i.units '.
                                                            ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                            ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                            //              ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                            ' AND i.lastvalue IS NOT NULL '.
                                                            ' AND i.status = 0 '.
                                                            ' ORDER BY i.lastvalue '.$order;
                                            $qtable_width = "600";
                                            $qtable_height= "200";
                                            $qtable_period= "43200";
                                            break;
                                    case ITEM_VALUE_TYPE_STR:
                                            $qtable = "history_str";
                                            $history_sql =  ' SELECT i.lastclock, i.status, i.name, i.lastvalue, hs.host, i.itemid, i.units '.
                                                            ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                            ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                            //              ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                            ' AND i.lastvalue IS NOT NULL '.
                                                            ' AND i.status = 0 '.
                                                            ' ORDER BY i.lastvalue '.$order;
                                            $qtable_width = "600";
                                            $qtable_height= "200";
                                            $qtable_period= "43200";
                                            break;
                                    case ITEM_VALUE_TYPE_LOG:
                                    default:
                                            $qtable = "history_log";
                                            $history_sql =  ' SELECT i.lastclock, i.status, i.name, i.lastvalue, hs.host, i.itemid, i.units '.
                                                            ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                            ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                            //              ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                            ' AND i.lastvalue IS NOT NULL '.
                                                            ' AND i.status = 0 '.
                                                            ' ORDER BY i.lastclock '.$order;
                                            $qtable_width = "1100";
                                            $qtable_height= "200";
                                            $qtable_period= "43200";
                                            break;
                                    }
                            $res_history = DBSelect($history_sql,10);
                    
                            while($row=DBfetch($res_history)){
                                    if (is_numeric($row['lastvalue'])) {
                                            $value = convert_units($row['lastvalue'], $row['units']);
                                    } else {
                                            $value = $row['lastvalue'];
                                    };
                                    $val = new CSpan($value, 'pointer bold');
                    
                                    $table_inf = new CTableInfo();
                                    $table_inf->setAttribute('style', 'width: 610px;');
                                    $table_inf->setHeader(array(
                                                            is_show_all_nodes() ? _('Node') : null,
                                                            _('Host')
                                                    ));
                    /*
                                    $img = new CImg('chart.php?width=500&height=100&period=21600&itemid='.$row['itemid']);
                                    $table_inf->addRow(array(new CCol($img, 'pointer')));
                                    $table_inf->onClick("javascript: redirect('history.php?action=showgraph&itemid=".$row['itemid']."')");
                    */
                                            $qtable_time = date('YmdGis', time() - $qtable_period);
                                            $qtable_time = date('YmdGis', time() - $qtable_period);
                    
                                            if(is_numeric($row['lastvalue'])) {
                                                    $img = new CImg('chart.php?width=500&height=100&period='.$qtable_period.'&itemid='.$row['itemid'].'&stime='.$qtable_time);
                                                    $table_inf->addRow(array(new CCol($img, 'pointer')));
                                            } else {
                                                    $text= new CIFrame('history.php?itemid[0]='.$row['itemid'].'&action=showvalues&period='.$qtable_period.'&plaintext=As+plain+text&stime='.$qtable_time, $qtable_width, $qtable_height, 'yes' );
                                                    $table_inf->addRow(array(new CCol($text, 'pointer')));
                                            };
                                    $val->setHint($table_inf);
                    
                                    switch($order) {
                                            case 'DESC': $sstyle = ($row['lastvalue'] > (int)$maxvalue)? 'high':'normal'; break;
                                            case 'ASC': $sstyle  = ($row['lastvalue'] < (int)$maxvalue)? 'high':'normal'; break;
                                    }
                    
                                    $col1 = (empty($label))? new CCol($row['host'],$sstyle) : new CCol(ShortenText($row['description']), $sstyle);
                            $col2 = new CCol($val,$sstyle);
                    
                                    $col1->setWidth('230');
                                    $col2->setWidth('70');
                    
                                    $table->addRow(array(
                                            $col1,
                                            $col2
                                    ));
                            }
                    
                    return $table;
                    }
                    
                    
                    function ShortenText($text, $chars=25) {
                            $text = substr($text,0,$chars);
                            $text = $text."...";
                            return $text;
                    }
                    
                    ?>

                    Comment

                    • billb
                      Junior Member
                      • Nov 2012
                      • 14

                      #40
                      Brilliant - works perfectly!

                      Comment

                      • angelhc
                        Senior Member
                        Zabbix Certified Specialist
                        • Nov 2009
                        • 226

                        #41
                        Hello all!,
                        This is really good job!! Congrats!

                        Thanks in advance!
                        Last edited by angelhc; 04-07-2013, 14:38.
                        Number of hosts 1600,Number of items +90k,Number of triggers +22k, Number of users +100, New values per second +1270

                        http://zabbixes.wordpress.com/

                        Comment

                        • uid0
                          Junior Member
                          • Aug 2013
                          • 8

                          #42
                          Hi,

                          great modification - thanks a lot!

                          With the script of Robert.hau i can get the last values and everything works perfect. Just one problem: i cant get the load average. It always display '0'.
                          My item description is correct.

                          With original files it display a value, so there must be a problem at Robert.hau modification.

                          Could you please help me out?

                          Thanks a lot.
                          Attached Files

                          Comment

                          • Robert.hau
                            Junior Member
                            Zabbix Certified Specialist
                            • Jun 2010
                            • 10

                            #43
                            uid0,
                            I can confirm its not anything you did wrong, I actually see the same data.

                            What i can tell you is its getting that value from the SQL. The CAST option seems to be rounding the value. I can't remove it on myside cause it disrupts the sorting for other values. I hope this helps. If you figure out a workaround please let me know too.

                            $history_sql = ' SELECT i.lastclock, i.status, i.name, CAST(i.lastvalue AS unsigned) as lastvalue , hs.host, i.itemid, i.units '.
                            ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                            ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                            // ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                            ' AND i.lastvalue IS NOT NULL '.
                            ' AND i.status = 0 '.
                            ' ORDER BY CAST(i.lastvalue AS unsigned) '.$order;

                            Comment

                            • Robert.hau
                              Junior Member
                              Zabbix Certified Specialist
                              • Jun 2010
                              • 10

                              #44
                              uid0
                              AH HA, I found the issue. I was correct it was the mysql select statement.

                              Here is what the fix is. Let me know if that fixes your issue.
                              Code:
                                              case ITEM_VALUE_TYPE_FLOAT:
                                                      $qtable = "history";
                                                      if (isset($GroupBy)) {
                                                      $history_sql =  ' SELECT i.lastclock, i.status, i.name, [B]CAST(i.lastvalue AS DECIMAL(65,4))[/B] as lastvalue, hs.host, i.itemid, i.units '.
                                                                      ' FROM items i LEFT JOIN hosts hs ON i.hostid = hs.hostid '.
                                                                      ' WHERE i.itemid IN ('.implode(",",$itemids).') '.
                                                              //      ' AND hs.hostid IN ('.implode(",",$hostids).') '.
                                                                      ' AND i.lastvalue IS NOT NULL '.
                                                                      ' AND i.status = 0 '.
                                                                      ' GROUP by '.$GroupBy.
                              [B]                                        ' ORDER BY CAST(i.lastvalue AS DECIMAL(65,4)) [/B]'.$order;

                              Comment

                              • uid0
                                Junior Member
                                • Aug 2013
                                • 8

                                #45
                                Hello Robert,

                                cool, cool, cool. Thanks so much Works perfect.

                                Comment

                                Working...