XMLWordPrintable

    • Icon: Change Request Change Request
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • Frontend (F)
    • None

      Adding additional columns to the items page that display the last time and last value for each item. 

      It's VERY useful for administering new agents and configuring new metrics.

       

      the changes to items.php

      /*
       * Display
       */
      if (isset($_REQUEST['form']) && str_in_array($_REQUEST['form'], ['create', 'update', 'clone'])) {
       $master_item_options = [];
       $has_errors = false;
      if (hasRequest('itemid')) {
       $items = API::Item()->get([
       'output' => ['itemid', 'type', 'snmp_community', 'snmp_oid', 'hostid', 'name', 'key_', 'delay', 'history',
       'trends', 'status', 'value_type', 'trapper_hosts', 'units', 'snmpv3_securityname',
       'snmpv3_securitylevel', 'snmpv3_authpassphrase', 'snmpv3_privpassphrase', 'logtimefmt', 'templateid',
       'valuemapid', 'params', 'ipmi_sensor', 'authtype', 'username', 'password', 'publickey', 'privatekey',
       'flags', 'interfaceid', 'port', 'description', 'inventory_link', 'lifetime', 'snmpv3_authprotocol',
       'snmpv3_privprotocol', 'snmpv3_contextname', 'jmx_endpoint', 'master_itemid', 'url', 'query_fields',
       'timeout', 'posts', 'status_codes', 'follow_redirects', 'post_type', 'http_proxy', 'headers',
       'retrieve_mode', 'request_method', 'output_format', 'ssl_cert_file', 'ssl_key_file', 'ssl_key_password',
       'verify_peer', 'verify_host', 'allow_traps', 'units', 'valuemapid'```
      Carl Slaughter [9:17 AM]
       in that same file, there is a second update starting at line 1648
       ```// items
       // Carl: Adding 'lastvalue', 'lastclock', 'units', 'valuemapid' to $options['output']
       $options = [
       'hostids' => $data['hostid'],
       'search' => [],
       'output' => [
       'itemid', 'type', 'hostid', 'name', 'key_', 'delay', 'history', 'trends', 'status', 'value_type', 'error',
       'templateid', 'flags', 'state', 'master_itemid', 'lastvalue', 'lastclock', 'units', 'valuemapid'
      

       

      2 additional changes in file /var/www/html/include/views/configuration.item.list.php

      Starting at line 55

      // create table
      // Carl: Adding "_('Last Check'), _('Last Value')" to this section
      // Carl: Companion File is Items.php
      $itemTable = (new CTableInfo())
       ->setHeader([
       (new CColHeader(
       (new CCheckBox('all_items'))->onClick("checkAll('".$itemForm->getName()."', 'all_items', 'group_itemid');")
       ))->addClass(ZBX_STYLE_CELL_WIDTH),
       _('Wizard'),
       empty($this->data['filter_hostid']) ? _('Host') : null,
       make_sorting_header(_('Name'), 'name', $data['sort'], $data['sortorder'], $url),
       _('Triggers'),
       make_sorting_header(_('Key'), 'key_', $data['sort'], $data['sortorder'], $url),
       make_sorting_header(_('Interval'), 'delay', $data['sort'], $data['sortorder'], $url),
       make_sorting_header(_('History'), 'history', $data['sort'], $data['sortorder'], $url),
       make_sorting_header(_('Trends'), 'trends', $data['sort'], $data['sortorder'], $url),
       make_sorting_header(_('Type'), 'type', $data['sort'], $data['sortorder'], $url),
       _('Applications'),
       make_sorting_header(_('Status'), 'status', $data['sort'], $data['sortorder'], $url),
       $data['showInfoColumn'] ? _('Info') : null,
       _('Last Check'),
       _('Last Value')
       ]);

      And at line 262

      $itemTable->addRow([
       new CCheckBox('group_itemid['.$item['itemid'].']', $item['itemid']),
       $wizard,
       empty($this->data['filter_hostid']) ? $item['host'] : null,
       $description,
       $triggerInfo,
       CHtml::encode($item['key_']),
       $item['delay'],
       $item['history'],
       $item['trends'],
       item_type2str($item['type']),
       CHtml::encode($item['applications_list']),
       $status,
       $data['showInfoColumn'] ? makeInformationList($info_icons) : null,
       zbx_date2str(DATE_TIME_FORMAT_SECONDS, $item['lastclock']),
       formatHistoryValue($item['lastvalue'], $item, false)
       ]);

       

            vmurzins Valdis Murzins
            cdslaughter Carl Slaughter
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: